Skip to content

Commit

Permalink
liveness: future-proof TestNodeLivenessStatusMap
Browse files Browse the repository at this point in the history
Instead of using hooks that directly mutate the system config span,
using SQL statements to tweak zone configs future proofs this test for
compatibility with the span configs infrastructure.

Release note: None
  • Loading branch information
irfansharif committed Dec 24, 2021
1 parent 57d7485 commit 427a98f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
4 changes: 0 additions & 4 deletions pkg/kv/kvserver/liveness/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ go_test(
embed = [":liveness"],
deps = [
"//pkg/base",
"//pkg/config",
"//pkg/config/zonepb",
"//pkg/keys",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/liveness/livenesspb",
"//pkg/roachpb:with-mocks",
Expand All @@ -63,7 +60,6 @@ go_test(
"//pkg/util/syncutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_logtags//:logtags",
"@com_github_gogo_protobuf//proto",
"@com_github_kr_pretty//:pretty",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
Expand Down
15 changes: 3 additions & 12 deletions pkg/kv/kvserver/liveness/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb"
Expand All @@ -36,7 +33,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/logtags"
"github.com/gogo/protobuf/proto"
"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -174,14 +170,9 @@ func TestNodeLivenessStatusMap(t *testing.T) {
ctx = logtags.AddTag(ctx, "in test", nil)

log.Infof(ctx, "setting zone config to disable replication")
// Allow for inserting zone configs without having to go through (or
// duplicate the logic from) the CLI.
config.TestingSetupZoneConfigHook(tc.Stopper())
zoneConfig := zonepb.DefaultZoneConfig()
// Force just one replica per range to ensure that we can shut down
// nodes without endangering the liveness range.
zoneConfig.NumReplicas = proto.Int32(1)
config.TestingSetZoneConfig(keys.MetaRangesID, zoneConfig)
if _, err := tc.Conns[0].Exec(`ALTER RANGE meta CONFIGURE ZONE using num_replicas = 1`); err != nil {
t.Fatal(err)
}

log.Infof(ctx, "starting 3 more nodes")
tc.AddAndStartServer(t, serverArgs)
Expand Down

0 comments on commit 427a98f

Please sign in to comment.