TestStopReplica tests that STOP REPLICA correctly stops the replication process, and that warnings are logged when STOP REPLICA is invoked when replication is not running.
(t *testing.T)
| 388 | // TestStopReplica tests that STOP REPLICA correctly stops the replication process, and that |
| 389 | // warnings are logged when STOP REPLICA is invoked when replication is not running. |
| 390 | func TestStopReplica(t *testing.T) { |
| 391 | defer teardown(t) |
| 392 | startSqlServersWithSystemVars(t, duckReplicaSystemVars) |
| 393 | |
| 394 | // STOP REPLICA logs a warning if replication is not running |
| 395 | replicaDatabase.MustExec("STOP REPLICA;") |
| 396 | assertWarning(t, replicaDatabase, 3084, "Replication thread(s) for channel '' are already stopped.") |
| 397 | |
| 398 | // Start replication with bad connection params |
| 399 | replicaDatabase.MustExec("CHANGE REPLICATION SOURCE TO SOURCE_HOST='doesnotexist', SOURCE_PORT=111, SOURCE_USER='nobody';") |
| 400 | replicaDatabase.MustExec("START REPLICA;") |
| 401 | time.Sleep(200 * time.Millisecond) |
| 402 | status := showReplicaStatus(t) |
| 403 | require.Equal(t, "Connecting", status["Replica_IO_Running"]) |
| 404 | require.Equal(t, "Yes", status["Replica_SQL_Running"]) |
| 405 | |
| 406 | // STOP REPLICA works when replication cannot establish a connection |
| 407 | replicaDatabase.MustExec("STOP REPLICA;") |
| 408 | status = showReplicaStatus(t) |
| 409 | require.Equal(t, "No", status["Replica_IO_Running"]) |
| 410 | require.Equal(t, "No", status["Replica_SQL_Running"]) |
| 411 | |
| 412 | // START REPLICA and verify status |
| 413 | startReplicationAndCreateTestDb(t, mySqlPort) |
| 414 | time.Sleep(100 * time.Millisecond) |
| 415 | status = showReplicaStatus(t) |
| 416 | require.True(t, status["Replica_IO_Running"] == "Connecting" || status["Replica_IO_Running"] == "Yes") |
| 417 | require.Equal(t, "Yes", status["Replica_SQL_Running"]) |
| 418 | |
| 419 | // STOP REPLICA stops replication when it is running and connected to the source |
| 420 | replicaDatabase.MustExec("STOP REPLICA;") |
| 421 | status = showReplicaStatus(t) |
| 422 | require.Equal(t, "No", status["Replica_IO_Running"]) |
| 423 | require.Equal(t, "No", status["Replica_SQL_Running"]) |
| 424 | |
| 425 | // STOP REPLICA logs a warning if replication is not running |
| 426 | replicaDatabase.MustExec("STOP REPLICA;") |
| 427 | assertWarning(t, replicaDatabase, 3084, "Replication thread(s) for channel '' are already stopped.") |
| 428 | } |
| 429 | |
| 430 | // TestForeignKeyChecks tests that foreign key constraints replicate correctly when foreign key checks are |
| 431 | // enabled and disabled. |
nothing calls this directly
no test coverage detected