@@ -364,13 +364,17 @@ func TestAccConfigRSAlertConfiguration_importConfigNotifications(t *testing.T) {
364
364
})
365
365
}
366
366
367
+ // dummy keys used for credential values in third party notifications
368
+ const dummy32CharKey = "11111111111111111111111111111111"
369
+ const dummy36CharKey = "11111111-1111-1111-1111-111111111111"
370
+
367
371
// used for testing notification that does not define interval_min attribute
368
372
func TestAccConfigRSAlertConfiguration_importPagerDuty (t * testing.T ) {
369
- SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
370
373
var (
371
374
resourceName = "mongodbatlas_alert_configuration.test"
372
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
373
- serviceKey = os .Getenv ("PAGER_DUTY_SERVICE_KEY" )
375
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
376
+ projectName = acctest .RandomWithPrefix ("test-acc" )
377
+ serviceKey = dummy32CharKey
374
378
alert = & matlas.AlertConfiguration {}
375
379
)
376
380
@@ -380,7 +384,7 @@ func TestAccConfigRSAlertConfiguration_importPagerDuty(t *testing.T) {
380
384
CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
381
385
Steps : []resource.TestStep {
382
386
{
383
- Config : testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (projectID , serviceKey , true ),
387
+ Config : testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (orgID , projectName , serviceKey , true ),
384
388
Check : resource .ComposeTestCheckFunc (
385
389
testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
386
390
resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
@@ -398,23 +402,22 @@ func TestAccConfigRSAlertConfiguration_importPagerDuty(t *testing.T) {
398
402
}
399
403
400
404
func TestAccConfigRSAlertConfiguration_DataDog (t * testing.T ) {
401
- SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
402
- SkipTest (t ) // Will force skip if enabled
403
405
var (
404
406
resourceName = "mongodbatlas_alert_configuration.test"
405
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
406
- ddAPIKey = os .Getenv ("DD_API_KEY" )
407
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
408
+ projectName = acctest .RandomWithPrefix ("test-acc" )
409
+ ddAPIKey = dummy32CharKey
407
410
ddRegion = "US"
408
411
alert = & matlas.AlertConfiguration {}
409
412
)
410
413
411
- resource .Test (t , resource.TestCase {
412
- PreCheck : func () { testAccPreCheck (t ) },
414
+ resource .ParallelTest (t , resource.TestCase {
415
+ PreCheck : func () { testAccPreCheckBasic (t ) },
413
416
ProtoV6ProviderFactories : testAccProviderV6Factories ,
414
417
CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
415
418
Steps : []resource.TestStep {
416
419
{
417
- Config : testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (projectID , ddAPIKey , ddRegion , true ),
420
+ Config : testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (orgID , projectName , ddAPIKey , ddRegion , true ),
418
421
Check : resource .ComposeTestCheckFunc (
419
422
testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
420
423
resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
@@ -425,21 +428,21 @@ func TestAccConfigRSAlertConfiguration_DataDog(t *testing.T) {
425
428
}
426
429
427
430
func TestAccConfigRSAlertConfiguration_PagerDuty (t * testing.T ) {
428
- SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
429
431
var (
430
432
resourceName = "mongodbatlas_alert_configuration.test"
431
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
432
- serviceKey = os .Getenv ("PAGER_DUTY_SERVICE_KEY" )
433
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
434
+ projectName = acctest .RandomWithPrefix ("test-acc" )
435
+ serviceKey = dummy32CharKey
433
436
alert = & matlas.AlertConfiguration {}
434
437
)
435
438
436
- resource .Test (t , resource.TestCase {
437
- PreCheck : func () { testAccPreCheck (t ) },
439
+ resource .ParallelTest (t , resource.TestCase {
440
+ PreCheck : func () { testAccPreCheckBasic (t ) },
438
441
ProtoV6ProviderFactories : testAccProviderV6Factories ,
439
442
CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
440
443
Steps : []resource.TestStep {
441
444
{
442
- Config : testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (projectID , serviceKey , true ),
445
+ Config : testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (orgID , projectName , serviceKey , true ),
443
446
Check : resource .ComposeTestCheckFunc (
444
447
testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
445
448
resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
@@ -450,21 +453,21 @@ func TestAccConfigRSAlertConfiguration_PagerDuty(t *testing.T) {
450
453
}
451
454
452
455
func TestAccConfigRSAlertConfiguration_OpsGenie (t * testing.T ) {
453
- SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
454
456
var (
455
457
resourceName = "mongodbatlas_alert_configuration.test"
456
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
457
- apiKey = os .Getenv ("OPS_GENIE_API_KEY" )
458
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
459
+ projectName = acctest .RandomWithPrefix ("test-acc" )
460
+ apiKey = dummy36CharKey
458
461
alert = & matlas.AlertConfiguration {}
459
462
)
460
463
461
- resource .Test (t , resource.TestCase {
462
- PreCheck : func () { testAccPreCheck (t ) },
464
+ resource .ParallelTest (t , resource.TestCase {
465
+ PreCheck : func () { testAccPreCheckBasic (t ) },
463
466
ProtoV6ProviderFactories : testAccProviderV6Factories ,
464
467
CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
465
468
Steps : []resource.TestStep {
466
469
{
467
- Config : testAccMongoDBAtlasAlertConfigurationOpsGenieConfig (projectID , apiKey , true ),
470
+ Config : testAccMongoDBAtlasAlertConfigurationOpsGenieConfig (orgID , projectName , apiKey , true ),
468
471
Check : resource .ComposeTestCheckFunc (
469
472
testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
470
473
resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
@@ -475,21 +478,21 @@ func TestAccConfigRSAlertConfiguration_OpsGenie(t *testing.T) {
475
478
}
476
479
477
480
func TestAccConfigRSAlertConfiguration_VictorOps (t * testing.T ) {
478
- SkipTestExtCred (t ) // Will skip because requires external credentials aka api key
479
481
var (
480
482
resourceName = "mongodbatlas_alert_configuration.test"
481
- projectID = os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
482
- apiKey = os .Getenv ("VICTOR_OPS_API_KEY" )
483
+ orgID = os .Getenv ("MONGODB_ATLAS_ORG_ID" )
484
+ projectName = acctest .RandomWithPrefix ("test-acc" )
485
+ apiKey = dummy36CharKey
483
486
alert = & matlas.AlertConfiguration {}
484
487
)
485
488
486
- resource .Test (t , resource.TestCase {
487
- PreCheck : func () { testAccPreCheck (t ) },
489
+ resource .ParallelTest (t , resource.TestCase {
490
+ PreCheck : func () { testAccPreCheckBasic (t ) },
488
491
ProtoV6ProviderFactories : testAccProviderV6Factories ,
489
492
CheckDestroy : testAccCheckMongoDBAtlasAlertConfigurationDestroy ,
490
493
Steps : []resource.TestStep {
491
494
{
492
- Config : testAccMongoDBAtlasAlertConfigurationVictorOpsConfig (projectID , apiKey , true ),
495
+ Config : testAccMongoDBAtlasAlertConfigurationVictorOpsConfig (orgID , projectName , apiKey , true ),
493
496
Check : resource .ComposeTestCheckFunc (
494
497
testAccCheckMongoDBAtlasAlertConfigurationExists (resourceName , alert ),
495
498
resource .TestCheckResourceAttrSet (resourceName , "project_id" ),
@@ -777,19 +780,23 @@ func testAccMongoDBAtlasAlertConfigurationConfigWithThresholdUpdated(orgID, proj
777
780
` , orgID , projectName , enabled , threshold )
778
781
}
779
782
780
- func testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (projectID , dataDogAPIKey , dataDogRegion string , enabled bool ) string {
783
+ func testAccMongoDBAtlasAlertConfigurationConfigWithDataDog (orgID , projectName , dataDogAPIKey , dataDogRegion string , enabled bool ) string {
781
784
return fmt .Sprintf (`
785
+ resource "mongodbatlas_project" "test" {
786
+ name = %[2]q
787
+ org_id = %[1]q
788
+ }
782
789
resource "mongodbatlas_third_party_integration" "atlas_datadog" {
783
- project_id = "%[1]s"
790
+ project_id = mongodbatlas_project.test.id
784
791
type = "DATADOG"
785
- api_key = "%[3 ]s"
786
- region = "%[4 ]s"
792
+ api_key = "%[4 ]s"
793
+ region = "%[5 ]s"
787
794
}
788
795
789
796
resource "mongodbatlas_alert_configuration" "test" {
790
- project_id = "%[1]s"
797
+ project_id = mongodbatlas_project.test.id
791
798
event_type = "REPLICATION_OPLOG_WINDOW_RUNNING_OUT"
792
- enabled = %t
799
+ enabled = %[3] t
793
800
794
801
notification {
795
802
type_name = "GROUP"
@@ -820,57 +827,69 @@ resource "mongodbatlas_alert_configuration" "test" {
820
827
units = "HOURS"
821
828
}
822
829
}
823
- ` , projectID , enabled , dataDogAPIKey , dataDogRegion )
830
+ ` , orgID , projectName , enabled , dataDogAPIKey , dataDogRegion )
824
831
}
825
832
826
- func testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (projectID , serviceKey string , enabled bool ) string {
833
+ func testAccMongoDBAtlasAlertConfigurationPagerDutyConfig (orgID , projectName , serviceKey string , enabled bool ) string {
827
834
return fmt .Sprintf (`
835
+ resource "mongodbatlas_project" "test" {
836
+ name = %[2]q
837
+ org_id = %[1]q
838
+ }
828
839
resource "mongodbatlas_alert_configuration" "test" {
829
- project_id = %[1]q
840
+ project_id = mongodbatlas_project.test.id
830
841
event_type = "NO_PRIMARY"
831
- enabled = "%[3 ]t"
842
+ enabled = "%[4 ]t"
832
843
833
844
notification {
834
845
type_name = "PAGER_DUTY"
835
- service_key = %[2 ]q
846
+ service_key = %[3 ]q
836
847
delay_min = 0
837
848
}
838
849
}
839
- ` , projectID , serviceKey , enabled )
850
+ ` , orgID , projectName , serviceKey , enabled )
840
851
}
841
852
842
- func testAccMongoDBAtlasAlertConfigurationOpsGenieConfig (projectID , apiKey string , enabled bool ) string {
853
+ func testAccMongoDBAtlasAlertConfigurationOpsGenieConfig (orgID , projectName , apiKey string , enabled bool ) string {
843
854
return fmt .Sprintf (`
855
+ resource "mongodbatlas_project" "test" {
856
+ name = %[2]q
857
+ org_id = %[1]q
858
+ }
844
859
resource "mongodbatlas_alert_configuration" "test" {
845
- project_id = %[1]q
860
+ project_id = mongodbatlas_project.test.id
846
861
event_type = "NO_PRIMARY"
847
- enabled = "%[3 ]t"
862
+ enabled = "%[4 ]t"
848
863
849
864
notification {
850
865
type_name = "OPS_GENIE"
851
- ops_genie_api_key = %[2 ]q
866
+ ops_genie_api_key = %[3 ]q
852
867
ops_genie_region = "US"
853
868
delay_min = 0
854
869
}
855
870
}
856
- ` , projectID , apiKey , enabled )
871
+ ` , orgID , projectName , apiKey , enabled )
857
872
}
858
873
859
- func testAccMongoDBAtlasAlertConfigurationVictorOpsConfig (projectID , apiKey string , enabled bool ) string {
874
+ func testAccMongoDBAtlasAlertConfigurationVictorOpsConfig (orgID , projectName , apiKey string , enabled bool ) string {
860
875
return fmt .Sprintf (`
876
+ resource "mongodbatlas_project" "test" {
877
+ name = %[2]q
878
+ org_id = %[1]q
879
+ }
861
880
resource "mongodbatlas_alert_configuration" "test" {
862
- project_id = %[1]q
881
+ project_id = mongodbatlas_project.test.id
863
882
event_type = "NO_PRIMARY"
864
- enabled = "%[3 ]t"
883
+ enabled = "%[4 ]t"
865
884
866
885
notification {
867
886
type_name = "VICTOR_OPS"
868
- victor_ops_api_key = %[2 ]q
887
+ victor_ops_api_key = %[3 ]q
869
888
victor_ops_routing_key = "testing"
870
889
delay_min = 0
871
890
}
872
891
}
873
- ` , projectID , apiKey , enabled )
892
+ ` , orgID , projectName , apiKey , enabled )
874
893
}
875
894
876
895
func testAccMongoDBAtlasAlertConfigurationConfigEmptyMetricThresholdConfig (orgID , projectName string , enabled bool ) string {
0 commit comments