Skip to content

Commit fb0e4de

Browse files
author
Piotr Bejda
authored
[dyninst/test] Allow some time for more events (#44363)
Co-authored-by: piotr.bejda <piotr.bejda@datadoghq.com>
1 parent 75956bb commit fb0e4de

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

pkg/dyninst/throttler_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,22 @@ func enforcesBudget(t *testing.T, busyloopPath string) {
9696
require.NoError(t, err)
9797
}
9898

99-
// Check that throttling happened.
100-
perCoreStats := program.RuntimeStats()
99+
// Check that throttling happened. We may need to give it more time.
100+
deadline := time.Now().Add(5 * time.Second)
101101
var stats loader.RuntimeStats
102-
for _, coreStats := range perCoreStats {
103-
stats.HitCnt += coreStats.HitCnt
104-
stats.ThrottledCnt += coreStats.ThrottledCnt
105-
stats.CPU += coreStats.CPU
102+
for {
103+
stats = loader.RuntimeStats{}
104+
perCoreStats := program.RuntimeStats()
105+
for _, coreStats := range perCoreStats {
106+
stats.HitCnt += coreStats.HitCnt
107+
stats.ThrottledCnt += coreStats.ThrottledCnt
108+
stats.CPU += coreStats.CPU
109+
}
110+
if int(stats.ThrottledCnt) > 0 {
111+
break
112+
}
113+
require.True(t, time.Now().Before(deadline), "timed out waiting for throttling to happen")
114+
time.Sleep(100 * time.Millisecond)
106115
}
107116
require.Greater(t, int(stats.HitCnt), expectedEvents)
108117
require.Greater(t, int(stats.ThrottledCnt), 0)

0 commit comments

Comments
 (0)