github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_black-white-list/run.sh (about)

     1  #!/bin/sh
     2  #
     3  # Copyright 2019 PingCAP, Inc.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -eux
    17  
    18  drop_dbs() {
    19      run_sql 'DROP DATABASE IF EXISTS firstdb;'
    20      run_sql 'DROP DATABASE IF EXISTS seconddb;'
    21  }
    22  
    23  check_firstdb_only() {
    24      run_sql 'SHOW DATABASES;'
    25      check_contains 'Database: firstdb'
    26      check_not_contains 'Database: seconddb'
    27      run_sql 'SHOW TABLES IN firstdb;'
    28      check_contains 'Tables_in_firstdb: first'
    29      check_contains 'Tables_in_firstdb: second'
    30      run_sql 'SHOW TABLES IN mysql;'
    31      check_not_contains 'Tables_in_mysql: testtable'
    32  }
    33  
    34  check_even_table_only() {
    35      run_sql 'SHOW DATABASES;'
    36      check_contains 'Database: firstdb'
    37      check_contains 'Database: seconddb'
    38      run_sql 'SHOW TABLES IN firstdb;'
    39      check_not_contains 'Tables_in_firstdb: first'
    40      check_contains 'Tables_in_firstdb: second'
    41      run_sql 'SHOW TABLES IN seconddb;'
    42      check_not_contains 'Tables_in_seconddb: third'
    43      check_contains 'Tables_in_seconddb: fourth'
    44      run_sql 'SHOW TABLES IN mysql;'
    45      check_not_contains 'Tables_in_mysql: testtable'
    46  }
    47  
    48  # Check if black-white-list works.
    49  
    50  drop_dbs
    51  run_lightning --config "tests/$TEST_NAME/firstdb-only.toml"
    52  check_firstdb_only
    53  
    54  drop_dbs
    55  run_lightning --config "tests/$TEST_NAME/even-table-only.toml"
    56  check_even_table_only
    57  
    58  # Check the same for table-filter
    59  
    60  drop_dbs
    61  run_lightning -f 'f*.*'
    62  check_firstdb_only
    63  
    64  drop_dbs
    65  run_lightning -f '!firstdb.*' -f '*.second' -f 'seconddb.fourth'
    66  check_even_table_only