diff --git a/pkg/alertmanager/multitenant_test.go b/pkg/alertmanager/multitenant_test.go index d8af49e996..285914b99b 100644 --- a/pkg/alertmanager/multitenant_test.go +++ b/pkg/alertmanager/multitenant_test.go @@ -1817,7 +1817,14 @@ func TestAlertmanager_StateReplicationWithSharding_InitialSyncFromPeers(t *testi { metrics := registries.BuildMetricFamiliesPerUser() assert.Equal(t, float64(1), metrics.GetSumOfGauges("cortex_alertmanager_silences")) - assert.Equal(t, float64(1), metrics.GetSumOfCounters("cortex_alertmanager_state_replication_total")) + } + // 2.c. Wait for the silence replication to be attempted; note this is asynchronous. + { + test.Poll(t, 5*time.Second, float64(1), func() interface{} { + metrics := registries.BuildMetricFamiliesPerUser() + return metrics.GetSumOfCounters("cortex_alertmanager_state_replication_total") + }) + metrics := registries.BuildMetricFamiliesPerUser() assert.Equal(t, float64(0), metrics.GetSumOfCounters("cortex_alertmanager_state_replication_failed_total")) }