Skip to content

Commit 1f4888a

Browse files
craig[bot]alyshanjahani-crl
andcommitted
Merge #148091
148091: application_api: Fix TestHotRanges2Response r=alyshanjahani-crl a=alyshanjahani-crl Previously the test checked that ranges were sorted by QPS. The hot ranges status server endpoint sorts the response by CPU time. Fixes: #146917 Release note: None Co-authored-by: Alyshan Jahani <[email protected]>
2 parents 680f175 + 584050a commit 1f4888a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/server/application_api/storage_inspection_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,26 +353,31 @@ func TestHotRanges2Response(t *testing.T) {
353353
if len(hotRangesResp.Ranges) == 0 {
354354
t.Fatalf("didn't get hot range responses from any nodes")
355355
}
356-
lastQPS := math.MaxFloat64
356+
cpuSupport := grunning.Supported
357+
lastCPU := math.MaxFloat64
357358
for _, r := range hotRangesResp.Ranges {
358359
if r.RangeID == 0 {
359360
t.Errorf("unexpected empty range id: %d", r.RangeID)
360361
}
362+
361363
if r.QPS > 0 {
362364
if r.ReadsPerSecond == 0 && r.WritesPerSecond == 0 && r.ReadBytesPerSecond == 0 && r.WriteBytesPerSecond == 0 {
363365
t.Errorf("qps %.2f > 0, expected either reads=%.2f, writes=%.2f, readBytes=%.2f or writeBytes=%.2f to be non-zero",
364366
r.QPS, r.ReadsPerSecond, r.WritesPerSecond, r.ReadBytesPerSecond, r.WriteBytesPerSecond)
365367
}
366-
// If the architecture doesn't support sampling CPU, it
367-
// will also be zero.
368-
if grunning.Supported && r.CPUTimePerSecond == 0 {
368+
369+
if cpuSupport && r.CPUTimePerSecond == 0 {
369370
t.Errorf("qps %.2f > 0, expected cpu=%.2f to be non-zero", r.QPS, r.CPUTimePerSecond)
370371
}
371372
}
372-
if r.QPS > lastQPS {
373-
t.Errorf("unexpected increase in qps between ranges; prev=%.2f, current=%.2f", lastQPS, r.QPS)
373+
374+
// Ranges in response should be sorted by cpu.
375+
if cpuSupport {
376+
if r.CPUTimePerSecond > lastCPU {
377+
t.Errorf("unexpected increase in cpu between ranges; prev=%.2f, current=%.2f", lastCPU, r.CPUTimePerSecond)
378+
}
379+
lastCPU = r.CPUTimePerSecond
374380
}
375-
lastQPS = r.QPS
376381
}
377382
}
378383

0 commit comments

Comments
 (0)