-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Reuses
advanced_cluster
logic in SDKv2 & TPF initial sing…
…le file `common.go` (#2947) * refactor: Moves TestAccMockableAdvancedCluster_basicTenant to SDKv2 * test(unit): use IsTfLogDebug and support logging config in both REPLAY & CAPTURE * refactor: move TPF resource_tests to sdkv2 * refactor: move testdata for TestAccMockableAdvancedCluster_replicasetAdvConfigUpdate.yaml * refactor: move testdata for TestAccMockableAdvancedCluster_shardedBasic.yaml * refactor: move testdata for TestAccMockableAdvancedCluster_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml * chore: log also query string in request matching and add QueryVars to mockConfig * chore: Support testmact in makefile and use it in github action * feat: add timeouts attribute support in advanced cluster schema conversion * refactor: consolidate data source definitions in advanced cluster tests * feat: add support for HTTP mock capture in testmact-capture target * refactor: move testdata for TestAccMockableAdvancedCluster_tenantUpgrade.yaml * refactor: move testdata for TestAccMockableAdvancedCluster_symmetricShardedOldSchema.yaml * test: ensure timeouts.create attribute is only checked on resource * fix: enforce explicit setting of ACCTEST_PACKAGES for testmact targets * chore: regenerate test files * chore: Add ORG_ID env var when using replay * fix: update minimum_enabled_tls_protocol to TLS1.2 and refactor timeout check in advanced cluster tests * test: Add more checks to new acceptance tests * fix: update advanced cluster test data sources to include new schema * chore: regen replicasetAdvConfigUpdate test * fix: update acceptance tests configuration to use correct package path and add regex for test selection * test: Refactor tests to use consistent TF config for data sources * fix: update advanced cluster test to correct timeout attribute and refactor update for TestAccMockableAdvancedCluster_replicasetAdvConfigUpdate * refactor: remove test cases functions for new tests * chore: use new schema for testmact if it is not set * chore: regenerate mock data * refactor: Moves AddIDsToReplicationSpecs to TPF and reuse FormatMongoDBMajorVersion * refactor: Replace getAdvancedClusterContainerID with advancedclustertpf.GetAdvancedClusterContainerID for improved code reuse * refactor: Reuse advanced configuration handling in createCluster function * refactor: Update acceptance tests runner to include common.go in advanced cluster filters * refactor: rename test function and make update compatible with SDKv2 * refactor: remove redundant VERSION assignments in GNUmakefile [ci skip] * refactor: remove redundant VERSION assignment in GNUmakefile * apply PR suggestion
- Loading branch information
1 parent
c13ae3b
commit 19c703f
Showing
9 changed files
with
187 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package advancedclustertpf | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" | ||
"github.com/spf13/cast" | ||
"go.mongodb.org/atlas-sdk/v20241113004/admin" | ||
) | ||
|
||
func FormatMongoDBMajorVersion(version string) string { | ||
if strings.Contains(version, ".") { | ||
return version | ||
} | ||
return fmt.Sprintf("%.1f", cast.ToFloat32(version)) | ||
} | ||
|
||
func AddIDsToReplicationSpecs(replicationSpecs []admin.ReplicationSpec20240805, zoneToReplicationSpecsIDs map[string][]string) []admin.ReplicationSpec20240805 { | ||
for zoneName, availableIDs := range zoneToReplicationSpecsIDs { | ||
indexOfIDToUse := 0 | ||
for i := range replicationSpecs { | ||
if indexOfIDToUse >= len(availableIDs) { | ||
break // all available ids for this zone have been used | ||
} | ||
if replicationSpecs[i].GetZoneName() == zoneName { | ||
newID := availableIDs[indexOfIDToUse] | ||
indexOfIDToUse++ | ||
replicationSpecs[i].Id = &newID | ||
} | ||
} | ||
} | ||
return replicationSpecs | ||
} | ||
|
||
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 "" | ||
} |
Oops, something went wrong.