mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 00:53:12 +00:00
Improve notifier queue test to reduce flakiness (#10984)
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
7479cd95b0
commit
2479fb42f0
@ -590,8 +590,13 @@ func TestHangingNotifier(t *testing.T) {
|
|||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var calledOnce bool
|
||||||
// Setting up a bad server. This server hangs for 2 seconds.
|
// Setting up a bad server. This server hangs for 2 seconds.
|
||||||
badServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
badServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if calledOnce {
|
||||||
|
t.Fatal("hanging server called multiple times")
|
||||||
|
}
|
||||||
|
calledOnce = true
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
@ -672,8 +677,8 @@ func TestHangingNotifier(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(300 * time.Millisecond):
|
case <-time.After(1 * time.Second):
|
||||||
t.Fatalf("Timeout after 300 milliseconds, targets not synced in time.")
|
t.Fatalf("Timeout after 1 second, targets not synced in time.")
|
||||||
case <-changed:
|
case <-changed:
|
||||||
// The good server has been hit in less than 3 seconds, therefore
|
// The good server has been hit in less than 3 seconds, therefore
|
||||||
// targets have been updated before a second call could be made to the
|
// targets have been updated before a second call could be made to the
|
||||||
|
Loading…
Reference in New Issue
Block a user