@@ -12,42 +12,49 @@ import (
1212func TestAccSyntheticMonitoringInstallation (t * testing.T ) {
1313 testutils .CheckCloudAPITestsEnabled (t )
1414
15- var stack gapi.Stack
16- stackPrefix := "tfsminstalltest"
17- testAccDeleteExistingStacks (t , stackPrefix )
18- stackSlug := GetRandomStackName (stackPrefix )
19-
20- apiKeyPrefix := "testsminstall-"
21- testAccDeleteExistingCloudAPIKeys (t , apiKeyPrefix )
22- apiKeyName := apiKeyPrefix + acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
23-
24- resource .ParallelTest (t , resource.TestCase {
25- ProviderFactories : testutils .ProviderFactories ,
26- CheckDestroy : testAccStackCheckDestroy (& stack ),
27- Steps : []resource.TestStep {
28- {
29- Config : testAccSyntheticMonitoringInstallation (stackSlug , apiKeyName ),
30- Check : resource .ComposeTestCheckFunc (
31- testAccStackCheckExists ("grafana_cloud_stack.test" , & stack ),
32- resource .TestCheckResourceAttrSet ("grafana_synthetic_monitoring_installation.test" , "sm_access_token" ),
33- resource .TestCheckResourceAttrSet ("grafana_synthetic_monitoring_installation.test" , "stack_sm_api_url" ),
34- ),
35- },
36- // Test deletion
37- {
38- Config : testAccSyntheticMonitoringInstallation (stackSlug , apiKeyName ),
39- },
40- },
41- })
15+ for region , expectedURL := range map [string ]string {
16+ "prod-ca-east-0" : "https://synthetic-monitoring-api-ca-east-0.grafana.net" ,
17+ "eu" : "https://synthetic-monitoring-api-eu-west.grafana.net" ,
18+ } {
19+ t .Run (region , func (t * testing.T ) {
20+ var stack gapi.Stack
21+ stackPrefix := "tfsminstalltest"
22+ testAccDeleteExistingStacks (t , stackPrefix )
23+ stackSlug := GetRandomStackName (stackPrefix )
24+
25+ apiKeyPrefix := "testsminstall-"
26+ testAccDeleteExistingCloudAPIKeys (t , apiKeyPrefix )
27+ apiKeyName := apiKeyPrefix + acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
28+
29+ resource .ParallelTest (t , resource.TestCase {
30+ ProviderFactories : testutils .ProviderFactories ,
31+ CheckDestroy : testAccStackCheckDestroy (& stack ),
32+ Steps : []resource.TestStep {
33+ {
34+ Config : testAccSyntheticMonitoringInstallation (stackSlug , apiKeyName , region ),
35+ Check : resource .ComposeTestCheckFunc (
36+ testAccStackCheckExists ("grafana_cloud_stack.test" , & stack ),
37+ resource .TestCheckResourceAttrSet ("grafana_synthetic_monitoring_installation.test" , "sm_access_token" ),
38+ resource .TestCheckResourceAttr ("grafana_synthetic_monitoring_installation.test" , "stack_sm_api_url" , expectedURL ),
39+ ),
40+ },
41+ // Test deletion
42+ {
43+ Config : testAccSyntheticMonitoringInstallation_Base (stackSlug , apiKeyName , region ),
44+ },
45+ },
46+ })
47+ })
48+ }
4249}
4350
44- func testAccSyntheticMonitoringInstallation_Base (stackSlug , apiKeyName string ) string {
45- return testAccStackConfigBasic (stackSlug , stackSlug ) +
51+ func testAccSyntheticMonitoringInstallation_Base (stackSlug , apiKeyName , region string ) string {
52+ return testAccStackConfigBasicWithCustomResourceName (stackSlug , stackSlug , region , "test" ) +
4653 testAccCloudAPIKeyConfig (apiKeyName , "MetricsPublisher" )
4754}
4855
49- func testAccSyntheticMonitoringInstallation (stackSlug , apiKeyName string ) string {
50- return testAccSyntheticMonitoringInstallation_Base (stackSlug , apiKeyName ) +
56+ func testAccSyntheticMonitoringInstallation (stackSlug , apiKeyName , region string ) string {
57+ return testAccSyntheticMonitoringInstallation_Base (stackSlug , apiKeyName , region ) +
5158 `
5259 resource "grafana_synthetic_monitoring_installation" "test" {
5360 stack_id = grafana_cloud_stack.test.id
0 commit comments