From 14928e1cdfc3c8493f74dc2a733cd2b8b61f418d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Wed, 30 Oct 2024 12:25:35 -0600 Subject: [PATCH] Fix potential race condition in the test Signed-off-by: Florent Poinsard --- go/cmd/vttablet/cli/cli_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go/cmd/vttablet/cli/cli_test.go b/go/cmd/vttablet/cli/cli_test.go index 5c83124a971..c88ebd1b8ae 100644 --- a/go/cmd/vttablet/cli/cli_test.go +++ b/go/cmd/vttablet/cli/cli_test.go @@ -49,6 +49,10 @@ func TestRunFailsToStartTabletManager(t *testing.T) { "--restore_from_backup", } - err := Main.Execute() + // Creating and canceling the context so that pending tasks in tm_init gets canceled before we close the topo server + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + err := Main.ExecuteContext(ctx) require.ErrorContains(t, err, "you cannot enable --restore_from_backup without a my.cnf file") }