Add test for ALTER TABLE with avrorouter
The test does a set of ALTER TABLE operations and checks that MaxScale outputs the correct data.
This commit is contained in:
@ -608,6 +608,7 @@ add_test_executable(test_hints.cpp test_hints hints2 LABELS hintfilter LIGHT REP
|
|||||||
|
|
||||||
# Binlogrouter tests, these heavily alter the replication so they are run last
|
# Binlogrouter tests, these heavily alter the replication so they are run last
|
||||||
add_test_executable(avro.cpp avro avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
add_test_executable(avro.cpp avro avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||||
|
add_test_executable(avro_alter.cpp avro_alter avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||||
|
|
||||||
# Test avrorouter file compression
|
# Test avrorouter file compression
|
||||||
#add_test_script(avro_compression avro avro_compression LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
#add_test_script(avro_compression avro avro_compression LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||||
|
57
maxscale-system-test/avro_alter.cpp
Normal file
57
maxscale-system-test/avro_alter.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* @file avro_alter.cpp Test ALTER TABLE handling of avrorouter
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testconnections.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
test.set_timeout(600);
|
||||||
|
test.ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||||
|
|
||||||
|
/** Start master to binlogrouter replication */
|
||||||
|
if (!test.replicate_from_master())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
test.set_timeout(120);
|
||||||
|
test.repl->connect();
|
||||||
|
|
||||||
|
execute_query_silent(test.repl->nodes[0], "DROP TABLE test.t1");
|
||||||
|
execute_query(test.repl->nodes[0], "CREATE TABLE test.t1(id INT)");
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (1)");
|
||||||
|
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 ADD COLUMN a VARCHAR(100)");
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (2, \"a\")");
|
||||||
|
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 ADD COLUMN b FLOAT");
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (3, \"b\", 3.0)");
|
||||||
|
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 CHANGE COLUMN b c DATETIME(3)");
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (4, \"c\", NOW())");
|
||||||
|
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 DROP COLUMN c");
|
||||||
|
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (5, \"d\")");
|
||||||
|
|
||||||
|
test.repl->close_connections();
|
||||||
|
|
||||||
|
/** Give avrorouter some time to process the events */
|
||||||
|
test.stop_timeout();
|
||||||
|
sleep(10);
|
||||||
|
test.set_timeout(120);
|
||||||
|
|
||||||
|
for (int i = 1; i <=5; i++)
|
||||||
|
{
|
||||||
|
std::stringstream cmd;
|
||||||
|
cmd << "maxavrocheck -d /var/lib/maxscale/avro/test.t1.00000" << i << ".avro|wc -l";
|
||||||
|
char* rows = test.ssh_maxscale_output(true, cmd.str().c_str());
|
||||||
|
int nrows = atoi(rows);
|
||||||
|
free(rows);
|
||||||
|
test.add_result(nrows != 1, "Expected 1 line in file number %d, got %d", i, nrows);
|
||||||
|
}
|
||||||
|
|
||||||
|
execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER");
|
||||||
|
test.repl->fix_replication();
|
||||||
|
|
||||||
|
return test.global_result;
|
||||||
|
}
|
@ -432,6 +432,7 @@ int Mariadb_nodes::start_replication()
|
|||||||
"mysql -u root %s -e \"STOP SLAVE; RESET SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
"mysql -u root %s -e \"STOP SLAVE; RESET SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
||||||
socket_cmd[i]);
|
socket_cmd[i]);
|
||||||
ssh_node(i, str, true);
|
ssh_node(i, str, true);
|
||||||
|
ssh_node(i, "sudo rm -f /etc/my.cnf.d/kerb.cnf", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(str, "%s/create_user.sh", test_dir);
|
sprintf(str, "%s/create_user.sh", test_dir);
|
||||||
|
Reference in New Issue
Block a user