Skip to content

Commit 45cc319

Browse files
craig[bot]wenyihu6
andcommitted
Merge #154343
154343: asim: improve comments and test set up for sma r=tbg a=wenyihu6 Epic: CRDB-49117 Release note: none --- **asim: move sma and mma to its own folder** This commit moves sma and mma test data into their own subfolders under testdata for clearer organization. --- **asim: add vmodule to tests** This commit enables vmodule logs by default in asim dd tests. --- **asim: make RebalancingSnapshotRate configurable** This commit changes settingsGen.Settings.RebalancingSnapshotRate as a configurable setting to speed up certain tests. --- **asim: fix replica state set up string** Previously, the replica distribution of setup output was inaccurate since it used target replica and lease count but was not from the actual distribution. This commit updates the string to reflect the actual distribution. --- **asim: skip mma tests by default** This commit skips tests in the mma folder by default since they tend to be slower, removing the need for skip_under_ci commands. --- **asim: change store_byte_capacity to *_gib** This commit changes store_byte_capacity to store_byte_capacity_gib to improve human readability. --- **asim: improve assertion output one-off errors** This commit organizes assertion output to reduce one-off errors - discovered while testing assertions. --- **asim: align min key of gen_load and gen_ranges** Previously, gen_load had a minKey starting at 1, while gen_ranges started at 0. This commit updates gen_load to start at 0 so both are aligned. --- **asim: rename multi_store.txt to multi_store_lease.txt** This commit renames multi_store.txt test to multi_store_lease.txt to reflect that it asserts on lease balance. --- **asim: remove load_cluster.txt and zone_config.txt** This commit remove load_cluster.txt and zone_config.txt tests as they are too basic and add little value. --- **asim: fix io_overload** This test started failing after we fixed the skew distribution, since it relied on the replica count on store 5 starting and ending at 0. After fixing the skew distribution, the replica count on store 5 no longer began at 0, even though the total leases/replica count on s5 didn’t change throughout the test which means we weren't adding more leases/replicas to the s5. This change updates the test to force the replica count on store 5 to start at 0 again. --- **asim: improve comments and test set up for sma** This commit improves comments and test setup for tests under sma. Co-authored-by: wenyihu6 <[email protected]>
2 parents 9f095ea + 65e28a0 commit 45cc319

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+895
-913
lines changed

pkg/kv/kvserver/asim/assertion/assert.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,15 @@ func (sa SteadyStateAssertion) Assert(
150150
}
151151

152152
if sa.Threshold.isViolated(maxMean) || sa.Threshold.isViolated(minMean) || math.IsNaN(maxMean) || math.IsNaN(minMean) {
153+
if buf.Len() != 0 {
154+
fmt.Fprintf(&buf, "\n")
155+
}
153156
if holds {
154157
fmt.Fprintf(&buf, " %s\n", sa)
155158
holds = false
156159
}
157160
fmt.Fprintf(&buf,
158-
"\tstore=%d min/mean=%.2f max/mean=%.2f\n",
161+
"\tstore=%d min/mean=%.2f max/mean=%.2f",
159162
i+1, minMean, maxMean)
160163
}
161164
}
@@ -239,11 +242,14 @@ func (ba BalanceAssertion) Assert(
239242
"Balance assertion: stat=%s, max/mean=%.2f, threshold=%+v raw=%v",
240243
ba.Stat, maxMeanRatio, ba.Threshold, tickStats)
241244
if ba.Threshold.isViolated(maxMeanRatio) {
245+
if buf.Len() != 0 {
246+
fmt.Fprintf(&buf, "\n")
247+
}
242248
if holds {
243249
fmt.Fprintf(&buf, " %s\n", ba)
244250
holds = false
245251
}
246-
fmt.Fprintf(&buf, "\tmax/mean=%.2f tick=%d\n", maxMeanRatio, tick)
252+
fmt.Fprintf(&buf, "\tmax/mean=%.2f tick=%d", maxMeanRatio, tick)
247253
}
248254
}
249255
return holds, buf.String()
@@ -294,12 +300,15 @@ func (sa StoreStatAssertion) Assert(
294300
trimmedStoreStats := statTs[store-1][ticks-sa.Ticks-1:]
295301
for _, stat := range trimmedStoreStats {
296302
if sa.Threshold.isViolated(stat) {
303+
if buf.Len() != 0 {
304+
fmt.Fprintf(&buf, "\n")
305+
}
297306
if holds {
298307
holds = false
299308
fmt.Fprintf(&buf, " %s\n", sa)
300309
}
301310
fmt.Fprintf(&buf,
302-
"\tstore=%d stat=%.2f\n",
311+
"\tstore=%d stat=%.2f",
303312
store, stat)
304313
}
305314
}
@@ -378,6 +387,9 @@ func (ca ConformanceAssertion) Assert(
378387
violatingLeases, lessPrefLeases := len(leaseViolatingPrefs), len(leaseLessPrefs)
379388

380389
maybeInitHolds := func() {
390+
if buf.Len() != 0 {
391+
fmt.Fprintf(&buf, "\n")
392+
}
381393
if holds {
382394
holds = false
383395
fmt.Fprintf(&buf, " %s\n", ca)
@@ -473,11 +485,13 @@ func printRangeDesc(r roachpb.RangeDescriptor) string {
473485

474486
func PrintSpanConfigConformanceList(tag string, ranges []roachpb.ConformanceReportedRange) string {
475487
var buf strings.Builder
488+
buf.WriteString(fmt.Sprintf("%s:\n", tag))
489+
if len(ranges) == 0 {
490+
buf.WriteString("\t<none>")
491+
return buf.String()
492+
}
476493
for i, r := range ranges {
477-
if i == 0 {
478-
buf.WriteString(fmt.Sprintf("%s:\n", tag))
479-
}
480-
buf.WriteString(fmt.Sprintf(" %s applying %s", printRangeDesc(r.RangeDescriptor),
494+
buf.WriteString(fmt.Sprintf("\t%s applying %s", printRangeDesc(r.RangeDescriptor),
481495
spanconfigtestutils.PrintSpanConfigDiffedAgainstDefaults(r.Config)))
482496
if i != len(ranges)-1 {
483497
buf.WriteString("\n")

pkg/kv/kvserver/asim/state/new_state.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ func RangesInfoWithDistribution(
174174
targetReplicaCount := make(requestCounts, len(stores))
175175
targetLeaseCount := map[StoreID]int{}
176176
var buf strings.Builder
177-
_, _ = fmt.Fprintf(&buf, "[")
177+
storesInfo := make(map[StoreID]struct {
178+
replicas int
179+
leases int
180+
})
178181
for i, store := range stores {
179182
requiredReplicas := int(float64(numRanges*rf) * (replicaWeights[i]))
180183
requiredLeases := int(float64(numRanges) * (leaseWeights[i]))
@@ -183,13 +186,7 @@ func RangesInfoWithDistribution(
183186
id: int(store),
184187
}
185188
targetLeaseCount[store] = requiredLeases
186-
_, _ = fmt.Fprintf(&buf, "s%d:(%d,%d*)",
187-
int(store), requiredReplicas, requiredLeases)
188-
if i != len(stores)-1 {
189-
_, _ = fmt.Fprintf(&buf, ",")
190-
}
191189
}
192-
_, _ = fmt.Fprintf(&buf, "]")
193190

194191
// If there are no ranges specified, default to 1 range.
195192
if numRanges == 0 {
@@ -228,6 +225,9 @@ func RangesInfoWithDistribution(
228225
rangeInfo.Descriptor.InternalReplicas[replCandidateIdx] = roachpb.ReplicaDescriptor{
229226
StoreID: roachpb.StoreID(storeID),
230227
}
228+
storeInfo := storesInfo[storeID]
229+
storeInfo.replicas++
230+
storesInfo[storeID] = storeInfo
231231
if targetLeaseCount[storeID] >
232232
targetLeaseCount[StoreID(rangeInfo.Descriptor.InternalReplicas[maxLeaseRequestedIdx].StoreID)] {
233233
maxLeaseRequestedIdx = replCandidateIdx
@@ -240,9 +240,22 @@ func RangesInfoWithDistribution(
240240
lhStore := rangeInfo.Descriptor.InternalReplicas[maxLeaseRequestedIdx].StoreID
241241
targetLeaseCount[StoreID(lhStore)]--
242242
rangeInfo.Leaseholder = StoreID(lhStore)
243+
storeInfo := storesInfo[StoreID(lhStore)]
244+
storeInfo.leases++
245+
storesInfo[StoreID(lhStore)] = storeInfo
243246
ret[rngIdx] = rangeInfo
244247
}
245248

249+
_, _ = fmt.Fprintf(&buf, "[")
250+
for i, sID := range stores {
251+
storeInfo := storesInfo[sID]
252+
_, _ = fmt.Fprintf(&buf, "s%d:(%d,%d*)", int(sID), storeInfo.replicas, storeInfo.leases)
253+
if i != len(stores)-1 {
254+
_, _ = fmt.Fprintf(&buf, ",")
255+
}
256+
}
257+
_, _ = fmt.Fprintf(&buf, "]")
258+
246259
return ret, buf.String()
247260
}
248261

pkg/kv/kvserver/asim/tests/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ go_test(
5656
"//pkg/kv/kvserver/kvserverbase",
5757
"//pkg/kv/kvserver/liveness/livenesspb",
5858
"//pkg/spanconfig/spanconfigtestutils",
59+
"//pkg/testutils",
5960
"//pkg/testutils/datapathutils",
6061
"//pkg/testutils/skip",
6162
"//pkg/testutils/sniffarg",

0 commit comments

Comments
 (0)