Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asim: add random predefined cluster config selection #107075

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/kv/kvserver/asim/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ go_library(
"assert.go",
"default_settings.go",
"rand_framework.go",
"rand_gen.go",
],
importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/tests",
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/asim/tests/rand_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f randTestingFramework) getCluster() gen.ClusterGen {
if !f.s.randOptions.cluster {
return defaultBasicClusterGen()
}
return gen.BasicCluster{}
return f.randomClusterInfoGen(f.s.randSource)
}

func (f randTestingFramework) getRanges() gen.RangeGen {
Expand Down
25 changes: 25 additions & 0 deletions pkg/kv/kvserver/asim/tests/rand_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package tests

import (
"math/rand"

"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/gen"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/state"
)

// randomClusterInfoGen returns a randomly picked predefined configuration.
func (f randTestingFramework) randomClusterInfoGen(randSource *rand.Rand) gen.LoadedCluster {
chosenIndex := randSource.Intn(len(state.ClusterOptions))
chosenType := state.ClusterOptions[chosenIndex]
return loadClusterInfo(chosenType)
}
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/asim/tests/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func defaultSettings(randOptions testRandOptions) testSettings {
// default
func TestRandomized(t *testing.T) {
randOptions := testRandOptions{
cluster: false,
cluster: true,
ranges: false,
load: false,
staticSettings: false,
Expand Down