Skip to content

Commit 2c650af

Browse files
craig[bot]nvb
andcommitted
108227: kv: deflake `TestAdminDecommissionedOperations` by setting `server.shutdown.query_wait` r=nvanbenschoten a=nvanbenschoten Fixes cockroachdb#107875. This commit deflakes `TestAdminDecommissionedOperations` by setting the `server.shutdown.query_wait` cluster setting to 0s. This ensures that SQL queries are immediately canceled during the drain, instead of being let run for up to 10s (the previous test timeout) before cancellation. The commit also increases the timeouts in the test to the default `testutils` timeouts, to avoid flakes when CI is slow. Release note: None Co-authored-by: Nathan VanBenschoten <[email protected]>
2 parents 01a6aab + 73f540d commit 2c650af

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/server/storage_api/decommission_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ func TestAdminDecommissionedOperations(t *testing.T) {
785785
})
786786
defer tc.Stopper().Stop(ctx)
787787

788+
// Configure drain to immediately cancel SQL queries and jobs to speed up the
789+
// test and avoid timeouts.
790+
serverutils.SetClusterSetting(t, tc, "server.shutdown.query_wait", 0)
788791
serverutils.SetClusterSetting(t, tc, "server.shutdown.jobs_wait", 0)
789792

790793
scratchKey := tc.ScratchRange(t)
@@ -801,8 +804,8 @@ func TestAdminDecommissionedOperations(t *testing.T) {
801804
require.NoError(t, srv.Decommission(ctx, status, []roachpb.NodeID{decomSrv.NodeID()}))
802805
}
803806

804-
testutils.SucceedsWithin(t, func() error {
805-
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
807+
testutils.SucceedsSoon(t, func() error {
808+
timeoutCtx, cancel := context.WithTimeout(ctx, testutils.DefaultSucceedsSoonDuration)
806809
defer cancel()
807810
_, err := decomSrv.DB().Scan(timeoutCtx, keys.LocalMax, keys.MaxKey, 0)
808811
if err == nil {
@@ -813,7 +816,7 @@ func TestAdminDecommissionedOperations(t *testing.T) {
813816
return nil
814817
}
815818
return err
816-
}, 10*time.Second)
819+
})
817820

818821
// Set up an admin client.
819822
adminClient := decomSrv.GetAdminClient(t)
@@ -925,8 +928,8 @@ func TestAdminDecommissionedOperations(t *testing.T) {
925928
for _, tc := range testcases {
926929
tc := tc
927930
t.Run(tc.name, func(t *testing.T) {
928-
testutils.SucceedsWithin(t, func() error {
929-
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
931+
testutils.SucceedsSoon(t, func() error {
932+
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
930933
defer cancel()
931934
err := tc.op(timeoutCtx, adminClient)
932935
if tc.expectCode == codes.OK {
@@ -945,7 +948,7 @@ func TestAdminDecommissionedOperations(t *testing.T) {
945948
}
946949
require.Equal(t, tc.expectCode, s.Code(), "%+v", err)
947950
return nil
948-
}, 10*time.Second)
951+
})
949952
})
950953
}
951954
}

0 commit comments

Comments
 (0)