Skip to content

Commit 3a46075

Browse files
Fix flaky config generation test
See the code comment in the test for explanation
1 parent fb47230 commit 3a46075

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

pkg/generate/generate_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ func TestAccGenerate(t *testing.T) {
120120
require.NoError(t, err)
121121
return string(content)
122122
}(),
123+
generateConfig: func(cfg *generate.Config) {
124+
// The alerting rule group sometimes also creates an annotation.
125+
// It seems to be async so it makes the test flaky.
126+
// We can include only the resources we care about to avoid this.x
127+
cfg.IncludeResources = []string{
128+
"grafana_contact_point.*",
129+
"grafana_folder.*",
130+
"grafana_message_template.*",
131+
"grafana_mute_timing.*",
132+
"grafana_notification_policy.*",
133+
"grafana_organization.*",
134+
"grafana_rule_group.*",
135+
}
136+
},
123137
check: func(t *testing.T, tempDir string) {
124138
assertFiles(t, tempDir, "testdata/generate/alerting-in-org", []string{
125139
".terraform",

pkg/generate/testdata/generate/alerting-in-org/imports.tf

-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ import {
2828
id = "2"
2929
}
3030

31-
import {
32-
to = grafana_organization_preferences._1
33-
id = "1"
34-
}
35-
36-
import {
37-
to = grafana_organization_preferences._2
38-
id = "2"
39-
}
40-
4131
import {
4232
to = grafana_rule_group._2_alert-rule-folder_My_Rule_Group
4333
id = "2:alert-rule-folder:My Rule Group"

pkg/generate/testdata/generate/alerting-in-org/resources.tf

-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ resource "grafana_organization" "_2" {
5353
name = "alerting-org"
5454
}
5555

56-
# __generated__ by Terraform from "1"
57-
resource "grafana_organization_preferences" "_1" {
58-
}
59-
60-
# __generated__ by Terraform from "2"
61-
resource "grafana_organization_preferences" "_2" {
62-
org_id = grafana_organization._2.id
63-
}
64-
6556
# __generated__ by Terraform from "2:alert-rule-folder:My Rule Group"
6657
resource "grafana_rule_group" "_2_alert-rule-folder_My_Rule_Group" {
6758
disable_provenance = false

0 commit comments

Comments
 (0)