MXS-1849 Fix broken test to work with new schemarouter

This commit is contained in:
Marko 2018-07-04 16:05:38 +03:00
parent 89e83fab4b
commit 40d076b4ce
4 changed files with 36 additions and 36 deletions

View File

@ -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)

View File

@ -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 <iostream>
#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;
}

View File

@ -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 <iostream>
#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;
}