Skip to content

test: Updates all test workflows to use advanced_cluster TPF implementation #3580

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

Merged
merged 11 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/code-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ jobs:
secrets: inherit
uses: ./.github/workflows/acceptance-tests.yml
with:
reduced_tests: false
reduced_tests: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
)

func TestMigOutageSimulationCluster_SingleRegion_basic(t *testing.T) {
mig.SkipIfVersionBelow(t, "2.0.0") // version where advanced_cluster TPF was GA
mig.CreateAndRunTest(t, singleRegionTestCase(t))
}

func TestMigOutageSimulationCluster_MultiRegion_basic(t *testing.T) {
mig.SkipIfVersionBelow(t, "2.0.0") // version where advanced_cluster TPF was GA
mig.CreateAndRunTest(t, multiRegionTestCase(t))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
)
Expand Down
11 changes: 6 additions & 5 deletions internal/serviceapi/searchdeploymentapi/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
)
Expand Down Expand Up @@ -91,17 +92,17 @@ func advancedClusterConfig(orgID, projectName, clusterName string) string {
cluster_type = "REPLICASET"
retain_backups_enabled = "true"

replication_specs {
region_configs {
electable_specs {
replication_specs = [{
region_configs = [{
electable_specs = {
instance_size = "M10"
node_count = 3
}
provider_name = "AWS"
priority = 7
region_name = "US_EAST_1"
}
}
}]
}]
}
`, orgID, projectName, clusterName)
}
Expand Down
61 changes: 29 additions & 32 deletions internal/testutil/acc/config_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func writeReplicationSpec(cluster *hclwrite.Body, specs []admin.ReplicationSpec2
"provider_name": cty.StringVal(*rc.ProviderName),
"region_name": cty.StringVal(*rc.RegionName),
}

if rc.BackingProviderName != nil {
rcMap["backing_provider_name"] = cty.StringVal(*rc.BackingProviderName)
}
Expand All @@ -151,59 +150,57 @@ func writeReplicationSpec(cluster *hclwrite.Body, specs []admin.ReplicationSpec2
"disk_gb_enabled": cty.BoolVal(false),
})
} else {
autoScaling := rc.GetAutoScaling()
asDisk := autoScaling.GetDiskGB()
if autoScaling.Compute != nil {
return fmt.Errorf("auto_scaling.compute is not supported yet %v", autoScaling)
as := rc.GetAutoScaling()
asDisk := as.GetDiskGB()
if as.Compute != nil {
return fmt.Errorf("auto_scaling.compute is not supported yet %v", as)
}
rcMap["auto_scaling"] = cty.ObjectVal(map[string]cty.Value{
"disk_gb_enabled": cty.BoolVal(asDisk.GetEnabled()),
})
}

nodeSpec := rc.GetElectableSpecs()
es := rc.GetElectableSpecs()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these changes related with test workflow changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exactly, these were to fix one of the tests

esMap := map[string]cty.Value{}
if nodeSpec.InstanceSize != nil {
esMap["instance_size"] = cty.StringVal(*nodeSpec.InstanceSize)
if es.InstanceSize != nil {
esMap["instance_size"] = cty.StringVal(*es.InstanceSize)
}
if nodeSpec.NodeCount != nil {
esMap["node_count"] = cty.NumberIntVal(int64(*nodeSpec.NodeCount))
if es.NodeCount != nil {
esMap["node_count"] = cty.NumberIntVal(int64(*es.NodeCount))
}
if nodeSpec.EbsVolumeType != nil && *nodeSpec.EbsVolumeType != "" {
esMap["ebs_volume_type"] = cty.StringVal(*nodeSpec.EbsVolumeType)
if es.EbsVolumeType != nil && *es.EbsVolumeType != "" {
esMap["ebs_volume_type"] = cty.StringVal(*es.EbsVolumeType)
}
if nodeSpec.DiskIOPS != nil {
esMap["disk_iops"] = cty.NumberIntVal(int64(*nodeSpec.DiskIOPS))
if es.DiskIOPS != nil {
esMap["disk_iops"] = cty.NumberIntVal(int64(*es.DiskIOPS))
}
if len(esMap) > 0 {
rcMap["electable_specs"] = cty.ObjectVal(esMap)
}

readOnlySpecs := rc.GetReadOnlySpecs()
if readOnlySpecs.GetNodeCount() != 0 {
roMap := map[string]cty.Value{}
if readOnlySpecs.InstanceSize != nil {
roMap["instance_size"] = cty.StringVal(*readOnlySpecs.InstanceSize)
}
if readOnlySpecs.NodeCount != nil {
roMap["node_count"] = cty.NumberIntVal(int64(*readOnlySpecs.NodeCount))
}
if readOnlySpecs.DiskIOPS != nil {
roMap["disk_iops"] = cty.NumberIntVal(int64(*readOnlySpecs.DiskIOPS))
}
if len(roMap) > 0 {
rcMap["read_only_specs"] = cty.ObjectVal(roMap)
}
ros := rc.GetReadOnlySpecs()
roMap := map[string]cty.Value{}
if ros.InstanceSize != nil {
roMap["instance_size"] = cty.StringVal(*ros.InstanceSize)
}
if ros.NodeCount != nil && *ros.NodeCount != 0 {
roMap["node_count"] = cty.NumberIntVal(int64(*ros.NodeCount))
}
if ros.DiskIOPS != nil {
roMap["disk_iops"] = cty.NumberIntVal(int64(*ros.DiskIOPS))
}
if len(roMap) > 0 {
rcMap["read_only_specs"] = cty.ObjectVal(roMap)
}

rcList = append(rcList, cty.ObjectVal(rcMap))
}

specMap["region_configs"] = cty.ListVal(rcList)
// Use TupleVal instead of ListVal so region/spec objects can have different fields without type conflicts.
specMap["region_configs"] = cty.TupleVal(rcList)
allSpecs = append(allSpecs, cty.ObjectVal(specMap))
}

cluster.SetAttributeValue("replication_specs", cty.ListVal(allSpecs))
cluster.SetAttributeValue("replication_specs", cty.TupleVal(allSpecs))
return nil
}

Expand Down
Loading