-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asim: introduce rand testing framework with default-only settings
This patch lays the backbone of the randomized testing framework. Currently, it only supports default configuration for all options, implying that there is no randomization yet. Additionally, it refactors some of the existing structure in data_driven_test. Note that this should not change any existing behavior, and the main purpose is to make future commits cleaner. Part of: #106311 Release note: None
- Loading branch information
Showing
8 changed files
with
437 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// 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 ( | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/config" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/event" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/gen" | ||
) | ||
|
||
// This file defines the default parameters for allocator simulator testing, | ||
// including configurations for the cluster, ranges, load, static settings, | ||
// static events, assertions, and plot settings. | ||
|
||
const ( | ||
defaultNodes = 3 | ||
defaultStoresPerNode = 1 | ||
) | ||
|
||
func defaultBasicClusterGen() gen.BasicCluster { | ||
return gen.BasicCluster{ | ||
Nodes: defaultNodes, | ||
StoresPerNode: defaultStoresPerNode, | ||
} | ||
} | ||
|
||
func defaultStaticSettingsGen() gen.StaticSettings { | ||
return gen.StaticSettings{Settings: config.DefaultSimulationSettings()} | ||
} | ||
|
||
func defaultStaticEventsGen() gen.StaticEvents { | ||
return gen.StaticEvents{DelayedEvents: event.DelayedEventList{}} | ||
} | ||
|
||
const defaultKeyspace = 200000 | ||
|
||
const ( | ||
defaultRwRatio, defaultRate = 0.0, 0.0 | ||
defaultMinBlock, defaultMaxBlock = 1, 1 | ||
defaultMinKey, defaultMaxKey = int64(1), int64(defaultKeyspace) | ||
defaultSkewedAccess = false | ||
) | ||
|
||
func defaultLoadGen() gen.BasicLoad { | ||
return gen.BasicLoad{ | ||
RWRatio: defaultRwRatio, | ||
Rate: defaultRate, | ||
SkewedAccess: defaultSkewedAccess, | ||
MinBlockSize: defaultMinBlock, | ||
MaxBlockSize: defaultMaxBlock, | ||
MinKey: defaultMinKey, | ||
MaxKey: defaultMaxKey, | ||
} | ||
} | ||
|
||
const ( | ||
defaultRanges = 1 | ||
defaultPlacementType = gen.Uniform | ||
defaultReplicationFactor = 1 | ||
defaultBytes = 0 | ||
) | ||
|
||
func defaultBasicRangesGen() gen.BasicRanges { | ||
return gen.NewBasicRanges(defaultRanges, defaultPlacementType, defaultKeyspace, defaultReplicationFactor, defaultBytes) | ||
} | ||
|
||
func defaultAssertions() []SimulationAssertion { | ||
return []SimulationAssertion{ | ||
conformanceAssertion{ | ||
underreplicated: 0, | ||
overreplicated: 0, | ||
violating: 0, | ||
unavailable: 0, | ||
}, | ||
} | ||
} | ||
|
||
const ( | ||
defaultStat = "replicas" | ||
defaultHeight, defaultWidth = 15, 80 | ||
) | ||
|
||
type plotSettings struct { | ||
stat string | ||
height, width int | ||
} | ||
|
||
func defaultPlotSettings() plotSettings { | ||
return plotSettings{ | ||
stat: defaultStat, | ||
height: defaultHeight, | ||
width: defaultWidth, | ||
} | ||
} |
Oops, something went wrong.