mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 14:09:41 -08:00
fix(discovery): allow requireUpdate util to timeout in discovery/file/file_test.go.
The loop ran indefinitely if the condition isn't met. Before, each iteration created a new timer channel which was always outpaced by the other timer channel with smaller duration. minor detail: There was a memory leak: resources of the ~10 previous timers were constantly kept. With the fix, we may keep the resources of one timer around for defaultWait but this isn't worth the changes to make it right. Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This commit is contained in:
parent
78c5ce3196
commit
afc05129f1
|
@ -193,9 +193,10 @@ func (t *testRunner) targets() []*targetgroup.Group {
|
||||||
func (t *testRunner) requireUpdate(ref time.Time, expected []*targetgroup.Group) {
|
func (t *testRunner) requireUpdate(ref time.Time, expected []*targetgroup.Group) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
timeout := time.After(defaultWait)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(defaultWait):
|
case <-timeout:
|
||||||
t.Fatalf("Expected update but got none")
|
t.Fatalf("Expected update but got none")
|
||||||
return
|
return
|
||||||
case <-time.After(defaultWait / 10):
|
case <-time.After(defaultWait / 10):
|
||||||
|
|
Loading…
Reference in a new issue