From da1c0009a8785bf1aaf729d68eee622cbebe46e1 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 18 Jun 2020 04:14:09 +0800 Subject: [PATCH] tests: upgraded black-white-list test to test -f too --- tests/black-white-list/config.toml | 0 tests/black-white-list/run.sh | 73 +++++++++++++++++++----------- 2 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 tests/black-white-list/config.toml diff --git a/tests/black-white-list/config.toml b/tests/black-white-list/config.toml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/black-white-list/run.sh b/tests/black-white-list/run.sh index be22ef10d..0c108fd96 100755 --- a/tests/black-white-list/run.sh +++ b/tests/black-white-list/run.sh @@ -13,33 +13,54 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Check if black-white-list works. - set -eux -run_sql 'DROP DATABASE IF EXISTS firstdb;' -run_sql 'DROP DATABASE IF EXISTS seconddb;' +drop_dbs() { + run_sql 'DROP DATABASE IF EXISTS firstdb;' + run_sql 'DROP DATABASE IF EXISTS seconddb;' +} + +check_firstdb_only() { + run_sql 'SHOW DATABASES;' + check_contains 'Database: firstdb' + check_not_contains 'Database: seconddb' + run_sql 'SHOW TABLES IN firstdb;' + check_contains 'Tables_in_firstdb: first' + check_contains 'Tables_in_firstdb: second' + run_sql 'SHOW TABLES IN mysql;' + check_not_contains 'Tables_in_mysql: testtable' +} + +check_even_table_only() { + run_sql 'SHOW DATABASES;' + check_contains 'Database: firstdb' + check_contains 'Database: seconddb' + run_sql 'SHOW TABLES IN firstdb;' + check_not_contains 'Tables_in_firstdb: first' + check_contains 'Tables_in_firstdb: second' + run_sql 'SHOW TABLES IN seconddb;' + check_not_contains 'Tables_in_seconddb: third' + check_contains 'Tables_in_seconddb: fourth' + run_sql 'SHOW TABLES IN mysql;' + check_not_contains 'Tables_in_mysql: testtable' +} + +# Check if black-white-list works. + +drop_dbs run_lightning --config "tests/$TEST_NAME/firstdb-only.toml" -run_sql 'SHOW DATABASES;' -check_contains 'Database: firstdb' -check_not_contains 'Database: seconddb' -run_sql 'SHOW TABLES IN firstdb;' -check_contains 'Tables_in_firstdb: first' -check_contains 'Tables_in_firstdb: second' -run_sql 'SHOW TABLES IN mysql;' -check_not_contains 'Tables_in_mysql: testtable' - -run_sql 'DROP DATABASE IF EXISTS firstdb;' -run_sql 'DROP DATABASE IF EXISTS seconddb;' +check_firstdb_only + +drop_dbs run_lightning --config "tests/$TEST_NAME/even-table-only.toml" -run_sql 'SHOW DATABASES;' -check_contains 'Database: firstdb' -check_contains 'Database: seconddb' -run_sql 'SHOW TABLES IN firstdb;' -check_not_contains 'Tables_in_firstdb: first' -check_contains 'Tables_in_firstdb: second' -run_sql 'SHOW TABLES IN seconddb;' -check_not_contains 'Tables_in_seconddb: third' -check_contains 'Tables_in_seconddb: fourth' -run_sql 'SHOW TABLES IN mysql;' -check_not_contains 'Tables_in_mysql: testtable' +check_even_table_only + +# Check the same for table-filter + +drop_dbs +run_lightning -f 'f*.*' +check_firstdb_only + +drop_dbs +run_lightning -f '*.*' -f '!firstdb.*' -f '*.second' -f 'seconddb.fourth' +check_even_table_only