Avoid using test.repl->N in MariaDBMonitor tests

The value may not match the nodes used by the test.
This commit is contained in:
Esa Korhonen
2020-11-24 10:42:52 +02:00
parent abd1efefc6
commit 885077b4d0
11 changed files with 20 additions and 19 deletions

View File

@ -209,6 +209,7 @@ int main(int argc, char** argv)
int server2_ind = 1;
int server1_id = test.repl->get_server_id(server1_ind);
const int N = 4;
const char* server_names[] = {"server1", "server2", "server3", "server4"};
auto server1_name = server_names[server1_ind];
auto server2_name = server_names[server2_ind];
@ -307,10 +308,10 @@ int main(int argc, char** argv)
if (test.ok())
{
// Check that all other nodes are slaves.
for (int i = 1; i < test.repl->N; i++)
for (int i = 1; i < N; i++)
{
string server_name = server_names[i];
auto states = test.maxscales->get_server_status(server_name.c_str());
states = test.maxscales->get_server_status(server_name.c_str());
test.expect(states.count("Slave") == 1, "%s is not a slave.", server_name.c_str());
}
}

View File

@ -105,8 +105,7 @@ void run(TestConnections& test)
{
test.maxscales->wait_for_monitor();
int N = test.repl->N;
cout << "Nodes: " << N << endl;
const int N = 4;
expect(test, "server1", "Master", "Running");
expect(test, "server2", "Slave", "Running");

View File

@ -208,8 +208,7 @@ void run(XTestConnections& test)
{
test.maxscales->wait_for_monitor();
int N = test.repl->N;
cout << "Nodes: " << N << endl;
const int N = 4;
cout << "\nConnecting to MaxScale." << endl;
test.connect_maxscale();

View File

@ -158,8 +158,7 @@ void run(TestConnections& test)
{
test.maxscales->wait_for_monitor();
int N = test.repl->N;
cout << "Nodes: " << N << endl;
const int N = 4;
check_server_status(test, N);

View File

@ -34,6 +34,9 @@ const time_t FAILOVER_DURATION = 5;
// The test now runs only two failovers. Change for a longer time limit later.
// TODO: add semisync to remove this limitation.
// Number of backends
const int N = 4;
#define CMESSAGE(msg) \
do { \
stringstream ss; \
@ -506,7 +509,7 @@ bool is_valid_server_id(TestConnections& test, int id)
std::set<int> ids;
test.repl->connect();
for (int i = 0; i < test.repl->N; i++)
for (int i = 0; i < N; i++)
{
ids.insert(test.repl->get_server_id(i));
}

View File

@ -60,7 +60,7 @@ int main(int argc, char** argv)
const char READ_ONLY_OFF[] = "SET GLOBAL read_only=0;";
const int FIRST_MOD_NODE = 2; // Modify nodes 2 & 3
const int NODE_COUNT = test.repl->N;
const int NODE_COUNT = 4;
MYSQL** nodes = test.repl->nodes;
for (int i = FIRST_MOD_NODE; i < NODE_COUNT; i++)
{

View File

@ -53,7 +53,7 @@ int main(int argc, char** argv)
const char READ_ONLY_OFF[] = "SET GLOBAL read_only=0;";
test.repl->connect();
const int FIRST_MOD_NODE = 2; // Modify nodes 2 & 3
const int NODE_COUNT = test.repl->N;
const int NODE_COUNT = 4;
MYSQL** nodes = test.repl->nodes;
for (int i = FIRST_MOD_NODE; i < NODE_COUNT; i++)

View File

@ -50,6 +50,7 @@ int main(int argc, char** argv)
const char drop_query[] = "DROP TABLE test.t1;";
const char strict_mode[] = "SET GLOBAL gtid_strict_mode=%i;";
const int N = 4;
string server_names[] = {"server1", "server2", "server3", "server4"};
string master = "Master";
string slave = "Slave";
@ -118,7 +119,7 @@ int main(int argc, char** argv)
expect_server_status(server_names[3], slave);
// Check that the values on the databases are identical by summing the values.
int expected_sum = 55; // 11 * 5
for (int i = 0; i < test.repl->N; i++)
for (int i = 0; i < N; i++)
{
int sum = read_sum(i);
test.expect(sum == expected_sum,

View File

@ -123,8 +123,7 @@ void run(TestConnections& test)
{
test.maxscales->wait_for_monitor();
int N = test.repl->N;
cout << "Nodes: " << N << endl;
const int N = 4;
expect(test, "server1", "Master", "Running");
expect(test, "server2", "Slave", "Running");

View File

@ -29,13 +29,14 @@ int main(int argc, char** argv)
test.repl->connect();
delete_slave_binlogs(test);
const int N = 4;
// Enable the disks-plugin on all servers. Has to be done before MaxScale is on to prevent disk space
// monitoring from disabling itself.
bool disks_plugin_loaded = false;
const char strict_mode[] = "SET GLOBAL gtid_strict_mode=%i;";
test.repl->connect();
for (int i = 0; i < test.repl->N; i++)
for (int i = 0; i < N; i++)
{
MYSQL* conn = test.repl->nodes[i];
test.try_query(conn, "INSTALL SONAME 'disks';");
@ -149,8 +150,8 @@ int main(int argc, char** argv)
if (disks_plugin_loaded)
{
// Enable the disks-plugin on all servers.
for (int i = 0; i < test.repl->N; i++)
// Disable the disks-plugin on all servers.
for (int i = 0; i < N; i++)
{
MYSQL* conn = test.repl->nodes[i];
test.try_query(conn, "UNINSTALL SONAME 'disks';");

View File

@ -123,8 +123,7 @@ void run(TestConnections& test)
{
test.maxscales->wait_for_monitor();
int N = test.repl->N;
cout << "Nodes: " << N << endl;
const int N = 4;
expect(test, "server1", "Master", "Running");
expect(test, "server2", "Slave", "Running");