From d3af4b582fa8e3820c3a370214c86bc5b6d5990e Mon Sep 17 00:00:00 2001 From: Fayzal Ghantiwala <114010985+fayzal-g@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:05:22 +0100 Subject: [PATCH] Alerting: Fix flaky tests (#109205) * Make sure random orgID isn't 0 * Retrigger CI --- pkg/services/ngalert/store/alert_rule_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/ngalert/store/alert_rule_test.go b/pkg/services/ngalert/store/alert_rule_test.go index a512b5949b4..e83dae824b6 100644 --- a/pkg/services/ngalert/store/alert_rule_test.go +++ b/pkg/services/ngalert/store/alert_rule_test.go @@ -565,7 +565,7 @@ func TestIntegration_DeleteAlertRulesByUID(t *testing.T) { }) t.Run("should remove all version and insert one with empty rule_uid when DeletedRuleRetention is set", func(t *testing.T) { - orgID := int64(rand.IntN(1000)) + orgID := int64(rand.IntN(1000)) + 1 gen = gen.With(gen.WithOrgID(orgID)) // Create a new store to pass the custom bus to check the signal b := &fakeBus{} @@ -632,7 +632,7 @@ func TestIntegration_DeleteAlertRulesByUID(t *testing.T) { }) t.Run("should remove all versions and not keep history if DeletedRuleRetention = 0", func(t *testing.T) { - orgID := int64(rand.IntN(1000)) + orgID := int64(rand.IntN(1000)) + 1 gen = gen.With(gen.WithOrgID(orgID)) // Create a new store to pass the custom bus to check the signal b := &fakeBus{} @@ -685,7 +685,7 @@ func TestIntegration_DeleteAlertRulesByUID(t *testing.T) { }) t.Run("should remove all versions and not keep history if permanently is true", func(t *testing.T) { - orgID := int64(rand.IntN(1000)) + orgID := int64(rand.IntN(1000)) + 1 gen = gen.With(gen.WithOrgID(orgID)) // Create a new store to pass the custom bus to check the signal b := &fakeBus{} @@ -2071,7 +2071,7 @@ func TestIntegration_CleanUpDeletedAlertRules(t *testing.T) { store.FeatureToggles = featuremgmt.WithFeatures(featuremgmt.FlagAlertRuleRestore) gen := models.RuleGen - orgID := int64(rand.IntN(1000)) + orgID := int64(rand.IntN(1000)) + 1 gen = gen.With(gen.WithOrgID(orgID))