Skip to content

Commit 3126dc0

Browse files
committed
asim: add explanatory output to assert command
I find that I have to check my understanding on this regularly, so perhaps this output can help understand that `balance` checks at each point in time that stores are close together, whereas `steady` checks that for each store, its min/max does not deviate from its mean (over time), in other words that the metric only changes within a small band. (Which does not imply any kind of convergence across the cluster; each store might settle on its own value for the metric).
1 parent 20c3c8e commit 3126dc0

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

pkg/kv/kvserver/asim/tests/datadriven_simulation_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,35 @@ func TestDataDriven(t *testing.T) {
580580
var ticks int
581581
scanMustExist(t, d, "type", &typ)
582582

583+
var buf strings.Builder
583584
switch typ {
584585
case "balance":
585586
scanMustExist(t, d, "stat", &stat)
586587
scanMustExist(t, d, "ticks", &ticks)
588+
threshold := scanThreshold(t, d)
587589
assertions = append(assertions, assertion.BalanceAssertion{
588590
Ticks: ticks,
589591
Stat: stat,
590-
Threshold: scanThreshold(t, d),
592+
Threshold: threshold,
591593
})
594+
_, _ = fmt.Fprintf(&buf, "asserting: max_{stores}(%s)/mean_{stores}(%s) %s %.2f at each of last %d ticks",
595+
stat, stat, threshold.ThresholdType, threshold.Value, ticks)
596+
// ^-- the max and mean are taken over the stores (with the tick fixed).
592597
case "steady":
593598
scanMustExist(t, d, "stat", &stat)
594599
scanMustExist(t, d, "ticks", &ticks)
600+
threshold := scanThreshold(t, d)
595601
assertions = append(assertions, assertion.SteadyStateAssertion{
596602
Ticks: ticks,
597603
Stat: stat,
598-
Threshold: scanThreshold(t, d),
604+
Threshold: threshold,
599605
})
606+
_, _ = fmt.Fprintf(&buf, "asserting: |%s(t)/mean_{T}(%s) - 1| %s %.2f ∀ t∈T and each store ("+
607+
"T=last %d ticks)",
608+
stat, stat, threshold.ThresholdType, threshold.Value, ticks)
609+
// ^-- the mean is taken over the ticks (and the check runs for each store).
610+
// These assertions are for "checking that change stops" (vs. balance
611+
// assertions, which verify that stores are close together on some metric).
600612
case "stat":
601613
var stores []int
602614
scanMustExist(t, d, "stat", &stat)
@@ -633,7 +645,7 @@ func TestDataDriven(t *testing.T) {
633645
default:
634646
panic("unknown assertion: " + typ)
635647
}
636-
return ""
648+
return buf.String()
637649
case "setting":
638650
// NB: delay could be supported for the below settings,
639651
// but it hasn't been needed yet.

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_add_node.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ add_node
1919
# Assert that the replica counts balance within 5% of each other among stores.
2020
assertion type=balance stat=replicas ticks=6 upper_bound=1.05
2121
----
22+
asserting: max_{stores}(replicas)/mean_{stores}(replicas) < 1.05 at each of last 6 ticks
2223

2324
# Update the replication factor for the keyspace to be 3, instead of the
2425
# initial replication factor of 1 set during generation.

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_multi_store.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ gen_load rate=7000 min_block=512 max_block=512
1313

1414
assertion stat=leases type=balance ticks=6 upper_bound=1
1515
----
16+
asserting: max_{stores}(leases)/mean_{stores}(leases) < 1.00 at each of last 6 ticks
1617

1718
assertion stat=leases type=steady ticks=6 upper_bound=0
1819
----
20+
asserting: |leases(t)/mean_{T}(leases) - 1| < 0.00 ∀ t∈T and each store (T=last 6 ticks)
1921

2022
eval duration=5m seed=42 metrics=(leases) cfgs=(sma-count,mma-only)
2123
----

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_rebalancing.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ gen_load rate=7000 rw_ratio=0.95 access_skew=false min_block=128 max_block=256
2121
# seconds) the max/mean QPS of the cluster does not exceed 1.15.
2222
assertion stat=qps type=balance ticks=6 upper_bound=1.15
2323
----
24+
asserting: max_{stores}(qps)/mean_{stores}(qps) < 1.15 at each of last 6 ticks
2425

2526
# The second is a steady state assertion. The steady state assertion requires
2627
# that during the last 6 ticks (60 seconds), the value of QPS per-store doesn't
@@ -31,6 +32,7 @@ assertion stat=qps type=balance ticks=6 upper_bound=1.15
3132
# to take a duration, not ticks.
3233
assertion stat=qps type=steady ticks=6 upper_bound=0.05
3334
----
35+
asserting: |qps(t)/mean_{T}(qps) - 1| < 0.05 ∀ t∈T and each store (T=last 6 ticks)
3436

3537
# The generators are then called and 2 simulation runs, named samples are
3638
# created and evaluated. Each sample has a fixed duration of 3 minutes.

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_splitting.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ setting split_qps_threshold=2500
2222
# ticks of the simulation.
2323
assertion stat=replicas type=steady ticks=6 upper_bound=0.00
2424
----
25+
asserting: |replicas(t)/mean_{T}(replicas) - 1| < 0.00 ∀ t∈T and each store (T=last 6 ticks)
2526

2627

2728
# Examine the number of replicas. Here there were 5 load based splits. This

0 commit comments

Comments
 (0)