Skip to content

Commit

Permalink
Fix flaky config generation test (#1642)
Browse files Browse the repository at this point in the history
See the code comment in the test for explanation
  • Loading branch information
julienduchesne authored Jun 14, 2024
1 parent 9d76cd8 commit a01dc75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
14 changes: 14 additions & 0 deletions pkg/generate/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ func TestAccGenerate(t *testing.T) {
require.NoError(t, err)
return string(content)
}(),
generateConfig: func(cfg *generate.Config) {
// The alerting rule group sometimes also creates an annotation.
// It seems to be async so it makes the test flaky.
// We can include only the resources we care about to avoid this.x
cfg.IncludeResources = []string{
"grafana_contact_point.*",
"grafana_folder.*",
"grafana_message_template.*",
"grafana_mute_timing.*",
"grafana_notification_policy.*",
"grafana_organization.*",
"grafana_rule_group.*",
}
},
check: func(t *testing.T, tempDir string) {
assertFiles(t, tempDir, "testdata/generate/alerting-in-org", []string{
".terraform",
Expand Down
10 changes: 0 additions & 10 deletions pkg/generate/testdata/generate/alerting-in-org/imports.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ import {
id = "2"
}

import {
to = grafana_organization_preferences._1
id = "1"
}

import {
to = grafana_organization_preferences._2
id = "2"
}

import {
to = grafana_rule_group._2_alert-rule-folder_My_Rule_Group
id = "2:alert-rule-folder:My Rule Group"
Expand Down
9 changes: 0 additions & 9 deletions pkg/generate/testdata/generate/alerting-in-org/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ resource "grafana_organization" "_2" {
name = "alerting-org"
}

# __generated__ by Terraform from "1"
resource "grafana_organization_preferences" "_1" {
}

# __generated__ by Terraform from "2"
resource "grafana_organization_preferences" "_2" {
org_id = grafana_organization._2.id
}

# __generated__ by Terraform from "2:alert-rule-folder:My Rule Group"
resource "grafana_rule_group" "_2_alert-rule-folder_My_Rule_Group" {
disable_provenance = false
Expand Down

0 comments on commit a01dc75

Please sign in to comment.