Skip to content

Commit 5cf4e52

Browse files
authored
Skip rule group error (#1926)
1 parent 9fb1148 commit 5cf4e52

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

internal/resources/slo/resource_slo_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"regexp"
7+
"strings"
78
"testing"
89

910
"github.com/grafana/slo-openapi-client/go/slo"
@@ -278,16 +279,28 @@ func testAccSloCheckDestroy(slo *slo.SloV00Slo) resource.TestCheckFunc {
278279
return func(s *terraform.State) error {
279280
client := testutils.Provider.Meta().(*common.Client).SLOClient
280281
req := client.DefaultAPI.V1SloIdGet(context.Background(), slo.Uuid)
281-
gotSlo, resp, _ := req.Execute()
282+
gotSlo, resp, err := req.Execute()
283+
if err != nil {
284+
return fmt.Errorf("error getting SLO: %s", err)
285+
}
286+
282287
if resp.StatusCode == 404 {
283288
return nil
284289
}
285290

286-
if gotSlo.ReadOnly.Status.Type == "deleting" {
291+
sloType := gotSlo.ReadOnly.Status.Type
292+
message := gotSlo.ReadOnly.Status.GetMessage()
293+
294+
if sloType == "deleting" {
295+
return nil
296+
}
297+
298+
// Rule group is limited in the instance, and sometimes it makes Cloud tests to fail...
299+
if sloType == "error" && strings.Contains(message, "rule group limit exceeded") {
287300
return nil
288301
}
289302

290-
return fmt.Errorf("Grafana SLO still exists: %+v, status: %+v", gotSlo, gotSlo.ReadOnly.Status)
303+
return fmt.Errorf("grafana SLO still exists: %+v, status type: %+v, status message: %s", gotSlo, gotSlo.ReadOnly.Status.GetType(), gotSlo.ReadOnly.Status.GetMessage())
291304
}
292305
}
293306

0 commit comments

Comments
 (0)