From 4e8a998bc19642e46b3d26f0ba934db466aef4f6 Mon Sep 17 00:00:00 2001 From: Tobias Grieger Date: Tue, 11 Jul 2023 14:47:35 +0200 Subject: [PATCH] loqrecovery: address a TODO --- pkg/kv/kvserver/loqrecovery/BUILD.bazel | 1 + .../loqrecovery/server_integration_test.go | 46 ++++++------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/pkg/kv/kvserver/loqrecovery/BUILD.bazel b/pkg/kv/kvserver/loqrecovery/BUILD.bazel index 451816b59b20..7f30694650fc 100644 --- a/pkg/kv/kvserver/loqrecovery/BUILD.bazel +++ b/pkg/kv/kvserver/loqrecovery/BUILD.bazel @@ -106,6 +106,7 @@ go_test( "//pkg/util/log", "//pkg/util/protoutil", "//pkg/util/randutil", + "//pkg/util/stop", "//pkg/util/strutil", "//pkg/util/timeutil", "//pkg/util/uuid", diff --git a/pkg/kv/kvserver/loqrecovery/server_integration_test.go b/pkg/kv/kvserver/loqrecovery/server_integration_test.go index d5cb4f0ad072..3326d6f1a500 100644 --- a/pkg/kv/kvserver/loqrecovery/server_integration_test.go +++ b/pkg/kv/kvserver/loqrecovery/server_integration_test.go @@ -35,6 +35,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" + "github.com/cockroachdb/cockroach/pkg/util/stop" "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/cockroachdb/errors" "github.com/stretchr/testify/require" @@ -197,8 +198,7 @@ func TestGetPlanStagingState(t *testing.T) { ctx := context.Background() - tc, reg, planStores, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, planStores := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -260,8 +260,7 @@ func TestStageRecoveryPlans(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -302,8 +301,7 @@ func TestStageBadVersions(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 1) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 1) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -332,8 +330,7 @@ func TestStageConflictingPlans(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -373,8 +370,7 @@ func TestForcePlanUpdate(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -416,8 +412,7 @@ func TestNodeDecommissioned(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -450,8 +445,7 @@ func TestRejectDecommissionReachableNode(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -472,8 +466,7 @@ func TestStageRecoveryPlansToWrongCluster(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -505,8 +498,7 @@ func TestRetrieveRangeStatus(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 5) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 5) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -562,8 +554,7 @@ func TestRetrieveApplyStatus(t *testing.T) { ctx := context.Background() - tc, reg, _, lReg := prepTestCluster(t, 5) - defer lReg.Close() + tc, reg, _ := prepTestCluster(t, 5) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -660,8 +651,7 @@ func TestRejectBadVersionApplication(t *testing.T) { ctx := context.Background() - tc, reg, pss, lReg := prepTestCluster(t, 3) - defer lReg.Close() + tc, reg, pss := prepTestCluster(t, 3) defer reg.CloseAllStickyInMemEngines() defer tc.Stopper().Stop(ctx) @@ -699,14 +689,7 @@ func TestRejectBadVersionApplication(t *testing.T) { func prepTestCluster( t *testing.T, nodes int, -) ( - *testcluster.TestCluster, - server.StickyInMemEnginesRegistry, - map[int]loqrecovery.PlanStore, - // TODO(during PR): no caller uses this now except to close it, so close it - // via stopper and don't return it. - *listenerutil.ListenerRegistry, -) { +) (*testcluster.TestCluster, server.StickyInMemEnginesRegistry, map[int]loqrecovery.PlanStore) { skip.UnderStressRace(t, "cluster frequently fails to start under stress race") reg := server.NewStickyInMemEnginesRegistry() @@ -737,7 +720,8 @@ func prepTestCluster( } tc := testcluster.NewTestCluster(t, nodes, args) tc.Start(t) - return tc, reg, prepInMemPlanStores(t, args.ServerArgsPerNode), lReg + tc.Stopper().AddCloser(stop.CloserFn(lReg.Close)) + return tc, reg, prepInMemPlanStores(t, args.ServerArgsPerNode) } func prepInMemPlanStores(