Skip to content

Commit

Permalink
loqrecovery: address a TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg committed Jul 12, 2023
1 parent 27af371 commit 4e8a998
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
1 change: 1 addition & 0 deletions pkg/kv/kvserver/loqrecovery/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
46 changes: 15 additions & 31 deletions pkg/kv/kvserver/loqrecovery/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4e8a998

Please sign in to comment.