Skip to content

Commit c730a87

Browse files
committed
asim: add tests for constraints validation, asim determinism
This patch adds an asim datadriven test case which sets up zone constraints and ensures its proper application and validation of these constraints. Part Of: cockroachdb#105904 Release Note: None
1 parent 02a7d32 commit c730a87

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

pkg/kv/kvserver/asim/asim_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ func TestRunAllocatorSimulator(t *testing.T) {
3939
sim.RunSim(ctx)
4040
}
4141

42-
func TestAllocatorSimulatorDeterministic(t *testing.T) {
43-
skip.WithIssue(t, 105904, "asim is non-deterministic")
42+
func TestAsimDeterministic(t *testing.T) {
43+
skip.UnderRace(t, 105904, "asim is non-deterministic under race")
4444
settings := config.DefaultSimulationSettings()
4545

4646
runs := 3
4747
duration := 15 * time.Minute
4848
settings.TickInterval = 2 * time.Second
4949

50-
stores := 7
50+
stores := 21
5151
replsPerRange := 3
52-
replicasPerStore := 100
52+
replicasPerStore := 600
53+
5354
// NB: We want 100 replicas per store, so the number of ranges required
5455
// will be 1/3 of the total replicas.
5556
ranges := (replicasPerStore * stores) / replsPerRange
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This test applies a configuration that prioritizes zone constraints, favoring
2+
# the US_East region. As a result, we expect a majority of replicas to be
3+
# distributed across stores numbered 1-12, all within the US_East region. The
4+
# allocation of replicas to stores outside of this region is expected to be
5+
# zero.
6+
7+
load_cluster config=multi_region
8+
----
9+
10+
# Create 200 ranges (RF=3) with zone preference set to US_East.
11+
set_span_config delay=1m
12+
[0,9999999999): num_replicas=3 constraints={'+region=US_East'}
13+
----
14+
15+
assertion type=conformance under=0 violating=0
16+
----
17+
18+
gen_ranges ranges=200
19+
----
20+
21+
# Stores=(13-25) should have number of replicas close to zero.
22+
assertion type=stat stat=replicas ticks=5 exact_bound=0 stores=(13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30)
23+
----
24+
25+
eval duration=10m samples=1 seed=42
26+
----
27+
OK
28+
29+
30+
topology
31+
----
32+
EU
33+
EU_1
34+
│ └── [25 26 27 28]
35+
EU_2
36+
│ └── [29 30 31 32]
37+
EU_3
38+
│ └── [33 34 35 36]
39+
US_East
40+
US_East_1
41+
│ └── [1 2 3 4]
42+
US_East_2
43+
│ └── [5 6 7 8]
44+
US_East_3
45+
│ └── [9 10 11 12]
46+
US_West
47+
US_West_1
48+
└── [13 14 15 16]
49+
US_West_2
50+
└── [17 18 19 20]
51+
US_West_3
52+
└── [21 22 23 24]
53+
54+
plot stat=replicas
55+
----
56+
----
57+
58+
51.00 ┤ ╭╭──────────────────────────────────────────────────────────────
59+
47.60 ┤ ╭╮╭─╭╯─────╯────────────────────────────────────────────────────────
60+
44.20 ┤ │╭──╯
61+
40.80 ┤ ╭╭╯╯
62+
37.40 ┤ ╭─╯
63+
34.00 ┤ │─╯
64+
30.60 ┤ │╯
65+
27.20 ┤ ╭│
66+
23.80 ┤ ╭╯
67+
20.40 ┤ │╯
68+
17.00 ┼────────╮╮
69+
13.60 ┤ ╰╮╮
70+
10.20 ┤ ╰│╰╮╮
71+
6.80 ┤ ╰─╮───╮
72+
3.40 ┤ ╰╰╰───╮──────╮
73+
0.00 ┤ ╰╰╰╰─╰───────────────────────────────────────────────────────────────
74+
replicas
75+
----
76+
----

0 commit comments

Comments
 (0)