Skip to content

Commit 80ceb18

Browse files
committed
testutils: improve validate DefaultDRPCOption error message
This improves the error message when node level server args are used instead of top-level server args for a test cluster. before: "improper use of DefaultDRPCOption in per-server args: 1 vs 0" now : "improper use of DefaultDRPCOption in per-server args: enabled vs unset" Release note: none Epic: none
1 parent 4c6b4ce commit 80ceb18

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pkg/base/test_server_args.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ const (
251251
TestDRPCEnabledRandomly
252252
)
253253

254+
func (d DefaultTestDRPCOption) String() string {
255+
switch d {
256+
case TestDRPCUnset:
257+
return "unset"
258+
case TestDRPCDisabled:
259+
return "disabled"
260+
case TestDRPCEnabled:
261+
return "enabled"
262+
case TestDRPCEnabledRandomly:
263+
return "enabled-randomly"
264+
default:
265+
panic("unreachable")
266+
}
267+
}
268+
254269
// TestClusterArgs contains the parameters one can set when creating a test
255270
// cluster. It contains a TestServerArgs instance which will be copied over to
256271
// every server.

pkg/testutils/testcluster/testcluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,16 @@ func (tc *TestCluster) validateDefaultTestTenant(
281281
// validateDefaultDRPCOption checks that per-server args don't override
282282
// the top-level DefaultDRPCOption setting inconsistently.
283283
func (tc *TestCluster) validateDefaultDRPCOption(
284-
t serverutils.TestFataler, nodes int, defaultDRPCOption base.DefaultTestDRPCOption,
284+
t serverutils.TestFataler, nodes int, clusterDRPCOption base.DefaultTestDRPCOption,
285285
) {
286286
for i := range nodes {
287287
if args, ok := tc.clusterArgs.ServerArgsPerNode[i]; ok &&
288288
args.DefaultDRPCOption != base.TestDRPCUnset &&
289-
args.DefaultDRPCOption != defaultDRPCOption {
289+
args.DefaultDRPCOption != clusterDRPCOption {
290290
tc.Stopper().Stop(context.Background())
291291
t.Fatalf("improper use of DefaultDRPCOption in per-server args: %v vs %v\n"+
292-
"Tip: use the top-level ServerArgs to set the default DRPC option.",
293-
args.DefaultDRPCOption, defaultDRPCOption)
292+
"Use the top-level ServerArgs to set the default DRPC option.",
293+
args.DefaultDRPCOption, clusterDRPCOption)
294294
}
295295
}
296296
}

0 commit comments

Comments
 (0)