From 427a98fbd4d46e4b51368e284dce360e0052fed7 Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Tue, 21 Dec 2021 22:27:27 -0500 Subject: [PATCH] liveness: future-proof TestNodeLivenessStatusMap 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 --- pkg/kv/kvserver/liveness/BUILD.bazel | 4 ---- pkg/kv/kvserver/liveness/client_test.go | 15 +++------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/kv/kvserver/liveness/BUILD.bazel b/pkg/kv/kvserver/liveness/BUILD.bazel index 1fa6121d1d69..962629ea783d 100644 --- a/pkg/kv/kvserver/liveness/BUILD.bazel +++ b/pkg/kv/kvserver/liveness/BUILD.bazel @@ -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", @@ -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", diff --git a/pkg/kv/kvserver/liveness/client_test.go b/pkg/kv/kvserver/liveness/client_test.go index 80019481dc8d..178369def9f0 100644 --- a/pkg/kv/kvserver/liveness/client_test.go +++ b/pkg/kv/kvserver/liveness/client_test.go @@ -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" @@ -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" @@ -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)