Skip to content

Commit 599a0db

Browse files
committed
AdminAPi test fixes:
Added check_sandbox_has_metadata() in the available test functions to wait for an instance which was recently added to a cluster to have the metedata schema before proceeding to any operation which requires the metadata: there may be some replication delay. Included the usage check_sandbox_has_metatadata() in check_sandbox_in_metadata(): in some cases the metadata schema wasn't present yet in the instance so the checks in the 'instances' table failed. Replaced the use of killSandboxInstance() with stopSandboxInstance() in super_read_only_handling test to make sure the instance is completely dead before restarting it to make sure the restart does not fail. Made use of try_restart_sandbox too instead of startSandboxInstance().
1 parent 29eb2b1 commit 599a0db

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

unittest/scripts/js_devapi/scripts/dba_super_read_only_handling.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ wait_slave_state(cluster, uri3, "ONLINE");
5858
// Wait for the third added instance to fetch all the replication data
5959
wait_sandbox_in_metadata(__mysql_sandbox_port3);
6060

61-
//@<OUT> Rejoins an instance
61+
// Rejoin instance
6262
stop_sandbox(__mysql_sandbox_port3);
6363
wait_slave_state(cluster, uri3, "(MISSING)");
64-
start_sandbox(__mysql_sandbox_port3);
65-
64+
try_restart_sandbox(__mysql_sandbox_port3);
6665
ensureSuperReadOnly(connection3);
66+
//@<OUT> Rejoins an instance
6767
cluster.rejoinInstance(connection3);
6868

6969
delete cluster;

unittest/scripts/js_devapi/setup/setup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ function wait_sandbox(timeout, wait_interval, condition, sandbox_port){
160160
return res;
161161
}
162162

163+
function check_sandbox_has_metadata() {
164+
var sandbox_has_metadata =
165+
session.runSql("SELECT count(*) FROM information_schema.TABLES WHERE (TABLE_SCHEMA = 'mysql_innodb_cluster_metadata') AND (TABLE_NAME = 'instances')").fetchOne()[0];
166+
167+
println("---> count(*) sandbox has metadata = " + sandbox_has_metadata);
168+
169+
return sandbox_has_metadata == "1";
170+
}
171+
163172
function check_sandbox_in_metadata(instance_port) {
164173
var sandbox_count_metadata =
165174
session.runSql("select count(*) from mysql_innodb_cluster_metadata.instances where instance_name = 'localhost:" + instance_port + "'").fetchOne()[0];
@@ -172,6 +181,7 @@ function check_sandbox_in_metadata(instance_port) {
172181
function wait_sandbox_in_metadata(instance_port) {
173182
var connected = connect_to_sandbox([instance_port]);
174183
if (connected) {
184+
wait(60, 1, check_sandbox_has_metadata);
175185
wait_sandbox(60, 1, check_sandbox_in_metadata, instance_port);
176186
session.close();
177187
}

0 commit comments

Comments
 (0)