MXS-1570: Test failover with no good candidate

- 1 master, 3 slaves
- "stop slave" on server 2
- "disable" log-bin on server 3
- set multi-source replication on server 4
- take down master
- no slave should be promoted
This commit is contained in:
Esa Korhonen
2017-12-19 11:39:32 +02:00
parent 0a6ef8713b
commit f9e8af83ce
4 changed files with 91 additions and 8 deletions

View File

@ -130,27 +130,31 @@ void basic_test(TestConnections& test)
* Do inserts, check that results are as expected.
*
* @param test Test connections
* @paran insert_count
* @param conn Which specific connection to use
* @param insert_count How many inserts should be done
* @return True, if successful
*/
void generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_count)
bool generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_count)
{
const char INSERT[] = "INSERT INTO test.t1 VALUES (%d);";
const char SELECT[] = "SELECT * FROM test.t1 ORDER BY id ASC;";
timespec short_sleep;
short_sleep.tv_sec = 0;
short_sleep.tv_nsec = 100000000;
for (int i = 0; i < insert_count; i++)
{
test.try_query(conn, INSERT, inserts++);
timespec time;
time.tv_sec = 0;
time.tv_nsec = 100000000;
nanosleep(&time, NULL);
nanosleep(&short_sleep, NULL);
}
sleep(1);
bool rval = false;
mysql_query(conn, SELECT);
MYSQL_RES *res = mysql_store_result(conn);
test.assert(res != NULL, "Query did not return a result set");
if (res)
{
rval = true;
MYSQL_ROW row;
// Check all values, they should go from 0 to 'inserts'
int expected_val = 0;
@ -160,6 +164,7 @@ void generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_c
if (value_read != expected_val)
{
test.assert(false, "Query returned %d when %d was expected", value_read, expected_val);
rval = false;
break;
}
expected_val++;
@ -167,9 +172,13 @@ void generate_traffic_and_check(TestConnections& test, MYSQL* conn, int insert_c
int num_rows = expected_val;
test.assert(num_rows == inserts, "Query returned %d rows when %d rows were expected",
num_rows, inserts);
if (num_rows != inserts)
{
rval = false;
}
mysql_free_result(res);
}
// mysql_close(conn);
return rval;
}
void print_gtids(TestConnections& test)