From 9cd716fb0620a29575d8eece1f8d879cbd541505 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 15 Nov 2023 21:11:48 +0530 Subject: [PATCH] feat: use a singe timeout for all the deletions Signed-off-by: Manan Gupta --- go/test/endtoend/utils/utils.go | 5 ++--- go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go/test/endtoend/utils/utils.go b/go/test/endtoend/utils/utils.go index ae911b31704..0231cae7baf 100644 --- a/go/test/endtoend/utils/utils.go +++ b/go/test/endtoend/utils/utils.go @@ -283,11 +283,10 @@ func WaitForKsError(t *testing.T, vtgateProcess cluster.VtgateProcess, ks string } // WaitForTableDeletions waits for a table to be deleted -func WaitForTableDeletions(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string) error { - timeout := time.After(60 * time.Second) +func WaitForTableDeletions(ctx context.Context, t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string) error { for { select { - case <-timeout: + case <-ctx.Done(): return fmt.Errorf("schema tracking still found the table '%s'", tbl) default: res, err := vtgateProcess.ReadVSchema() diff --git a/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go b/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go index 4d3d9a98917..91e64e67d1e 100644 --- a/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go +++ b/go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go @@ -705,8 +705,10 @@ func createInitialSchema(t *testing.T, tcase *testCase) { } }) t.Run("waiting for vschema deletions to apply", func(t *testing.T) { + timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Minute) + defer cancel() for _, tableName := range tableNames { - err := utils.WaitForTableDeletions(t, clusterInstance.VtgateProcess, keyspaceName, tableName) + err := utils.WaitForTableDeletions(timeoutCtx, t, clusterInstance.VtgateProcess, keyspaceName, tableName) require.NoError(t, err) } })