Skip to content

Commit

Permalink
Attempt at making SyncOnRingTopologyChanges test more reliable. (#4348)
Browse files Browse the repository at this point in the history
It was only waiting one second for the second sync to complete, which is
probably too harsh a deadline than necessary for overloaded systems.

Signed-off-by: Steve Simpson <[email protected]>
  • Loading branch information
stevesg authored Jul 9, 2021
1 parent 40b623b commit bfce5fa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/alertmanager/multitenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1325,18 +1325,15 @@ func TestMultitenantAlertmanager_SyncOnRingTopologyChanges(t *testing.T) {
return ringDesc, true, nil
}))

// Assert if we expected a sync or not.
// Assert if we expected an additional sync or not.
expectedSyncs := 1
if tt.expected {
test.Poll(t, time.Second, float64(2), func() interface{} {
metrics := regs.BuildMetricFamiliesPerUser()
return metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total")
})
} else {
time.Sleep(250 * time.Millisecond)

metrics := regs.BuildMetricFamiliesPerUser()
assert.Equal(t, float64(1), metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total"))
expectedSyncs++
}
test.Poll(t, 5*time.Second, float64(expectedSyncs), func() interface{} {
metrics := regs.BuildMetricFamiliesPerUser()
return metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total")
})
})
}
}
Expand Down

0 comments on commit bfce5fa

Please sign in to comment.