Skip to content

Commit c0c9665

Browse files
authored
Fix flaky informer tests (#3894)
1 parent d56d3e3 commit c0c9665

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

cmd/otel-allocator/internal/collector/collector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ func Test_runWatch(t *testing.T) {
190190
mapMutex.Lock()
191191
defer mapMutex.Unlock()
192192
assert.Len(collect, actual, len(tt.want))
193-
assert.Equal(collect, actual, tt.want)
193+
assert.Equal(collect, tt.want, actual)
194194
assert.Equal(collect, testutil.ToFloat64(collectorsDiscovered), float64(len(actual)))
195-
}, time.Second*3, time.Millisecond)
195+
}, time.Second*30, time.Millisecond*100)
196196
})
197197
}
198198
}

cmd/otel-allocator/internal/watcher/promOperator_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,16 +1068,13 @@ func TestNamespaceLabelUpdate(t *testing.T) {
10681068
},
10691069
}})
10701070

1071-
select {
1072-
case <-events:
1073-
case <-time.After(1 * time.Minute):
1074-
}
1075-
1076-
got, err = w.LoadConfig(context.Background())
1077-
assert.NoError(t, err)
1071+
assert.EventuallyWithT(t, func(collect *assert.CollectT) {
1072+
got, err = w.LoadConfig(context.Background())
1073+
assert.NoError(t, err)
10781074

1079-
sanitizeScrapeConfigsForTest(got.ScrapeConfigs)
1080-
assert.Equal(t, want_after.ScrapeConfigs, got.ScrapeConfigs)
1075+
sanitizeScrapeConfigsForTest(got.ScrapeConfigs)
1076+
assert.Equal(t, want_after.ScrapeConfigs, got.ScrapeConfigs)
1077+
}, time.Second*30, time.Millisecond*100)
10811078
}
10821079

10831080
func TestRateLimit(t *testing.T) {

0 commit comments

Comments
 (0)