Skip to content

Commit bfce5fa

Browse files
authored
Attempt at making SyncOnRingTopologyChanges test more reliable. (#4348)
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]>
1 parent 40b623b commit bfce5fa

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pkg/alertmanager/multitenant_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,18 +1325,15 @@ func TestMultitenantAlertmanager_SyncOnRingTopologyChanges(t *testing.T) {
13251325
return ringDesc, true, nil
13261326
}))
13271327

1328-
// Assert if we expected a sync or not.
1328+
// Assert if we expected an additional sync or not.
1329+
expectedSyncs := 1
13291330
if tt.expected {
1330-
test.Poll(t, time.Second, float64(2), func() interface{} {
1331-
metrics := regs.BuildMetricFamiliesPerUser()
1332-
return metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total")
1333-
})
1334-
} else {
1335-
time.Sleep(250 * time.Millisecond)
1336-
1337-
metrics := regs.BuildMetricFamiliesPerUser()
1338-
assert.Equal(t, float64(1), metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total"))
1331+
expectedSyncs++
13391332
}
1333+
test.Poll(t, 5*time.Second, float64(expectedSyncs), func() interface{} {
1334+
metrics := regs.BuildMetricFamiliesPerUser()
1335+
return metrics.GetSumOfCounters("cortex_alertmanager_sync_configs_total")
1336+
})
13401337
})
13411338
}
13421339
}

0 commit comments

Comments
 (0)