@@ -127,20 +127,21 @@ func testAccAdvancedClusterFlexUpgrade(t *testing.T, instanceSize string, includ
127127 projectID , clusterName := acc .ProjectIDExecutionWithCluster (t , 1 )
128128 defaultZoneName := "Zone 1" // Uses backend default as in existing tests
129129
130+ // avoid checking plural data source to reduce risk of being impacted from failure in other test using same project, allows running in parallel
130131 steps := []resource.TestStep {
131132 {
132133 Config : configTenant (t , true , projectID , clusterName , defaultZoneName , instanceSize ),
133- Check : checkTenant (true , projectID , clusterName ),
134+ Check : checkTenant (true , projectID , clusterName , false ),
134135 },
135136 {
136137 Config : configFlexCluster (t , projectID , clusterName , "AWS" , "US_EAST_1" , defaultZoneName , false ),
137- Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , false ),
138+ Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , false , false ),
138139 },
139140 }
140141 if includeDedicated {
141142 steps = append (steps , resource.TestStep {
142143 Config : acc .ConvertAdvancedClusterToPreviewProviderV2 (t , true , acc .ConfigBasicDedicated (projectID , clusterName , defaultZoneName )),
143- Check : checksBasicDedicated (projectID , clusterName ),
144+ Check : checksBasicDedicated (projectID , clusterName , false ),
144145 })
145146 }
146147
@@ -153,11 +154,11 @@ func testAccAdvancedClusterFlexUpgrade(t *testing.T, instanceSize string, includ
153154}
154155
155156func TestAccAdvancedCluster_basicTenant_flexUpgrade_dedicatedUpgrade (t * testing.T ) {
156- resource .Test (t , testAccAdvancedClusterFlexUpgrade (t , freeInstanceSize , true ))
157+ resource .ParallelTest (t , testAccAdvancedClusterFlexUpgrade (t , freeInstanceSize , true ))
157158}
158159
159160func TestAccAdvancedCluster_sharedTier_flexUpgrade (t * testing.T ) {
160- resource .Test (t , testAccAdvancedClusterFlexUpgrade (t , sharedInstanceSize , false ))
161+ resource .ParallelTest (t , testAccAdvancedClusterFlexUpgrade (t , sharedInstanceSize , false ))
161162}
162163func TestAccMockableAdvancedCluster_tenantUpgrade (t * testing.T ) {
163164 var (
@@ -171,11 +172,11 @@ func TestAccMockableAdvancedCluster_tenantUpgrade(t *testing.T) {
171172 Steps : []resource.TestStep {
172173 {
173174 Config : acc .ConvertAdvancedClusterToPreviewProviderV2 (t , true , configTenant (t , true , projectID , clusterName , defaultZoneName , freeInstanceSize )),
174- Check : checkTenant (true , projectID , clusterName ),
175+ Check : checkTenant (true , projectID , clusterName , true ),
175176 },
176177 {
177178 Config : acc .ConvertAdvancedClusterToPreviewProviderV2 (t , true , acc .ConfigBasicDedicated (projectID , clusterName , defaultZoneName )),
178- Check : checksBasicDedicated (projectID , clusterName ),
179+ Check : checksBasicDedicated (projectID , clusterName , true ),
179180 },
180181 acc .TestStepImportCluster (resourceName ),
181182 },
@@ -1767,9 +1768,12 @@ func configTenant(t *testing.T, usePreviewProvider bool, projectID, name, zoneNa
17671768 ` , projectID , name , zoneNameLine , instanceSize )) + dataSourcesTFNewSchema
17681769}
17691770
1770- func checkTenant (usePreviewProvider bool , projectID , name string ) resource.TestCheckFunc {
1771- pluralChecks := acc .AddAttrSetChecksPreviewProviderV2 (usePreviewProvider , dataSourcePluralName , nil ,
1772- []string {"results.#" , "results.0.replication_specs.#" , "results.0.name" , "results.0.termination_protection_enabled" , "results.0.global_cluster_self_managed_sharding" }... )
1771+ func checkTenant (usePreviewProvider bool , projectID , name string , checkPlural bool ) resource.TestCheckFunc {
1772+ var pluralChecks []resource.TestCheckFunc
1773+ if checkPlural {
1774+ pluralChecks = acc .AddAttrSetChecksPreviewProviderV2 (usePreviewProvider , dataSourcePluralName , nil ,
1775+ []string {"results.#" , "results.0.replication_specs.#" , "results.0.name" , "results.0.termination_protection_enabled" , "results.0.global_cluster_self_managed_sharding" }... )
1776+ }
17731777 return checkAggr (usePreviewProvider ,
17741778 []string {"replication_specs.#" , "replication_specs.0.id" , "replication_specs.0.region_configs.#" },
17751779 map [string ]string {
@@ -1780,8 +1784,8 @@ func checkTenant(usePreviewProvider bool, projectID, name string) resource.TestC
17801784 pluralChecks ... )
17811785}
17821786
1783- func checksBasicDedicated (projectID , name string ) resource.TestCheckFunc {
1784- originalChecks := checkTenant (true , projectID , name )
1787+ func checksBasicDedicated (projectID , name string , checkPlural bool ) resource.TestCheckFunc {
1788+ originalChecks := checkTenant (true , projectID , name , checkPlural )
17851789 checkMap := map [string ]string {
17861790 "replication_specs.0.region_configs.0.electable_specs.0.node_count" : "3" ,
17871791 "replication_specs.0.region_configs.0.electable_specs.0.instance_size" : "M10" ,
@@ -3280,11 +3284,11 @@ func TestAccClusterFlexCluster_basic(t *testing.T) {
32803284 Steps : []resource.TestStep {
32813285 {
32823286 Config : configFlexCluster (t , projectID , clusterName , "AWS" , "US_EAST_1" , "" , false ),
3283- Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , false ),
3287+ Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , false , true ),
32843288 },
32853289 {
32863290 Config : configFlexCluster (t , projectID , clusterName , "AWS" , "US_EAST_1" , "" , true ),
3287- Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , true ),
3291+ Check : checkFlexClusterConfig (projectID , clusterName , "AWS" , "US_EAST_1" , true , true ),
32883292 },
32893293 acc .TestStepImportCluster (resourceName ),
32903294 {
@@ -3295,7 +3299,7 @@ func TestAccClusterFlexCluster_basic(t *testing.T) {
32953299 })
32963300}
32973301
3298- func checkFlexClusterConfig (projectID , clusterName , providerName , region string , tagsCheck bool ) resource.TestCheckFunc {
3302+ func checkFlexClusterConfig (projectID , clusterName , providerName , region string , tagsCheck , checkPlural bool ) resource.TestCheckFunc {
32993303 checks := []resource.TestCheckFunc {acc .CheckExistsFlexCluster ()}
33003304 attrMapAdvCluster := map [string ]string {
33013305 "name" : clusterName ,
@@ -3338,17 +3342,22 @@ func checkFlexClusterConfig(projectID, clusterName, providerName, region string,
33383342 tagsCheck := checkKeyValueBlocks (true , true , "tags" , tagsMap )
33393343 checks = append (checks , tagsCheck )
33403344 }
3341- pluralMap := map [string ]string {
3342- "project_id" : projectID ,
3343- "results.#" : "1" ,
3344- }
33453345 checks = acc .AddAttrChecks (acc .FlexDataSourceName , checks , attrMapFlex )
33463346 checks = acc .AddAttrSetChecks (acc .FlexDataSourceName , checks , attrSetFlex ... )
3347- checks = acc .AddAttrChecks (acc .FlexDataSourcePluralName , checks , pluralMap )
3348- checks = acc .AddAttrChecksPrefix (acc .FlexDataSourcePluralName , checks , attrMapFlex , "results.0" )
3349- checks = acc .AddAttrSetChecksPrefix (acc .FlexDataSourcePluralName , checks , attrSetFlex , "results.0" )
3350- checks = acc .AddAttrChecks (dataSourcePluralName , checks , pluralMap )
33513347 ds := conversion .StringPtr (dataSourceName )
3352- dsp := conversion .StringPtr (dataSourcePluralName )
3348+ var dsp * string
3349+
3350+ if checkPlural {
3351+ dsp = conversion .StringPtr (dataSourcePluralName )
3352+
3353+ pluralMap := map [string ]string {
3354+ "project_id" : projectID ,
3355+ "results.#" : "1" ,
3356+ }
3357+ checks = acc .AddAttrChecks (acc .FlexDataSourcePluralName , checks , pluralMap )
3358+ checks = acc .AddAttrChecksPrefix (acc .FlexDataSourcePluralName , checks , attrMapFlex , "results.0" )
3359+ checks = acc .AddAttrSetChecksPrefix (acc .FlexDataSourcePluralName , checks , attrSetFlex , "results.0" )
3360+ checks = acc .AddAttrChecks (dataSourcePluralName , checks , pluralMap )
3361+ }
33533362 return acc .CheckRSAndDSPreviewProviderV2 (true , resourceName , ds , dsp , attrSetAdvCluster , attrMapAdvCluster , checks ... )
33543363}
0 commit comments