From 24935b23f923525f9fb5e7389720c6d1df30e27e Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 9 Dec 2024 13:45:57 -0600 Subject: [PATCH] make sure the entire backup ctx is canceled before inspecting the logs Signed-off-by: Florent Poinsard --- go/vt/mysqlctl/blackbox/backup_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/vt/mysqlctl/blackbox/backup_test.go b/go/vt/mysqlctl/blackbox/backup_test.go index 31640fce094..b7e35304904 100644 --- a/go/vt/mysqlctl/blackbox/backup_test.go +++ b/go/vt/mysqlctl/blackbox/backup_test.go @@ -612,6 +612,7 @@ func TestExecuteBackupFailToWriteEachFileOnlyOnce(t *testing.T) { mysqld.ExpectedExecuteSuperQueryList = []string{"STOP REPLICA", "START REPLICA"} logger := logutil.NewMemoryLogger() + ctx, cancel := context.WithCancel(ctx) backupResult, err := be.ExecuteBackup(ctx, mysqlctl.BackupParams{ Logger: logger, Mysqld: mysqld, @@ -628,6 +629,7 @@ func TestExecuteBackupFailToWriteEachFileOnlyOnce(t *testing.T) { Shard: shard, MysqlShutdownTimeout: MysqlShutdownTimeout, }, bh) + cancel() expectedLogs := []string{ "Backing up file: test1/0.ibd (attempt 1/2)", @@ -680,6 +682,7 @@ func TestExecuteBackupFailToWriteFileTwice(t *testing.T) { logger := logutil.NewMemoryLogger() fakeStats := backupstats.NewFakeStats() + ctx, cancel := context.WithCancel(ctx) backupResult, err := be.ExecuteBackup(ctx, mysqlctl.BackupParams{ Logger: logger, Mysqld: mysqld, @@ -696,6 +699,7 @@ func TestExecuteBackupFailToWriteFileTwice(t *testing.T) { Shard: shard, MysqlShutdownTimeout: MysqlShutdownTimeout, }, bh) + cancel() // Sleep just long enough for everything to complete. // It's not flaky, the race detector detects a race when there isn't,