From 9d341b0d85b1a9704782818d0189004408cd6bf9 Mon Sep 17 00:00:00 2001 From: Espen Albert Date: Wed, 4 Dec 2024 10:37:17 +0000 Subject: [PATCH] chore: Implements extra API Calls for AdvancedCluster TPF (#2852) * chore: Add support for ExtraAPIInfo in TFModel to find replication_specs.*.container_id * feat: Initial /tenantUpgrade logic * refactor: Fix zoneName default for legacy schema * address PR comments part 1 * use explicit code instead of comments Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> * chore: remove comments and fix suggested change commit * chore: remove comment * address PR comments 2 * test: hard code extra container response --------- Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com> --- internal/common/constant/cloud_provider.go | 7 +- .../model_ClusterDescription20240805.go | 24 ++- .../model_to_ClusterDescription20240805.go | 13 +- .../service/advancedclustertpf/move_state.go | 2 +- .../service/advancedclustertpf/resource.go | 52 +++-- .../resource_compatibility_reuse.go | 47 +++++ .../resource_compatiblity.go | 3 +- .../advancedclustertpf/resource_schema.go | 14 +- .../advancedclustertpf/resource_test.go | 68 +------ .../advancedclustertpf/resource_unit_test.go | 32 +-- .../advancedclustertpf/resource_upgrade.go | 27 +++ ...usterConfig_symmetricShardedOldSchema.yaml | 4 +- ...kClusterAdvancedCluster_tenantUpgrade.yaml | 186 ++++++++++++++++++ ..._groups_{groupId}_clusters_2024-10-23.json | 23 +++ ..._{groupId}_clusters_2024-10-23_manual.json | 22 +++ ...Id}_clusters_tenantUpgrade_2023-01-01.json | 8 + ...Id}_clusters_{clusterName}_2023-02-01.json | 0 internal/testutil/tc/advanced_cluster.go | 123 ++++++++++++ 18 files changed, 539 insertions(+), 116 deletions(-) create mode 100644 internal/service/advancedclustertpf/resource_upgrade.go create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json create mode 100644 internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json diff --git a/internal/common/constant/cloud_provider.go b/internal/common/constant/cloud_provider.go index f77b0ff731..edc8a01fff 100644 --- a/internal/common/constant/cloud_provider.go +++ b/internal/common/constant/cloud_provider.go @@ -1,7 +1,8 @@ package constant const ( - AWS = "AWS" - AZURE = "AZURE" - GCP = "GCP" + AWS = "AWS" + AZURE = "AZURE" + GCP = "GCP" + TENANT = "TENANT" ) diff --git a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go index 8b0b730d4b..92b24c27e3 100644 --- a/internal/service/advancedclustertpf/model_ClusterDescription20240805.go +++ b/internal/service/advancedclustertpf/model_ClusterDescription20240805.go @@ -25,11 +25,15 @@ type LegacySchemaInfo struct { RootDiskSize *float64 } -func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, timeout timeouts.Value, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo) *TFModel { +type ExtraAPIInfo struct { + ContainerIDs map[string]string +} + +func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, timeout timeouts.Value, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo, apiInfo ExtraAPIInfo) *TFModel { biConnector := NewBiConnectorConfigObjType(ctx, input.BiConnector, diags) connectionStrings := NewConnectionStringsObjType(ctx, input.ConnectionStrings, diags) labels := NewLabelsObjType(ctx, input.Labels, diags) - replicationSpecs := NewReplicationSpecsObjType(ctx, input.ReplicationSpecs, diags, legacyInfo) + replicationSpecs := NewReplicationSpecsObjType(ctx, input.ReplicationSpecs, diags, legacyInfo, apiInfo) tags := NewTagsObjType(ctx, input.Tags, diags) if diags.HasError() { return nil @@ -112,15 +116,15 @@ func NewLabelsObjType(ctx context.Context, input *[]admin.ComponentLabel, diags return setType } -func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo) types.List { +func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo, apiInfo ExtraAPIInfo) types.List { if input == nil { return types.ListNull(ReplicationSpecsObjType) } var tfModels *[]TFReplicationSpecsModel if legacyInfo == nil { - tfModels = convertReplicationSpecs(ctx, input, diags) + tfModels = convertReplicationSpecs(ctx, input, diags, apiInfo) } else { - tfModels = convertReplicationSpecsLegacy(ctx, input, diags, legacyInfo) + tfModels = convertReplicationSpecsLegacy(ctx, input, diags, legacyInfo, apiInfo) } if diags.HasError() { return types.ListNull(ReplicationSpecsObjType) @@ -130,15 +134,15 @@ func NewReplicationSpecsObjType(ctx context.Context, input *[]admin.ReplicationS return listType } -func convertReplicationSpecs(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics) *[]TFReplicationSpecsModel { +func convertReplicationSpecs(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, apiInfo ExtraAPIInfo) *[]TFReplicationSpecsModel { tfModels := make([]TFReplicationSpecsModel, len(*input)) for i, item := range *input { regionConfigs := NewRegionConfigsObjType(ctx, item.RegionConfigs, diags) tfModels[i] = TFReplicationSpecsModel{ Id: types.StringPointerValue(item.Id), ExternalId: types.StringPointerValue(item.Id), - NumShards: types.Int64Value(1), // TODO: Static - ContainerId: conversion.ToTFMapOfString(ctx, diags, nil), // TODO: Static + NumShards: types.Int64Value(1), // TODO: Static + ContainerId: conversion.ToTFMapOfString(ctx, diags, &apiInfo.ContainerIDs), RegionConfigs: regionConfigs, ZoneId: types.StringPointerValue(item.ZoneId), ZoneName: types.StringPointerValue(item.ZoneName), @@ -147,7 +151,7 @@ func convertReplicationSpecs(ctx context.Context, input *[]admin.ReplicationSpec return &tfModels } -func convertReplicationSpecsLegacy(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo) *[]TFReplicationSpecsModel { +func convertReplicationSpecsLegacy(ctx context.Context, input *[]admin.ReplicationSpec20240805, diags *diag.Diagnostics, legacyInfo *LegacySchemaInfo, apiInfo ExtraAPIInfo) *[]TFReplicationSpecsModel { tfModels := []TFReplicationSpecsModel{} tfModelsSkipIndexes := []int{} for i, item := range *input { @@ -179,7 +183,7 @@ func convertReplicationSpecsLegacy(ctx context.Context, input *[]admin.Replicati } } tfModels = append(tfModels, TFReplicationSpecsModel{ - ContainerId: conversion.ToTFMapOfString(ctx, diags, nil), // TODO: Static + ContainerId: conversion.ToTFMapOfString(ctx, diags, &apiInfo.ContainerIDs), ExternalId: types.StringPointerValue(item.Id), Id: types.StringValue(legacyID), RegionConfigs: regionConfigs, diff --git a/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go index 2916eccb1d..1f235e6707 100644 --- a/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go +++ b/internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go @@ -11,6 +11,8 @@ import ( "go.mongodb.org/atlas-sdk/v20241113001/admin" ) +const defaultZoneName = "ZoneName managed by Terraform" + func NewAtlasReq(ctx context.Context, input *TFModel, diags *diag.Diagnostics) *admin.ClusterDescription20240805 { acceptDataRisksAndForceReplicaSetReconfig, ok := conversion.StringPtrToTimePtr(input.AcceptDataRisksAndForceReplicaSetReconfig.ValueStringPointer()) if !ok { @@ -93,11 +95,20 @@ func newReplicationSpec20240805(ctx context.Context, input types.List, diags *di Id: conversion.NilForUnknown(item.Id, item.Id.ValueStringPointer()), ZoneId: conversion.NilForUnknown(item.ZoneId, item.ZoneId.ValueStringPointer()), RegionConfigs: newCloudRegionConfig20240805(ctx, item.RegionConfigs, diags), - ZoneName: item.ZoneName.ValueStringPointer(), + ZoneName: conversion.StringPtr(resolveZoneNameOrUseDefault(item)), } } return &resp } + +func resolveZoneNameOrUseDefault(item *TFReplicationSpecsModel) string { + zoneName := conversion.NilForUnknown(item.ZoneName, item.ZoneName.ValueStringPointer()) + if zoneName == nil { + return defaultZoneName + } + return *zoneName +} + func newResourceTag(ctx context.Context, input types.Set, diags *diag.Diagnostics) *[]admin.ResourceTag { if input.IsUnknown() || input.IsNull() { return nil diff --git a/internal/service/advancedclustertpf/move_state.go b/internal/service/advancedclustertpf/move_state.go index dab7886bfb..cf2afeaba9 100644 --- a/internal/service/advancedclustertpf/move_state.go +++ b/internal/service/advancedclustertpf/move_state.go @@ -73,7 +73,7 @@ func setMoveStateResponse(ctx context.Context, projectID, clusterName string, re model := NewTFModel(ctx, &admin.ClusterDescription20240805{ GroupId: conversion.StringPtr(projectID), Name: conversion.StringPtr(clusterName), - }, validTimeout, &resp.Diagnostics, nil) + }, validTimeout, &resp.Diagnostics, nil, ExtraAPIInfo{}) if resp.Diagnostics.HasError() { return } diff --git a/internal/service/advancedclustertpf/resource.go b/internal/service/advancedclustertpf/resource.go index 23d899a377..f88fad9b14 100644 --- a/internal/service/advancedclustertpf/resource.go +++ b/internal/service/advancedclustertpf/resource.go @@ -101,7 +101,24 @@ func (r *rs) Update(ctx context.Context, req resource.UpdateRequest, resp *resou if diags.HasError() { return } - cluster := r.applyClusterChanges(ctx, diags, &state, &plan) + stateReq := normalizeFromTFModel(ctx, &state, diags, false) + planReq := normalizeFromTFModel(ctx, &plan, diags, false) + if diags.HasError() { + return + } + normalizePatchState(stateReq) + patchReq, err := update.PatchPayload(stateReq, planReq) + if err != nil { + diags.AddError("errorPatchPayload", err.Error()) + return + } + upgradeRequest := getTenantUpgradeRequest(stateReq, patchReq) + var cluster *admin.ClusterDescription20240805 + if upgradeRequest != nil { + cluster = r.applyTenantUpgrade(ctx, &plan, upgradeRequest, diags) + } else { + cluster = r.applyClusterChanges(ctx, diags, &state, &plan, patchReq) + } if diags.HasError() { return } @@ -233,18 +250,7 @@ func (r *rs) applyAdvancedConfigurationChanges(ctx context.Context, diags *diag. return legacyAdvConfig, advConfig } -func (r *rs) applyClusterChanges(ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel) *admin.ClusterDescription20240805 { - stateReq := normalizeFromTFModel(ctx, state, diags, false) - planReq := normalizeFromTFModel(ctx, plan, diags, false) - if diags.HasError() { - return nil - } - normalizePatchState(stateReq) - patchReq, err := update.PatchPayload(stateReq, planReq) - if err != nil { - diags.AddError("errorPatchPayload", err.Error()) - return nil - } +func (r *rs) applyClusterChanges(ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel, patchReq *admin.ClusterDescription20240805) *admin.ClusterDescription20240805 { var cluster *admin.ClusterDescription20240805 if usingLegacySchema(ctx, plan.ReplicationSpecs, diags) { // Only updates of replication specs will be done with legacy API @@ -344,6 +350,19 @@ func (r *rs) updateAndWaitLegacy(ctx context.Context, patchReq *admin20240805.Cl return AwaitChanges(ctx, r.Client.AtlasV2.ClustersApi, &tfModel.Timeouts, diags, projectID, clusterName, changeReasonUpdate) } +func (r *rs) applyTenantUpgrade(ctx context.Context, plan *TFModel, upgradeRequest *admin.LegacyAtlasTenantClusterUpgradeRequest, diags *diag.Diagnostics) *admin.ClusterDescription20240805 { + api := r.Client.AtlasV2.ClustersApi + projectID := plan.ProjectID.ValueString() + clusterName := plan.Name.ValueString() + upgradeRequest.Name = clusterName + _, _, err := api.UpgradeSharedCluster(ctx, projectID, upgradeRequest).Execute() + if err != nil { + diags.AddError("errorTenantUpgrade", fmt.Sprintf(errorUpdate, clusterName, err.Error())) + return nil + } + return AwaitChanges(ctx, api, &plan.Timeouts, diags, projectID, clusterName, changeReasonUpdate) +} + func (r *rs) convertClusterAddAdvConfig(ctx context.Context, legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs, advConfig *admin.ClusterDescriptionProcessArgs20240805, cluster *admin.ClusterDescription20240805, modelIn *TFModel, diags *diag.Diagnostics) *TFModel { api := r.Client.AtlasV2.ClustersApi api20240530 := r.Client.AtlasV220240530.ClustersApi @@ -365,7 +384,12 @@ func (r *rs) convertClusterAddAdvConfig(ctx context.Context, legacyAdvConfig *ad } } legacyInfo := resolveLegacyInfo(ctx, modelIn, diags, cluster, api20240530) - modelOut := NewTFModel(ctx, cluster, modelIn.Timeouts, diags, legacyInfo) + apiInfo, err := resolveExtraAPIInfo(ctx, projectID, cluster, r.Client.AtlasV2.NetworkPeeringApi) + if err != nil { + diags.AddError("errorExtraApiInfo", err.Error()) + return nil + } + modelOut := NewTFModel(ctx, cluster, modelIn.Timeouts, diags, legacyInfo, *apiInfo) if diags.HasError() { return nil } diff --git a/internal/service/advancedclustertpf/resource_compatibility_reuse.go b/internal/service/advancedclustertpf/resource_compatibility_reuse.go index 0f0bb3c172..f80a0bb459 100644 --- a/internal/service/advancedclustertpf/resource_compatibility_reuse.go +++ b/internal/service/advancedclustertpf/resource_compatibility_reuse.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/spf13/cast" admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin" "go.mongodb.org/atlas-sdk/v20241113001/admin" @@ -17,6 +18,52 @@ func FormatMongoDBMajorVersion(version string) string { return fmt.Sprintf("%.1f", cast.ToFloat32(version)) } +// based on flattenAdvancedReplicationSpecRegionConfigs in model_advanced_cluster.go +func resolveExtraAPIInfo(ctx context.Context, projectID string, cluster *admin.ClusterDescription20240805, api admin.NetworkPeeringApi) (*ExtraAPIInfo, error) { + containerIDs := map[string]string{} + for _, spec := range cluster.GetReplicationSpecs() { + for _, regionConfig := range spec.GetRegionConfigs() { + providerName := regionConfig.GetProviderName() + if providerName == constant.TENANT { + continue + } + params := &admin.ListPeeringContainerByCloudProviderApiParams{ + GroupId: projectID, + ProviderName: &providerName, + } + containerIDKey := fmt.Sprintf("%s:%s", providerName, regionConfig.GetRegionName()) + if _, ok := containerIDs[containerIDKey]; ok { + continue + } + containers, _, err := api.ListPeeringContainerByCloudProviderWithParams(ctx, params).Execute() + if err != nil { + return nil, err + } + if results := getAdvancedClusterContainerID(containers.GetResults(), ®ionConfig); results != "" { + containerIDs[containerIDKey] = results + } else { + return nil, fmt.Errorf("container id not found for %s", containerIDKey) + } + } + } + return &ExtraAPIInfo{ + ContainerIDs: containerIDs, + }, nil +} + +// copied from model_advanced_cluster.go +func getAdvancedClusterContainerID(containers []admin.CloudProviderContainer, cluster *admin.CloudRegionConfig20240805) string { + for i, container := range containers { + gpc := cluster.GetProviderName() == constant.GCP + azure := container.GetProviderName() == cluster.GetProviderName() && container.GetRegion() == cluster.GetRegionName() + aws := container.GetRegionName() == cluster.GetRegionName() + if gpc || azure || aws { + return containers[i].GetId() + } + } + return "" +} + func getReplicationSpecIDsFromOldAPI(ctx context.Context, projectID, clusterName string, api admin20240530.ClustersApi) (map[string]string, error) { clusterOldAPI, _, err := api.GetCluster(ctx, projectID, clusterName).Execute() if err != nil { diff --git a/internal/service/advancedclustertpf/resource_compatiblity.go b/internal/service/advancedclustertpf/resource_compatiblity.go index 5478180970..a1ffd8ad21 100644 --- a/internal/service/advancedclustertpf/resource_compatiblity.go +++ b/internal/service/advancedclustertpf/resource_compatiblity.go @@ -161,7 +161,8 @@ func numShardsMap(ctx context.Context, input types.List, diags *diag.Diagnostics counts := map[string]int64{} for i := range elements { e := elements[i] - counts[e.ZoneName.ValueString()] = e.NumShards.ValueInt64() + zoneName := resolveZoneNameOrUseDefault(&e) + counts[zoneName] = e.NumShards.ValueInt64() } return counts } diff --git a/internal/service/advancedclustertpf/resource_schema.go b/internal/service/advancedclustertpf/resource_schema.go index d180f78ff2..55d1753dc4 100644 --- a/internal/service/advancedclustertpf/resource_schema.go +++ b/internal/service/advancedclustertpf/resource_schema.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/setdefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/schemafunc" @@ -128,10 +127,7 @@ func ResourceSchema(ctx context.Context) schema.Schema { }, }, "create_date": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, + Computed: true, MarkdownDescription: "Date and time when MongoDB Cloud created this cluster. This parameter expresses its value in ISO 8601 format in UTC.", }, "encryption_at_rest_provider": schema.StringAttribute{ @@ -149,10 +145,7 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.", }, "cluster_id": schema.StringAttribute{ // TODO: was generated as id - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, + Computed: true, MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the cluster.", }, "labels": schema.SetNestedAttribute{ @@ -276,9 +269,8 @@ func ResourceSchema(ctx context.Context) schema.Schema { MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the zone in a Global Cluster. This value can be used to configure Global Cluster backup policies.", }, "zone_name": schema.StringAttribute{ - Computed: true, // must be computed to have a Default + Computed: true, Optional: true, - Default: stringdefault.StaticString("ZoneName managed by Terraform"), // TODO: as in current resource MarkdownDescription: "Human-readable label that describes the zone this shard belongs to in a Global Cluster. Provide this value only if \"clusterType\" : \"GEOSHARDED\" but not \"selfManagedSharding\" : true.", }, }, diff --git a/internal/service/advancedclustertpf/resource_test.go b/internal/service/advancedclustertpf/resource_test.go index e5ad2198f4..efe29be364 100644 --- a/internal/service/advancedclustertpf/resource_test.go +++ b/internal/service/advancedclustertpf/resource_test.go @@ -1,7 +1,6 @@ package advancedclustertpf_test import ( - "fmt" "os" "testing" @@ -20,66 +19,10 @@ func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) { clusterName = acc.RandomClusterName() clusterNameUpdated = acc.RandomClusterName() ) - testCase := basicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) + testCase := tc.BasicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) resource.ParallelTest(t, *testCase) } -func basicTenantTestCase(t *testing.T, projectID, clusterName, clusterNameUpdated string) *resource.TestCase { - t.Helper() - return &resource.TestCase{ - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: acc.CheckDestroyCluster, - PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), - Steps: []resource.TestStep{ - { - Config: configTenant(projectID, clusterName), - Check: checkTenant(projectID, clusterName), - }, - { - Config: configTenant(projectID, clusterNameUpdated), - Check: checkTenant(projectID, clusterNameUpdated), - }, - acc.TestStepImportCluster(resourceName), - }, - } -} - -func configTenant(projectID, name string) string { - return fmt.Sprintf(` - resource "mongodbatlas_advanced_cluster" "test" { - project_id = %[1]q - name = %[2]q - cluster_type = "REPLICASET" - - replication_specs = [{ - region_configs = [{ - electable_specs = { - instance_size = "M5" - } - provider_name = "TENANT" - backing_provider_name = "AWS" - region_name = "US_EAST_1" - priority = 7 - }] - }] - } - `, projectID, name) -} - -func checkTenant(projectID, name string) resource.TestCheckFunc { - attrsSet := []string{"replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"} - attrsMap := map[string]string{ - "project_id": projectID, - "name": name, - "termination_protection_enabled": "false", - "global_cluster_self_managed_sharding": "false", - "labels.#": "0", - } - checks := acc.AddAttrSetChecks(resourceName, nil, attrsSet...) - checks = acc.AddAttrChecks(resourceName, checks, attrsMap) - return resource.ComposeAggregateTestCheckFunc(checks...) -} - func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T) { var ( orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") @@ -99,3 +42,12 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) testCase := tc.SymmetricShardedOldSchema(t, orgID, projectName, clusterName) resource.ParallelTest(t, *testCase) } + +func TestAccClusterAdvancedCluster_tenantUpgrade(t *testing.T) { + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + ) + testCase := tc.TenantUpgrade(t, projectID, clusterName) + resource.ParallelTest(t, *testCase) +} diff --git a/internal/service/advancedclustertpf/resource_unit_test.go b/internal/service/advancedclustertpf/resource_unit_test.go index 73b7372bf8..1262703407 100644 --- a/internal/service/advancedclustertpf/resource_unit_test.go +++ b/internal/service/advancedclustertpf/resource_unit_test.go @@ -78,6 +78,7 @@ func TestMockAdvancedCluster_replicaset(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "state_name", "IDLE"), resource.TestCheckResourceAttr(resourceName, "timeouts.create", "20s"), + resource.TestCheckResourceAttr(resourceName, "replication_specs.0.container_id.AWS:US_EAST_1", "67345bd9905b8c30c54fd220"), ), }, { @@ -111,13 +112,7 @@ func TestMockAdvancedCluster_replicaset(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "advanced_configuration.change_stream_options_pre_and_post_images_expire_after_seconds", "100"), ), }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateIDFuncProjectIDClusterName(resourceName, "project_id", "name"), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "name", - }, + acc.TestStepImportCluster(resourceName), }, } unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, &testCase) @@ -149,13 +144,7 @@ func TestMockAdvancedCluster_configSharded(t *testing.T) { Config: configSharded(projectID, clusterName, true), Check: resource.TestCheckResourceAttr(resourceName, "name", clusterName), }, - { - ResourceName: resourceName, - ImportStateIdFunc: acc.ImportStateIDFuncProjectIDClusterName(resourceName, "project_id", "name"), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIdentifierAttribute: "name", - }, + acc.TestStepImportCluster(resourceName), }, } unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, &testCase) @@ -233,7 +222,7 @@ func TestMockClusterAdvancedCluster_basicTenant(t *testing.T) { } ) shortenRetries() - testCase := basicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) + testCase := tc.BasicTenantTestCase(t, projectID, clusterName, clusterNameUpdated) unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) } @@ -266,3 +255,16 @@ func TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T testCase := tc.SymmetricShardedOldSchema(t, orgID, projectName, clusterName) unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) } + +func TestMockClusterAdvancedCluster_tenantUpgrade(t *testing.T) { + var ( + clusterName = "test-acc-tf-c-878317177498266511" + vars = map[string]string{ + "groupId": projectID, + "clusterName": clusterName, + } + ) + shortenRetries() + testCase := tc.TenantUpgrade(t, projectID, clusterName) + unit.MockTestCaseAndRun(t, vars, &unit.MockHTTPDataConfig{AllowMissingRequests: true, AllowReReadGet: true}, testCase) +} diff --git a/internal/service/advancedclustertpf/resource_upgrade.go b/internal/service/advancedclustertpf/resource_upgrade.go new file mode 100644 index 0000000000..44552dd5a8 --- /dev/null +++ b/internal/service/advancedclustertpf/resource_upgrade.go @@ -0,0 +1,27 @@ +package advancedclustertpf + +import ( + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" + "go.mongodb.org/atlas-sdk/v20241113001/admin" +) + +func getTenantUpgradeRequest(state, patch *admin.ClusterDescription20240805) *admin.LegacyAtlasTenantClusterUpgradeRequest { + if patch.ReplicationSpecs == nil { + return nil + } + oldRegion := state.GetReplicationSpecs()[0].GetRegionConfigs()[0] + oldProviderName := oldRegion.GetProviderName() + newRegion := patch.GetReplicationSpecs()[0].GetRegionConfigs()[0] + newProviderName := newRegion.GetProviderName() + if oldProviderName != constant.TENANT || newProviderName == constant.TENANT { + return nil + } + return &admin.LegacyAtlasTenantClusterUpgradeRequest{ + Name: state.GetName(), + ProviderSettings: &admin.ClusterProviderSettings{ + ProviderName: newProviderName, + RegionName: newRegion.RegionName, + InstanceSizeName: newRegion.GetElectableSpecs().InstanceSize, + }, + } +} diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml index c993e1357b..cd38497596 100644 --- a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedClusterConfig_symmetricShardedOldSchema.yaml @@ -289,11 +289,11 @@ steps: responses: - response_index: 88 status: 200 - text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }\n ],\n \"totalCount\": 1\n}" + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }, {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 2\n}" duplicate_responses: 8 - response_index: 89 status: 200 - text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 1\n}" + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AZURE&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"6746cefbaef48d1cb2658bbc\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"EU_WEST_1\",\n \"vpcId\": \"vpc-0dd32328690ba0813\"\n }, {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"azureSubscriptionId\": \"591236d43d098d433845860f\",\n \"id\": \"6746cefbaef48d1cb2658bbb\",\n \"providerName\": \"AZURE\",\n \"provisioned\": true,\n \"region\": \"US_EAST_2\",\n \"vnetName\": \"vnet_6746cefbaef48d1cb2658bbb_ykngkrlx\"\n }\n ],\n \"totalCount\": 2\n}" duplicate_responses: 8 - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs method: GET diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml new file mode 100644 index 0000000000..39fd92c8c8 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade.yaml @@ -0,0 +1,186 @@ +step_count: 2 +steps: +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters + method: POST + version: '2024-10-23' + text: "{\n \"clusterType\": \"REPLICASET\",\n \"labels\": [],\n \"name\": \"{clusterName}\",\n \"replicationSpecs\": [\n {\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"instanceSize\": \"M5\",\n \"nodeCount\": 0\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"tags\": []\n}" + responses: + - response_index: 0 + status: 201 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"CREATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 1 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 8 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 3 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 4 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 4 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 6 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 5 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 7 + - response_index: 8 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 6 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters?includeCount=true&includeDeletedWithRetainedBackups=false&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n }\n ],\n \"totalCount\": 1\n}" + duplicate_responses: 2 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 9 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" +- diff_requests: + - path: /api/atlas/v2/groups/{groupId}/clusters/tenantUpgrade + method: POST + version: '2023-01-01' + text: "{\n \"name\": \"{clusterName}\",\n \"providerSettings\": {\n \"instanceSizeName\": \"M10\",\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n}" + responses: + - response_index: 39 + status: 200 + text: "{\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGBEnabled\": false\n },\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"mongoURI\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017\",\n \"mongoURIUpdated\": \"2024-12-03T16:54:43Z\",\n \"mongoURIWithOptions\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"name\": \"{clusterName}\",\n \"numShards\": 1,\n \"paused\": false,\n \"pitEnabled\": false,\n \"providerBackupEnabled\": false,\n \"providerSettings\": {\n \"autoScaling\": {\n \"compute\": {\n \"maxInstanceSize\": null,\n \"minInstanceSize\": null\n }\n },\n \"backingProviderName\": \"AWS\",\n \"effectiveInstanceSizeName\": \"M5\",\n \"instanceSizeName\": \"M5\",\n \"nextBackupDate\": \"2024-12-04T16:54:26Z\",\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\",\n \"tenantBackupEnabled\": true\n },\n \"replicationFactor\": 3,\n \"replicationSpec\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionsConfig\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"srvAddress\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 76 + status: 202 + text: '{}' + request_responses: + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 35 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b42\",\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"diskSizeGB\": 5.0,\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 40 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {},\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 26 + - response_index: 67 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 1 + - response_index: 69 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 2 + - response_index: 77 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"featureCompatibilityVersion\": \"8.0\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"redactClientLogData\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e83\",\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"diskSizeGB\": 10.0,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"DELETING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + duplicate_responses: 6 + - response_index: 84 + status: 404 + text: "{\n \"detail\": \"No cluster named {clusterName} exists in group {groupId}.\",\n \"error\": 404,\n \"errorCode\": \"CLUSTER_NOT_FOUND\",\n \"parameters\": [\n \"{clusterName}\",\n \"{groupId}\"\n ],\n \"reason\": \"Not Found\"\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: GET + version: '2023-02-01' + text: '' + responses: + - response_index: 36 + status: 200 + text: "{\n \"backupEnabled\": true,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"backingProviderName\": \"AWS\",\n \"electableSpecs\": {\n \"effectiveInstanceSize\": \"M5\",\n \"instanceSize\": \"M5\"\n },\n \"priority\": 7,\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f37c288864967c85f6b40\",\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - response_index: 71 + status: 200 + text: "{\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:57:44Z\",\n \"diskSizeGB\": 10.0,\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f388843ca6e2ab9803e84\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"name\": \"{clusterName}\",\n \"paused\": false,\n \"pitEnabled\": false,\n \"replicationSpecs\": [\n {\n \"id\": \"674f388843ca6e2ab9803e79\",\n \"numShards\": 1,\n \"regionConfigs\": [\n {\n \"analyticsSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGB\": {\n \"enabled\": true\n }\n },\n \"electableSpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 3\n },\n \"priority\": 7,\n \"providerName\": \"AWS\",\n \"readOnlySpecs\": {\n \"diskIOPS\": 3000,\n \"ebsVolumeType\": \"STANDARD\",\n \"instanceSize\": \"M10\",\n \"nodeCount\": 0\n },\n \"regionName\": \"US_EAST_1\"\n }\n ],\n \"zoneId\": \"674f388843ca6e2ab9803e82\",\n \"zoneName\": \"Zone 1\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"stateName\": \"IDLE\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 37 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultReadConcern\": null,\n \"defaultWriteConcern\": null,\n \"failIndexKeyTooLong\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/processArgs + method: GET + version: '2024-08-05' + text: '' + responses: + - response_index: 38 + status: 200 + text: "{\n \"changeStreamOptionsPreAndPostImagesExpireAfterSeconds\": null,\n \"chunkMigrationConcurrency\": null,\n \"customOpensslCipherConfigTls12\": [],\n \"defaultMaxTimeMS\": null,\n \"defaultWriteConcern\": null,\n \"javascriptEnabled\": true,\n \"minimumEnabledTlsProtocol\": \"TLS1_2\",\n \"noTableScan\": false,\n \"oplogMinRetentionHours\": null,\n \"oplogSizeMB\": null,\n \"queryStatsLogVerbosity\": 1,\n \"sampleRefreshIntervalBIConnector\": null,\n \"sampleSizeBIConnector\": null,\n \"tlsCipherConfigMode\": \"DEFAULT\",\n \"transactionLifetimeLimitSeconds\": null\n}" + duplicate_responses: 1 + - path: /api/atlas/v2/groups/{groupId}/clusters/tenantUpgrade + method: POST + version: '2023-01-01' + text: "{\n \"name\": \"{clusterName}\",\n \"providerSettings\": {\n \"instanceSizeName\": \"M10\",\n \"providerName\": \"AWS\",\n \"regionName\": \"US_EAST_1\"\n }\n}" + responses: + - response_index: 39 + status: 200 + text: "{\n \"autoScaling\": {\n \"compute\": {\n \"enabled\": false,\n \"scaleDownEnabled\": false\n },\n \"diskGBEnabled\": false\n },\n \"backupEnabled\": false,\n \"biConnector\": {\n \"enabled\": false,\n \"readPreference\": \"secondary\"\n },\n \"clusterType\": \"REPLICASET\",\n \"connectionStrings\": {\n \"standard\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"standardSrv\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\"\n },\n \"createDate\": \"2024-12-03T16:54:26Z\",\n \"diskSizeGB\": 5.0,\n \"diskWarmingMode\": \"FULLY_WARMED\",\n \"encryptionAtRestProvider\": \"NONE\",\n \"globalClusterSelfManagedSharding\": false,\n \"groupId\": \"{groupId}\",\n \"id\": \"674f37c288864967c85f6b47\",\n \"labels\": [],\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/restoreJobs\",\n \"rel\": \"https://cloud.mongodb.com/restoreJobs\"\n },\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/snapshots\",\n \"rel\": \"https://cloud.mongodb.com/snapshots\"\n }\n ],\n \"mongoDBMajorVersion\": \"8.0\",\n \"mongoDBVersion\": \"8.0.3\",\n \"mongoURI\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017\",\n \"mongoURIUpdated\": \"2024-12-03T16:54:43Z\",\n \"mongoURIWithOptions\": \"mongodb://ac-ks9snsv-shard-00-00.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-01.jsgqjpo.mongodb-dev.net:27017,ac-ks9snsv-shard-00-02.jsgqjpo.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-bm8qep-shard-0\",\n \"name\": \"{clusterName}\",\n \"numShards\": 1,\n \"paused\": false,\n \"pitEnabled\": false,\n \"providerBackupEnabled\": false,\n \"providerSettings\": {\n \"autoScaling\": {\n \"compute\": {\n \"maxInstanceSize\": null,\n \"minInstanceSize\": null\n }\n },\n \"backingProviderName\": \"AWS\",\n \"effectiveInstanceSizeName\": \"M5\",\n \"instanceSizeName\": \"M5\",\n \"nextBackupDate\": \"2024-12-04T16:54:26Z\",\n \"providerName\": \"TENANT\",\n \"regionName\": \"US_EAST_1\",\n \"tenantBackupEnabled\": true\n },\n \"replicationFactor\": 3,\n \"replicationSpec\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"replicationSpecs\": [\n {\n \"id\": \"674f37c288864967c85f6b41\",\n \"numShards\": 1,\n \"regionsConfig\": {\n \"US_EAST_1\": {\n \"analyticsNodes\": 0,\n \"electableNodes\": 3,\n \"priority\": 7,\n \"readOnlyNodes\": 0\n }\n },\n \"zoneName\": \"ZoneName managed by Terraform\"\n }\n ],\n \"rootCertType\": \"ISRGROOTX1\",\n \"srvAddress\": \"mongodb+srv://test-acc-tf-c-878317177.jsgqjpo.mongodb-dev.net\",\n \"stateName\": \"UPDATING\",\n \"tags\": [],\n \"terminationProtectionEnabled\": false,\n \"versionReleaseSystem\": \"LTS\"\n}" + - path: /api/atlas/v2/groups/{groupId}/containers + method: GET + version: '2023-01-01' + text: '' + responses: + - response_index: 72 + status: 200 + text: "{\n \"links\": [\n {\n \"href\": \"https://cloud-dev.mongodb.com/api/atlas/v2/groups/{groupId}/containers?includeCount=true&providerName=AWS&pageNum=1&itemsPerPage=100\",\n \"rel\": \"self\"\n }\n ],\n \"results\": [\n {\n \"atlasCidrBlock\": \"192.168.248.0/21\",\n \"id\": \"674f388843ca6e2ab9803e89\",\n \"providerName\": \"AWS\",\n \"provisioned\": true,\n \"regionName\": \"US_EAST_1\",\n \"vpcId\": \"vpc-0a59ad5152645bea7\"\n }\n ],\n \"totalCount\": 1\n}" + - path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName} + method: DELETE + version: '2023-02-01' + text: '' + responses: + - response_index: 76 + status: 202 + text: '{}' + - path: /api/atlas/v2/groups/{groupId} + method: DELETE + version: '2023-01-01' + text: '' + responses: + - response_index: 86 + status: 202 + text: '{}' +variables: + groupId: 674f37b888864967c85f6ad7 + clusterName: test-acc-tf-c-878317177498266511 diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json new file mode 100644 index 0000000000..6778b1311a --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23.json @@ -0,0 +1,23 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-878317177498266511", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5", + "nodeCount": 0 + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json new file mode 100644 index 0000000000..71905d7b89 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/01_01_POST__api_atlas_v2_groups_{groupId}_clusters_2024-10-23_manual.json @@ -0,0 +1,22 @@ +{ + "clusterType": "REPLICASET", + "labels": [], + "name": "test-acc-tf-c-878317177498266511", + "replicationSpecs": [ + { + "regionConfigs": [ + { + "backingProviderName": "AWS", + "electableSpecs": { + "instanceSize": "M5" + }, + "priority": 7, + "providerName": "TENANT", + "regionName": "US_EAST_1" + } + ], + "zoneName": "ZoneName managed by Terraform" + } + ], + "tags": [] +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json new file mode 100644 index 0000000000..a3ce19b271 --- /dev/null +++ b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_01_POST__api_atlas_v2_groups_{groupId}_clusters_tenantUpgrade_2023-01-01.json @@ -0,0 +1,8 @@ +{ + "name": "test-acc-tf-c-878317177498266511", + "providerSettings": { + "instanceSizeName": "M10", + "providerName": "AWS", + "regionName": "US_EAST_1" + } +} \ No newline at end of file diff --git a/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json b/internal/service/advancedclustertpf/testdata/TestMockClusterAdvancedCluster_tenantUpgrade/02_02_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/internal/testutil/tc/advanced_cluster.go b/internal/testutil/tc/advanced_cluster.go index 808cc4d49c..b95c4f9c75 100644 --- a/internal/testutil/tc/advanced_cluster.go +++ b/internal/testutil/tc/advanced_cluster.go @@ -3,9 +3,11 @@ package tc import ( "fmt" "strconv" + "strings" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" ) @@ -195,3 +197,124 @@ func checkShardedOldSchemaMultiCloud(name string, numShards int, analyticsSize s }, additionalChecks...) } + +func BasicTenantTestCase(t *testing.T, projectID, clusterName, clusterNameUpdated string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + Steps: []resource.TestStep{ + { + Config: configTenant(projectID, clusterName), + Check: checkTenant(projectID, clusterName), + }, + { + Config: configTenant(projectID, clusterNameUpdated), + Check: checkTenant(projectID, clusterNameUpdated), + }, + acc.TestStepImportCluster(resourceName), + }, + } +} + +func configTenant(projectID, name string) string { + return fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs = [{ + region_configs = [{ + electable_specs = { + instance_size = "M5" + } + provider_name = "TENANT" + backing_provider_name = "AWS" + region_name = "US_EAST_1" + priority = 7 + }] + }] + } + `, projectID, name) +} + +func checkTenant(projectID, name string) resource.TestCheckFunc { + attrsSet := []string{"replication_specs.#", "replication_specs.0.id", "replication_specs.0.region_configs.#"} + attrsMap := map[string]string{ + "project_id": projectID, + "name": name, + "termination_protection_enabled": "false", + "global_cluster_self_managed_sharding": "false", + "labels.#": "0", + } + checks := acc.AddAttrSetChecks(resourceName, nil, attrsSet...) + checks = acc.AddAttrChecks(resourceName, checks, attrsMap) + return resource.ComposeAggregateTestCheckFunc(checks...) +} + +func TenantUpgrade(t *testing.T, projectID, clusterName string) *resource.TestCase { + t.Helper() + return &resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: acc.ConvertAdvancedClusterToTPF(t, configTenant(projectID, clusterName)), + Check: checkTenant(projectID, clusterName), + }, + { + Config: acc.ConvertAdvancedClusterToTPF(t, configTenantUpgraded(projectID, clusterName)), + Check: checksTenantUpgraded(projectID, clusterName), + }, + }, + } +} + +func configTenantUpgraded(projectID, name string) string { + return fmt.Sprintf(` + resource "mongodbatlas_advanced_cluster" "test" { + project_id = %[1]q + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs { + region_configs { + priority = 7 + provider_name = "AWS" + region_name = "US_EAST_1" + electable_specs { + node_count = 3 + instance_size = "M10" + } + } + } + } + `, projectID, name) +} + +func enableChecksLatestTpf(checkMap map[string]string) map[string]string { + newMap := map[string]string{} + for k, v := range checkMap { + modifiedKey := strings.ReplaceAll(k, "electable_specs.0", "electable_specs") + newMap[modifiedKey] = v + } + return newMap +} + +func checksTenantUpgraded(projectID, name string) resource.TestCheckFunc { + originalChecks := checkTenant(projectID, name) + checks := []resource.TestCheckFunc{originalChecks} + checkMap := map[string]string{ + "replication_specs.0.region_configs.0.electable_specs.0.node_count": "3", + "replication_specs.0.region_configs.0.electable_specs.0.instance_size": "M10", + "replication_specs.0.region_configs.0.provider_name": "AWS", + } + if config.AdvancedClusterV2Schema() { + checkMap = enableChecksLatestTpf(checkMap) + } + checks = acc.AddAttrChecks(resourceName, checks, checkMap) + return resource.ComposeAggregateTestCheckFunc(originalChecks, resource.ComposeAggregateTestCheckFunc(checks...)) +}