From 40d076b4ce4aba0f5e0d98d4304c244c33e4593f Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 4 Jul 2018 16:05:38 +0300 Subject: [PATCH] MXS-1849 Fix broken test to work with new schemarouter --- maxscale-system-test/CMakeLists.txt | 2 +- ...scale.cnf.template.schemarouter_duplicate} | 0 .../schemarouter_duplicate.cpp | 35 +++++++++++++++++++ .../schemarouter_duplicate_db.cpp | 35 ------------------- 4 files changed, 36 insertions(+), 36 deletions(-) rename maxscale-system-test/cnf/{maxscale.cnf.template.schemarouter_duplicate_db => maxscale.cnf.template.schemarouter_duplicate} (100%) create mode 100644 maxscale-system-test/schemarouter_duplicate.cpp delete mode 100644 maxscale-system-test/schemarouter_duplicate_db.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 9d1bc4216..c0eec7c50 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -804,7 +804,7 @@ add_test_executable(rwsplit_read_only_trx.cpp rwsplit_read_only_trx rwsplit_read #add_test_executable_notest(replication_manager_3nodes.cpp replication_manager_3nodes replication_manager_3nodes LABELS maxscale REPL_BACKEND) # Schemarouter duplicate database detection test: create DB on all nodes and then try query againt schema router -add_test_executable(schemarouter_duplicate_db.cpp schemarouter_duplicate_db schemarouter_duplicate_db LABELS schemarouter REPL_BACKEND) +add_test_executable(schemarouter_duplicate.cpp schemarouter_duplicate schemarouter_duplicate LABELS schemarouter REPL_BACKEND) # Test of external script execution add_test_executable(script.cpp script script LABELS maxscale REPL_BACKEND) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.schemarouter_duplicate_db b/maxscale-system-test/cnf/maxscale.cnf.template.schemarouter_duplicate similarity index 100% rename from maxscale-system-test/cnf/maxscale.cnf.template.schemarouter_duplicate_db rename to maxscale-system-test/cnf/maxscale.cnf.template.schemarouter_duplicate diff --git a/maxscale-system-test/schemarouter_duplicate.cpp b/maxscale-system-test/schemarouter_duplicate.cpp new file mode 100644 index 000000000..7e2a76571 --- /dev/null +++ b/maxscale-system-test/schemarouter_duplicate.cpp @@ -0,0 +1,35 @@ +/** + * @file schemarouter_duplicate.cpp - Schemarouter duplicate table detection test + * + * - Start MaxScale + * - create DB and table on all nodes + * - Connect to schemarouter + * - Execute query and expect failure + * - Check that message about duplicate tables is logged into error log + */ + + +#include +#include "testconnections.h" + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + test.set_timeout(30); + + /** Create a database and table on all nodes */ + test.repl->execute_query_all_nodes("STOP SLAVE"); + test.repl->execute_query_all_nodes("DROP DATABASE IF EXISTS duplicate;"); + test.repl->execute_query_all_nodes("CREATE DATABASE duplicate;"); + test.repl->execute_query_all_nodes("CREATE TABLE duplicate.duplicate (a int, b int);"); + + test.maxscales->connect_maxscale(0); + test.add_result(execute_query(test.maxscales->conn_rwsplit[0], "SELECT 1") == 0, + "Query should fail when duplicate table is found."); + test.stop_timeout(); + sleep(10); + test.check_log_err(0, (char *) "Duplicate tables found", true); + test.repl->execute_query_all_nodes("DROP DATABASE IF EXISTS duplicate"); + test.repl->execute_query_all_nodes("START SLAVE"); + return test.global_result; +} diff --git a/maxscale-system-test/schemarouter_duplicate_db.cpp b/maxscale-system-test/schemarouter_duplicate_db.cpp deleted file mode 100644 index 079a36d58..000000000 --- a/maxscale-system-test/schemarouter_duplicate_db.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file schemarouter_duplicate_db.cpp - Schemarouter duplicate database detection test - * - * - Start MaxScale - * - create DB on all nodes (directly via Master) - * - Connect to schemarouter - * - Execute query and expect failure - * - Check that message about duplicate databases is logged into error log - */ - - -#include -#include "testconnections.h" - -int main(int argc, char *argv[]) -{ - TestConnections * Test = new TestConnections(argc, argv); - - Test->set_timeout(30); - Test->maxscales->connect_maxscale(0); - - /** Create a database on all nodes */ - execute_query(Test->maxscales->conn_master[0], "DROP DATABASE IF EXISTS duplicate;"); - execute_query(Test->maxscales->conn_master[0], "CREATE DATABASE duplicate;"); - - Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], "SELECT 1") == 0, - "Query should fail when duplicate database is found."); - Test->stop_timeout(); - sleep(10); - Test->check_log_err(0, (char *) "Duplicate databases found", true); - - int rval = Test->global_result; - delete Test; - return rval; -}