Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Moves disk_size_gb to replication spec for GetClusterInfo #2452

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ func TestAccBackupCompliancePolicy_overwriteBackupPolicies(t *testing.T) {
ProjectID: projectIDTerraform,
MongoDBMajorVersion: "6.0",
CloudBackup: true,
DiskSizeGb: 12,
RetainBackupsEnabled: true,
ReplicationSpecs: []acc.ReplicationSpecRequest{
{EbsVolumeType: "STANDARD", AutoScalingDiskGbEnabled: true, NodeCount: 3},
{EbsVolumeType: "STANDARD", AutoScalingDiskGbEnabled: true, NodeCount: 3, DiskSizeGb: 12},
},
}
clusterInfo = acc.GetClusterInfo(t, &req)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TestAccPrivateEndpointRegionalMode_conn(t *testing.T) {
providerName = "AWS"
region = os.Getenv("AWS_REGION_LOWERCASE")
privatelinkEndpointServiceResourceName = fmt.Sprintf("mongodbatlas_privatelink_endpoint_service.%s", endpointResourceSuffix)
spec1 = acc.ReplicationSpecRequest{Region: os.Getenv("AWS_REGION_UPPERCASE"), ProviderName: providerName, ZoneName: "Zone 1"}
spec2 = acc.ReplicationSpecRequest{Region: "US_WEST_2", ProviderName: providerName, ZoneName: "Zone 2"}
clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true, DiskSizeGb: 80, ReplicationSpecs: []acc.ReplicationSpecRequest{spec1, spec2}})
spec1 = acc.ReplicationSpecRequest{Region: os.Getenv("AWS_REGION_UPPERCASE"), ProviderName: providerName, ZoneName: "Zone 1", DiskSizeGb: 80}
spec2 = acc.ReplicationSpecRequest{Region: "US_WEST_2", ProviderName: providerName, ZoneName: "Zone 2", DiskSizeGb: 80}
clusterInfo = acc.GetClusterInfo(t, &acc.ClusterRequest{Geosharded: true, ReplicationSpecs: []acc.ReplicationSpecRequest{spec1, spec2}})
projectID = clusterInfo.ProjectID
clusterResourceName = clusterInfo.ResourceName
clusterDataName = "data.mongodbatlas_advanced_cluster.test"
Expand Down
25 changes: 15 additions & 10 deletions internal/testutil/acc/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type ClusterRequest struct {
ClusterName string
MongoDBMajorVersion string
ReplicationSpecs []ReplicationSpecRequest
DiskSizeGb int
CloudBackup bool
Geosharded bool
RetainBackupsEnabled bool
Expand Down Expand Up @@ -112,6 +111,7 @@ type ReplicationSpecRequest struct {
NodeCount int
NodeCountReadOnly int
Priority int
DiskSizeGb int
AutoScalingDiskGbEnabled bool
}

Expand Down Expand Up @@ -167,16 +167,21 @@ func cloudRegionConfig(req ReplicationSpecRequest) admin.CloudRegionConfig202501
InstanceSize: &req.InstanceSize,
}
}
electableSpec := admin.HardwareSpec20250101{
InstanceSize: &req.InstanceSize,
NodeCount: &req.NodeCount,
EbsVolumeType: conversion.StringPtr(req.EbsVolumeType),
}
if req.DiskSizeGb != 0 {
diskSizeGb := float64(req.DiskSizeGb)
electableSpec.DiskSizeGB = &diskSizeGb
}
return admin.CloudRegionConfig20250101{
RegionName: &req.Region,
Priority: &req.Priority,
ProviderName: &req.ProviderName,
ElectableSpecs: &admin.HardwareSpec20250101{
InstanceSize: &req.InstanceSize,
NodeCount: &req.NodeCount,
EbsVolumeType: conversion.StringPtr(req.EbsVolumeType),
},
ReadOnlySpecs: &readOnly,
RegionName: &req.Region,
Priority: &req.Priority,
ProviderName: &req.ProviderName,
ElectableSpecs: &electableSpec,
ReadOnlySpecs: &readOnly,
AutoScaling: &admin.AdvancedAutoScalingSettings{
DiskGB: &admin.DiskGBAutoScaling{Enabled: &req.AutoScalingDiskGbEnabled},
},
Expand Down
3 changes: 0 additions & 3 deletions internal/testutil/acc/config_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ func ClusterResourceHcl(req *ClusterRequest) (configStr, clusterName, resourceNa
} else {
clusterRootAttributes["project_id"] = projectID
}
if req.DiskSizeGb != 0 {
clusterRootAttributes["disk_size_gb"] = req.DiskSizeGb
}
if req.RetainBackupsEnabled {
clusterRootAttributes["retain_backups_enabled"] = req.RetainBackupsEnabled
}
Expand Down
11 changes: 10 additions & 1 deletion internal/testutil/acc/config_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ resource "mongodbatlas_advanced_cluster" "cluster_info" {
disk_gb_enabled = false
}
electable_specs {
disk_size_gb = 16
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 30
Expand Down Expand Up @@ -314,7 +315,15 @@ func Test_ClusterResourceHcl(t *testing.T) {
MongoDBMajorVersion: "6.0",
RetainBackupsEnabled: true,
ReplicationSpecs: []acc.ReplicationSpecRequest{
{Region: "MY_REGION_1", ZoneName: "Zone X", InstanceSize: "M30", NodeCount: 30, ProviderName: constant.AZURE, EbsVolumeType: "STANDARD"},
{
Region: "MY_REGION_1",
ZoneName: "Zone X",
InstanceSize: "M30",
NodeCount: 30,
ProviderName: constant.AZURE,
EbsVolumeType: "STANDARD",
DiskSizeGb: 16,
},
},
PitEnabled: true,
AdvancedConfiguration: map[string]any{
Expand Down
Loading