Skip to content

Commit 171c26c

Browse files
craig[bot]tbgrickystewart
committed
150496: asim: plot initial values only if nonzero r=tbg a=tbg Epic: CRDB-25222 150512: teamcity: add `s390x-test-failure` label for relevant unit test failures r=rail a=rickystewart Epic: CRDB-21133 Release note: None Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
3 parents 96bc36e + ba68970 + 08a489d commit 171c26c

26 files changed

+69
-68
lines changed

build/teamcity/cockroach/ci/tests-ibm-cloud-linux-s390x/unit_tests_impl.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TESTS=$(bazel query 'kind(go_test, pkg/...) except attr("tags", "[\[ ]integratio
2020

2121
set -x
2222

23-
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci -- test --config=ci --config=dev \
24-
$TESTS \
25-
--profile=/artifacts/profile.gz
23+
$(bazel info bazel-bin)/pkg/cmd/bazci/bazci_/bazci --extralabels=s390x-test-failure -- \
24+
test --config=ci --config=dev \
25+
$TESTS \
26+
--profile=/artifacts/profile.gz

pkg/cmd/bazci/bazci.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var (
6161
port int
6262
artifactsDir string
6363
githubPostFormatterName string
64+
extraLabels []string
6465

6566
rootCmd = &cobra.Command{
6667
Use: "bazci",
@@ -286,6 +287,12 @@ func init() {
286287
8998,
287288
"port to run the bazci server on",
288289
)
290+
rootCmd.Flags().StringSliceVar(
291+
&extraLabels,
292+
"extralabels",
293+
[]string{},
294+
"comma-separated list of extra labels to add to any filed GitHub issues",
295+
)
289296
}
290297

291298
func getRunEnvForBeaverHub() string {
@@ -488,7 +495,7 @@ func processTestXmls(testXmls []string) error {
488495
postErrors = append(postErrors, fmt.Sprintf("Failed to parse test.xml file with the following error: %+v", err))
489496
continue
490497
}
491-
if err := githubpost.PostFromTestXMLWithFormatterName(githubPostFormatterName, testSuites); err != nil {
498+
if err := githubpost.PostFromTestXMLWithFormatterName(githubPostFormatterName, testSuites, extraLabels); err != nil {
492499
postErrors = append(postErrors, fmt.Sprintf("Failed to process %s with the following error: %+v", testXml, err))
493500
continue
494501
}

pkg/cmd/bazci/githubpost/githubpost.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,22 @@ func DefaultIssueFilerFromFormatter(
111111

112112
}
113113

114-
func getFailurePosterFromFormatterName(formatterName string) FailurePoster {
114+
func getFailurePosterFromFormatterName(formatterName string, extraLabels []string) FailurePoster {
115115
var reqFromFailure Formatter
116116
switch formatterName {
117117
case "pebble-metamorphic":
118118
reqFromFailure = formatPebbleMetamorphicIssue
119119
default:
120120
reqFromFailure = DefaultFormatter
121121
}
122+
if len(extraLabels) > 0 {
123+
reqFromFailure2 := func(ctx context.Context, f Failure) (issues.IssueFormatter, issues.PostRequest) {
124+
i, r := reqFromFailure(ctx, f)
125+
r.Labels = append(r.Labels, extraLabels...)
126+
return i, r
127+
}
128+
reqFromFailure = reqFromFailure2
129+
}
122130
return DefaultIssueFilerFromFormatter(reqFromFailure)
123131
}
124132

@@ -129,7 +137,7 @@ func getFailurePosterFromFormatterName(formatterName string) FailurePoster {
129137
// GitHub.
130138
func PostFromJSON(formatterName string, in io.Reader) {
131139
ctx := context.Background()
132-
fileIssue := getFailurePosterFromFormatterName(formatterName)
140+
fileIssue := getFailurePosterFromFormatterName(formatterName, []string{})
133141
if err := listFailuresFromJSON(ctx, in, fileIssue); err != nil {
134142
log.Println(err) // keep going
135143
}
@@ -138,10 +146,13 @@ func PostFromJSON(formatterName string, in io.Reader) {
138146
// PostFromTestXMLWithFormatterName consumes a Bazel-style `test.xml` stream
139147
// and posts issues for any failed tests to GitHub. If there are no failed
140148
// tests, it does nothing. Unlike PostFromTestXMLWithFailurePoster, it takes a
141-
// formatter name.
142-
func PostFromTestXMLWithFormatterName(formatterName string, testXml buildutil.TestSuites) error {
149+
// formatter name. extraLabels is a list of extra labels to apply to the
150+
// created GitHub issue.
151+
func PostFromTestXMLWithFormatterName(
152+
formatterName string, testXml buildutil.TestSuites, extraLabels []string,
153+
) error {
143154
ctx := context.Background()
144-
fileIssue := getFailurePosterFromFormatterName(formatterName)
155+
fileIssue := getFailurePosterFromFormatterName(formatterName, extraLabels)
145156
return PostFromTestXMLWithFailurePoster(ctx, fileIssue, testXml)
146157
}
147158

@@ -738,7 +749,7 @@ func formatPebbleMetamorphicIssue(
738749
// insight into what caused the build failure and can't properly assign owners,
739750
// so a general issue is filed against test-eng in this case.
740751
func PostGeneralFailure(formatterName, logs string) {
741-
fileIssue := getFailurePosterFromFormatterName(formatterName)
752+
fileIssue := getFailurePosterFromFormatterName(formatterName, []string{})
742753
postGeneralFailureImpl(logs, fileIssue)
743754
}
744755

pkg/kv/kvserver/asim/history/history.go

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,52 @@ func (h *History) Listen(ctx context.Context, sms []metrics.StoreMetrics) {
3232
h.Recorded = append(h.Recorded, sms)
3333
}
3434

35-
func (h *History) ShowRecordedValueAt(idx int, stat string) string {
36-
var buf strings.Builder
37-
35+
// PerStoreValuesAt returns, for tick `idx` and metric `stat`, the per-store
36+
// measurements at that tick, in the History's store order.
37+
func (h *History) PerStoreValuesAt(idx int, stat string) []float64 {
3838
storeMetricsAtTick := h.Recorded[idx]
3939
values := make([]float64, 0, len(storeMetricsAtTick))
4040

41+
// Extract values for each store. Note that h.Recorded[idx] is already sorted
42+
// by store ID when appending to h.Recorded.
43+
for _, sm := range storeMetricsAtTick {
44+
value := sm.GetMetricValue(stat)
45+
values = append(values, value)
46+
}
47+
return values
48+
}
49+
50+
// ShowRecordedValueAt returns a string representation of the recorded values.
51+
// The returned boolean is false if (and only if) the recorded values were all
52+
// zero.
53+
func (h *History) ShowRecordedValueAt(idx int, stat string) (string, bool) {
54+
var buf strings.Builder
55+
56+
values := h.PerStoreValuesAt(idx, stat)
57+
4158
_, _ = fmt.Fprintf(&buf, "[")
4259

4360
// Extract values for each store. Note that h.Recorded[idx] is already sorted
4461
// by store ID when appending to h.Recorded.
45-
for i, sm := range storeMetricsAtTick {
62+
for i, v := range values {
4663
if i > 0 {
4764
_, _ = fmt.Fprintf(&buf, ", ")
4865
}
49-
value := sm.GetMetricValue(stat)
66+
storeID := h.Recorded[idx][i].StoreID
67+
5068
if stat == "disk_fraction_used" {
51-
_, _ = fmt.Fprintf(&buf, "s%v=%.2f", sm.StoreID, value)
69+
_, _ = fmt.Fprintf(&buf, "s%v=%.2f", storeID, v)
5270
} else {
53-
_, _ = fmt.Fprintf(&buf, "s%v=%.0f", sm.StoreID, value)
71+
_, _ = fmt.Fprintf(&buf, "s%v=%.0f", storeID, v)
5472
}
55-
values = append(values, value)
5673
}
5774
_, _ = fmt.Fprintf(&buf, "]")
5875
stddev, _ := stats.StandardDeviation(values)
5976
mean, _ := stats.Mean(values)
6077
sum, _ := stats.Sum(values)
6178
_, _ = fmt.Fprintf(&buf, " (stddev=%.2f, mean=%.2f, sum=%.0f)", stddev, mean, sum)
62-
return buf.String()
79+
// If the stddev is zero, all values are the same. If additionally the mean
80+
// is zero, all values were zero.
81+
nonzero := stddev > 0 || mean != 0
82+
return buf.String(), nonzero
6383
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,17 @@ func TestDataDriven(t *testing.T) {
563563
asciigraph.Height(height),
564564
asciigraph.Width(width),
565565
))
566-
567-
buf.WriteString("\ninitial store values: ")
568-
buf.WriteString(history.ShowRecordedValueAt(0, stat))
569-
buf.WriteString("\nlast store values: ")
570-
buf.WriteString(history.ShowRecordedValueAt(len(history.Recorded)-1, stat))
566+
buf.WriteString("\n")
567+
at0, ok0 := history.ShowRecordedValueAt(0, stat)
568+
if ok0 {
569+
buf.WriteString("initial store values: ")
570+
buf.WriteString(at0)
571+
buf.WriteString("\n")
572+
}
573+
s, _ := history.ShowRecordedValueAt(len(history.Recorded)-1, stat)
574+
buf.WriteString("last store values: ")
575+
buf.WriteString(s)
576+
buf.WriteString("\n")
571577

572578
return buf.String()
573579
default:

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ plot stat=qps sample=2
6262
395 ┤ ││ │ ││ │
6363
0 ┼─────────────────────────────╯─────────────────────────╯
6464
qps
65-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0] (stddev=0.00, mean=0.00, sum=0)
6665
last store values: [s1=996, s2=998, s3=996, s4=1000, s5=1000, s6=1012, s7=1001] (stddev=5.07, mean=1000.43, sum=7003)
6766

6867
plot stat=replica_moves sample=2
@@ -84,7 +83,6 @@ plot stat=replica_moves sample=2
8483
0.33 ┤│ │
8584
0.00 ┼───────────────────────────────────────────────────────────────────────────────
8685
replica_moves
87-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0] (stddev=0.00, mean=0.00, sum=0)
8886
last store values: [s1=5, s2=0, s3=1, s4=0, s5=0, s6=0, s7=0] (stddev=1.73, mean=0.86, sum=6)
8987

9088
# The cluster settings and simulation variables can be modified to examine how
@@ -133,7 +131,6 @@ plot stat=qps sample=4
133131
467 ┤ │ │││ │││ │ │ ││ ││ │ │ │ │ ╭│ │
134132
0 ┼────────────────────────────╯──────────────────────────────────────────────────
135133
qps
136-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0] (stddev=0.00, mean=0.00, sum=0)
137134
last store values: [s1=999, s2=0, s3=2002, s4=1998, s5=0, s6=1003, s7=999] (stddev=755.93, mean=1000.14, sum=7001)
138135

139136
# Plot the replica movements for the same sample, we should see a steadily
@@ -158,7 +155,6 @@ plot stat=replica_moves sample=4
158155
1.60 ┤ │╭╭─────╭──╭──────╯───────╭───────╯
159156
0.00 ┼───────────────────────────────╯
160157
replica_moves
161-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0] (stddev=0.00, mean=0.00, sum=0)
162158
last store values: [s1=24, s2=11, s3=16, s4=11, s5=5, s6=10, s7=6] (stddev=5.99, mean=11.86, sum=83)
163159

164160
# vim:ft=sh

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_skewed_cpu_even_ranges_mma

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ plot stat=cpu sample=1
8383
335000000 ┤│ ╭──────────╯ ╭───────────╯─────────────╯───╯ ╭─╯
8484
0 ┼──────────────────╯───╯─────────────────╯─────────╯
8585
cpu
86-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
8786
last store values: [s1=569996683, s2=572459858, s3=577041089, s4=557385814, s5=555426485, s6=556145510, s7=570251533, s8=555498030, s9=557066732] (stddev=8256286.12, mean=563474637.11, sum=5071271734)
8887

8988
plot stat=leases sample=1
@@ -149,5 +148,4 @@ plot stat=write_bytes_per_second
149148
335 ┤│ ╭╮ ╭───────────╯─────────────╯───╯ ╭──╯
150149
0 ┼───╯╰─────────────╯───╯─────────────────╯─────────╯
151150
write_bytes_per_second
152-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
153151
last store values: [s1=3757, s2=3916, s3=4016, s4=544, s5=554, s6=559, s7=569, s8=559, s9=546] (stddev=1576.26, mean=1668.89, sum=15020)

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_skewed_cpu_even_ranges_mma_and_queues

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ plot stat=cpu sample=1
8383
159192871 ┤│ │╭─╭─╯─╭───╯───────────────────────────╯
8484
0 ┼─────╯───╯
8585
cpu
86-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
8786
last store values: [s1=571144223, s2=571097655, s3=570432769, s4=556522751, s5=555345020, s6=560111935, s7=557209028, s8=559901378, s9=571601108] (stddev=6738397.52, mean=563707318.56, sum=5073365867)
8887

8988
plot stat=leases sample=1
@@ -149,5 +148,4 @@ plot stat=write_bytes_per_second
149148
335 ┤│ ╭────╭────────────────────────────╯╯ ╭──╯
150149
0 ┼───────╯─────╯───────────────────────────╯
151150
write_bytes_per_second
152-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
153151
last store values: [s1=4023, s2=3324, s3=3483, s4=832, s5=563, s6=698, s7=819, s8=693, s9=564] (stddev=1387.79, mean=1666.56, sum=14999)

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_skewed_cpu_even_ranges_sma

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ plot stat=cpu sample=1
8383
335000000 ┤│ │ ╭╭│╭╯╯──╯╯
8484
0 ┼──────────╯╯
8585
cpu
86-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
8786
last store values: [s1=562526385, s2=573916363, s3=562940607, s4=574474977, s5=560862237, s6=561701547, s7=558426354, s8=558535231, s9=559898216] (stddev=5806267.41, mean=563697990.78, sum=5073281917)
8887

8988
plot stat=leases sample=1
@@ -149,5 +148,4 @@ plot stat=write_bytes_per_second
149148
333 ┤│ ╭──╯╭╯
150149
0 ┼─────────╯
151150
write_bytes_per_second
152-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
153151
last store values: [s1=2358, s2=4029, s3=2063, s4=1391, s5=1245, s6=1398, s7=851, s8=829, s9=834] (stddev=977.64, mean=1666.44, sum=14998)

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_skewed_cpu_even_ranges_sma_and_queues

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ plot stat=cpu sample=1
8383
167928572 ┤│ │╭╭╯─╯
8484
0 ┼────╯─╯╯
8585
cpu
86-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
8786
last store values: [s1=561422336, s2=564403791, s3=564929833, s4=562766740, s5=564001678, s6=576295997, s7=559127795, s8=561707672, s9=560029049] (stddev=4772070.32, mean=563853876.78, sum=5074684891)
8887

8988
plot stat=leases sample=1
@@ -149,5 +148,4 @@ plot stat=write_bytes_per_second
149148
334 ┤│ ╭─╯╯╯─╯
150149
0 ┼───╯─╯╯╯
151150
write_bytes_per_second
152-
initial store values: [s1=0, s2=0, s3=0, s4=0, s5=0, s6=0, s7=0, s8=0, s9=0] (stddev=0.00, mean=0.00, sum=0)
153151
last store values: [s1=1098, s2=1667, s3=2366, s4=1531, s5=1948, s6=1536, s7=1386, s8=1669, s9=1799] (stddev=337.21, mean=1666.67, sum=15000)

0 commit comments

Comments
 (0)