From 1ffabca94a8926576e24474d675676fca2bbd232 Mon Sep 17 00:00:00 2001 From: Manan Gupta <35839558+GuptaManan100@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:29:22 +0530 Subject: [PATCH] Flaky test fix `TestCanGetKeyspaces` (#16214) Signed-off-by: Manan Gupta --- go/cmd/vttestserver/cli/main_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/go/cmd/vttestserver/cli/main_test.go b/go/cmd/vttestserver/cli/main_test.go index 3f65b5e1847..d417b5c4190 100644 --- a/go/cmd/vttestserver/cli/main_test.go +++ b/go/cmd/vttestserver/cli/main_test.go @@ -238,9 +238,6 @@ func TestCanGetKeyspaces(t *testing.T) { conf := config defer resetConfig(conf) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - clusterInstance, err := startCluster() require.NoError(t, err) defer clusterInstance.TearDown() @@ -251,6 +248,8 @@ func TestCanGetKeyspaces(t *testing.T) { } }() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() assertGetKeyspaces(ctx, t, clusterInstance) } @@ -258,9 +257,6 @@ func TestExternalTopoServerConsul(t *testing.T) { conf := config defer resetConfig(conf) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - // Start a single consul in the background. cmd, serverAddr := startConsul(t) defer func() { @@ -279,6 +275,8 @@ func TestExternalTopoServerConsul(t *testing.T) { require.NoError(t, err) defer cluster.TearDown() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() assertGetKeyspaces(ctx, t, cluster) }