Skip to content

Commit

Permalink
Merge #108227
Browse files Browse the repository at this point in the history
108227: kv: deflake `TestAdminDecommissionedOperations` by setting `server.shutdown.query_wait` r=nvanbenschoten a=nvanbenschoten

Fixes #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]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Aug 9, 2023
2 parents 01a6aab + 73f540d commit 2c650af
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/server/storage_api/decommission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ func TestAdminDecommissionedOperations(t *testing.T) {
})
defer tc.Stopper().Stop(ctx)

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

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

testutils.SucceedsWithin(t, func() error {
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
testutils.SucceedsSoon(t, func() error {
timeoutCtx, cancel := context.WithTimeout(ctx, testutils.DefaultSucceedsSoonDuration)
defer cancel()
_, err := decomSrv.DB().Scan(timeoutCtx, keys.LocalMax, keys.MaxKey, 0)
if err == nil {
Expand All @@ -813,7 +816,7 @@ func TestAdminDecommissionedOperations(t *testing.T) {
return nil
}
return err
}, 10*time.Second)
})

// Set up an admin client.
adminClient := decomSrv.GetAdminClient(t)
Expand Down Expand Up @@ -925,8 +928,8 @@ func TestAdminDecommissionedOperations(t *testing.T) {
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
testutils.SucceedsWithin(t, func() error {
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
testutils.SucceedsSoon(t, func() error {
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
err := tc.op(timeoutCtx, adminClient)
if tc.expectCode == codes.OK {
Expand All @@ -945,7 +948,7 @@ func TestAdminDecommissionedOperations(t *testing.T) {
}
require.Equal(t, tc.expectCode, s.Code(), "%+v", err)
return nil
}, 10*time.Second)
})
})
}
}
Expand Down

0 comments on commit 2c650af

Please sign in to comment.