Skip to content

Commit

Permalink
test: Fixes DUPLICATE_CLUSTER_NAME failures (#2424)
Browse files Browse the repository at this point in the history
* test: fix DUPLICATE_CLUSTER_NAME online_archive

* test: fix DUPLICATE_CLUSTER_NAME backup_snapshot_restore_job
  • Loading branch information
EspenAlbert authored Jul 16, 2024
1 parent 3f45cca commit f9a1809
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ const (
dataSourceName = "data.mongodbatlas_cloud_backup_snapshot_restore_job.test"
)

var clusterRequest = acc.ClusterRequest{
CloudBackup: true,
ReplicationSpecs: []acc.ReplicationSpecRequest{
{Region: "US_WEST_2"},
},
func clusterRequest() *acc.ClusterRequest {
return &acc.ClusterRequest{
CloudBackup: true,
ReplicationSpecs: []acc.ReplicationSpecRequest{
{Region: "US_WEST_2"},
},
}
}

func TestAccCloudBackupSnapshotRestoreJob_basic(t *testing.T) {
Expand All @@ -31,7 +33,7 @@ func TestAccCloudBackupSnapshotRestoreJob_basic(t *testing.T) {

func TestAccCloudBackupSnapshotRestoreJob_basicDownload(t *testing.T) {
var (
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterName = clusterInfo.ClusterName
description = fmt.Sprintf("My description in %s", clusterName)
retentionInDays = "1"
Expand Down Expand Up @@ -66,7 +68,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase {
var (
snapshotsDataSourceName = "data.mongodbatlas_cloud_backup_snapshot_restore_jobs.test"
snapshotsDataSourcePaginationName = "data.mongodbatlas_cloud_backup_snapshot_restore_jobs.pagination"
clusterInfo = acc.GetClusterInfo(tb, &clusterRequest)
clusterInfo = acc.GetClusterInfo(tb, clusterRequest())
clusterName = clusterInfo.ClusterName
description = fmt.Sprintf("My description in %s", clusterName)
retentionInDays = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestMigBackupRSOnlineArchiveWithNoChangeBetweenVersions(t *testing.T) {
var (
onlineArchiveResourceName = "mongodbatlas_online_archive.users_archive"
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterName = clusterInfo.ClusterName
projectID = clusterInfo.ProjectID
clusterTerraformStr = clusterInfo.ClusterTerraformStr
Expand Down
15 changes: 7 additions & 8 deletions internal/service/onlinearchive/resource_online_archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
)

var (
clusterRequest = acc.ClusterRequest{
func clusterRequest() *acc.ClusterRequest {
return &acc.ClusterRequest{
ReplicationSpecs: []acc.ReplicationSpecRequest{
// Must use US_EAST_1 in dev for online_archive to work
{AutoScalingDiskGbEnabled: true, Region: "US_EAST_1"},
Expand All @@ -23,14 +23,13 @@ var (
"ArchiveTest": "true", "Owner": "test",
},
}
)

}
func TestAccBackupRSOnlineArchive(t *testing.T) {
var (
onlineArchiveResourceName = "mongodbatlas_online_archive.users_archive"
onlineArchiveDataSourceName = "data.mongodbatlas_online_archive.read_archive"
onlineArchivesDataSourceName = "data.mongodbatlas_online_archives.all"
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterName = clusterInfo.ClusterName
projectID = clusterInfo.ProjectID
clusterTerraformStr = clusterInfo.ClusterTerraformStr
Expand Down Expand Up @@ -127,7 +126,7 @@ func TestAccBackupRSOnlineArchive(t *testing.T) {

func TestAccBackupRSOnlineArchiveBasic(t *testing.T) {
var (
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterResourceName = clusterInfo.ClusterResourceName
clusterName = clusterInfo.ClusterName
projectID = clusterInfo.ProjectID
Expand Down Expand Up @@ -175,7 +174,7 @@ func TestAccBackupRSOnlineArchiveWithProcessRegion(t *testing.T) {
var (
onlineArchiveResourceName = "mongodbatlas_online_archive.users_archive"
onlineArchiveDataSourceName = "data.mongodbatlas_online_archive.read_archive"
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterResourceName = clusterInfo.ClusterResourceName
clusterName = clusterInfo.ClusterName
projectID = clusterInfo.ProjectID
Expand Down Expand Up @@ -221,7 +220,7 @@ func TestAccBackupRSOnlineArchiveWithProcessRegion(t *testing.T) {

func TestAccBackupRSOnlineArchiveInvalidProcessRegion(t *testing.T) {
var (
clusterInfo = acc.GetClusterInfo(t, &clusterRequest)
clusterInfo = acc.GetClusterInfo(t, clusterRequest())
clusterTerraformStr = clusterInfo.ClusterTerraformStr
cloudProvider = "AWS"
clusterResourceName = clusterInfo.ClusterResourceName
Expand Down

0 comments on commit f9a1809

Please sign in to comment.