Stop keepalived after the tests
Once the tests are done keepalived must be stopped. This is done to prevent it from affecting other tests.
This commit is contained in:
@ -33,6 +33,11 @@ int main(int argc, char* argv[])
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Test->on_destroy([&](){
|
||||
Test->maxscales->ssh_node_f(0, true, "service keepalived stop");
|
||||
Test->maxscales->ssh_node_f(1, true, "service keepalived stop");
|
||||
});
|
||||
|
||||
|
||||
Test->check_maxscale_alive(0);
|
||||
Test->check_maxscale_alive(1);
|
||||
|
@ -23,19 +23,23 @@ int main(int argc, char* argv[])
|
||||
TestConnections::multiple_maxscales(true);
|
||||
Mariadb_nodes::require_gtid(true);
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
if (test.maxscales->N < 2)
|
||||
{
|
||||
test.tprintf("At least 2 Maxscales are needed for this test. Exiting");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
test.on_destroy([&](){
|
||||
test.maxscales->ssh_node_f(0, true, "service keepalived stop");
|
||||
test.maxscales->ssh_node_f(1, true, "service keepalived stop");
|
||||
});
|
||||
|
||||
test.repl->connect();
|
||||
delete_slave_binlogs(test);
|
||||
basic_test(test);
|
||||
print_gtids(test);
|
||||
|
||||
test.tprintf("Number of MaxScales: %d\n", test.maxscales->N);
|
||||
test.expect(test.maxscales->N == 2,
|
||||
"Two Maxscales are needed for this test, %i nodes was/were detected.", test.maxscales->N);
|
||||
if (test.global_result != 0)
|
||||
{
|
||||
return test.global_result;
|
||||
}
|
||||
|
||||
test.tprintf("Configuring 'keepalived'\n");
|
||||
// Get test client IP, replace last number in it with 253 and use it as Virtual IP
|
||||
configure_keepalived(&test, (char*) "masterdown");
|
||||
|
@ -366,6 +366,11 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
|
||||
TestConnections::~TestConnections()
|
||||
{
|
||||
for (auto& a : m_on_destroy)
|
||||
{
|
||||
a();
|
||||
}
|
||||
|
||||
if (backend_ssl)
|
||||
{
|
||||
repl->disable_ssl();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <functional>
|
||||
|
||||
#include <maxbase/ccdefs.hh>
|
||||
|
||||
@ -597,9 +598,21 @@ public:
|
||||
*/
|
||||
int get_master_server_id(int m = 0);
|
||||
|
||||
/**
|
||||
* Add a callback that is called when the test ends
|
||||
*
|
||||
* @param func Function to call
|
||||
*/
|
||||
void on_destroy(std::function<void (void)> func)
|
||||
{
|
||||
m_on_destroy.push_back(func);
|
||||
}
|
||||
|
||||
private:
|
||||
void report_result(const char* format, va_list argp);
|
||||
void copy_one_mariadb_log(int i, std::string filename);
|
||||
|
||||
std::vector<std::function<void (void)>> m_on_destroy;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user