Skip to content

Commit 388f986

Browse files
authored
Merge pull request #588 from prometheus/beorn7/test
Attempt to fix flakiness of TestGoCollectorMemStats
2 parents 33a2efd + fe90eea commit 388f986

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

prometheus/go_collector_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ func TestGoCollectorMemStats(t *testing.T) {
184184
}
185185
}
186186

187-
// Speed up the timing to make the tast faster.
188-
c.msMaxWait = time.Millisecond
189-
c.msMaxAge = 10 * time.Millisecond
187+
// Speed up the timing to make the test faster.
188+
c.msMaxWait = 5 * time.Millisecond
189+
c.msMaxAge = 50 * time.Millisecond
190190

191191
// Scenario 1: msRead responds slowly, no previous memstats available,
192192
// msRead is executed anyway.
193193
c.msRead = func(ms *runtime.MemStats) {
194-
time.Sleep(3 * time.Millisecond)
194+
time.Sleep(20 * time.Millisecond)
195195
ms.Alloc = 1
196196
}
197197
checkCollect(1)
@@ -218,12 +218,12 @@ func TestGoCollectorMemStats(t *testing.T) {
218218
// Scenario 3: msRead responds slowly, previous memstats available, old
219219
// value collected.
220220
c.msRead = func(ms *runtime.MemStats) {
221-
time.Sleep(3 * time.Millisecond)
221+
time.Sleep(20 * time.Millisecond)
222222
ms.Alloc = 3
223223
}
224224
checkCollect(2)
225225
// After waiting, new value is still set in msLast.
226-
time.Sleep(12 * time.Millisecond)
226+
time.Sleep(80 * time.Millisecond)
227227
c.msMtx.Lock()
228228
if want, got := uint64(3), c.msLast.Alloc; want != got {
229229
t.Errorf("unexpected of msLast.Alloc, want %d, got %d", want, got)
@@ -233,7 +233,7 @@ func TestGoCollectorMemStats(t *testing.T) {
233233
// Scenario 4: msRead responds slowly, previous memstats is too old, new
234234
// value collected.
235235
c.msRead = func(ms *runtime.MemStats) {
236-
time.Sleep(3 * time.Millisecond)
236+
time.Sleep(20 * time.Millisecond)
237237
ms.Alloc = 4
238238
}
239239
checkCollect(4)

0 commit comments

Comments
 (0)