@@ -127,20 +127,21 @@ func testAccAdvancedClusterFlexUpgrade(t *testing.T, instanceSize string, includ
127
127
projectID , clusterName := acc .ProjectIDExecutionWithCluster (t , 1 )
128
128
defaultZoneName := "Zone 1" // Uses backend default as in existing tests
129
129
130
+ // avoid checking plural data source to reduce risk of being impacted from failure in other test using same project, allows running in parallel
130
131
steps := []resource.TestStep {
131
132
{
132
133
Config : configTenant (t , true , projectID , clusterName , defaultZoneName , instanceSize ),
133
- Check : checkTenant (true , projectID , clusterName ),
134
+ Check : checkTenant (true , projectID , clusterName , false ),
134
135
},
135
136
{
136
137
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 ),
138
139
},
139
140
}
140
141
if includeDedicated {
141
142
steps = append (steps , resource.TestStep {
142
143
Config : acc .ConvertAdvancedClusterToPreviewProviderV2 (t , true , acc .ConfigBasicDedicated (projectID , clusterName , defaultZoneName )),
143
- Check : checksBasicDedicated (projectID , clusterName ),
144
+ Check : checksBasicDedicated (projectID , clusterName , false ),
144
145
})
145
146
}
146
147
@@ -153,11 +154,11 @@ func testAccAdvancedClusterFlexUpgrade(t *testing.T, instanceSize string, includ
153
154
}
154
155
155
156
func TestAccAdvancedCluster_basicTenant_flexUpgrade_dedicatedUpgrade (t * testing.T ) {
156
- resource .Test (t , testAccAdvancedClusterFlexUpgrade (t , freeInstanceSize , true ))
157
+ resource .ParallelTest (t , testAccAdvancedClusterFlexUpgrade (t , freeInstanceSize , true ))
157
158
}
158
159
159
160
func TestAccAdvancedCluster_sharedTier_flexUpgrade (t * testing.T ) {
160
- resource .Test (t , testAccAdvancedClusterFlexUpgrade (t , sharedInstanceSize , false ))
161
+ resource .ParallelTest (t , testAccAdvancedClusterFlexUpgrade (t , sharedInstanceSize , false ))
161
162
}
162
163
func TestAccMockableAdvancedCluster_tenantUpgrade (t * testing.T ) {
163
164
var (
@@ -171,11 +172,11 @@ func TestAccMockableAdvancedCluster_tenantUpgrade(t *testing.T) {
171
172
Steps : []resource.TestStep {
172
173
{
173
174
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 ),
175
176
},
176
177
{
177
178
Config : acc .ConvertAdvancedClusterToPreviewProviderV2 (t , true , acc .ConfigBasicDedicated (projectID , clusterName , defaultZoneName )),
178
- Check : checksBasicDedicated (projectID , clusterName ),
179
+ Check : checksBasicDedicated (projectID , clusterName , true ),
179
180
},
180
181
acc .TestStepImportCluster (resourceName ),
181
182
},
@@ -1767,9 +1768,12 @@ func configTenant(t *testing.T, usePreviewProvider bool, projectID, name, zoneNa
1767
1768
` , projectID , name , zoneNameLine , instanceSize )) + dataSourcesTFNewSchema
1768
1769
}
1769
1770
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
+ }
1773
1777
return checkAggr (usePreviewProvider ,
1774
1778
[]string {"replication_specs.#" , "replication_specs.0.id" , "replication_specs.0.region_configs.#" },
1775
1779
map [string ]string {
@@ -1780,8 +1784,8 @@ func checkTenant(usePreviewProvider bool, projectID, name string) resource.TestC
1780
1784
pluralChecks ... )
1781
1785
}
1782
1786
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 )
1785
1789
checkMap := map [string ]string {
1786
1790
"replication_specs.0.region_configs.0.electable_specs.0.node_count" : "3" ,
1787
1791
"replication_specs.0.region_configs.0.electable_specs.0.instance_size" : "M10" ,
@@ -3280,11 +3284,11 @@ func TestAccClusterFlexCluster_basic(t *testing.T) {
3280
3284
Steps : []resource.TestStep {
3281
3285
{
3282
3286
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 ),
3284
3288
},
3285
3289
{
3286
3290
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 ),
3288
3292
},
3289
3293
acc .TestStepImportCluster (resourceName ),
3290
3294
{
@@ -3295,7 +3299,7 @@ func TestAccClusterFlexCluster_basic(t *testing.T) {
3295
3299
})
3296
3300
}
3297
3301
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 {
3299
3303
checks := []resource.TestCheckFunc {acc .CheckExistsFlexCluster ()}
3300
3304
attrMapAdvCluster := map [string ]string {
3301
3305
"name" : clusterName ,
@@ -3338,17 +3342,22 @@ func checkFlexClusterConfig(projectID, clusterName, providerName, region string,
3338
3342
tagsCheck := checkKeyValueBlocks (true , true , "tags" , tagsMap )
3339
3343
checks = append (checks , tagsCheck )
3340
3344
}
3341
- pluralMap := map [string ]string {
3342
- "project_id" : projectID ,
3343
- "results.#" : "1" ,
3344
- }
3345
3345
checks = acc .AddAttrChecks (acc .FlexDataSourceName , checks , attrMapFlex )
3346
3346
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 )
3351
3347
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
+ }
3353
3362
return acc .CheckRSAndDSPreviewProviderV2 (true , resourceName , ds , dsp , attrSetAdvCluster , attrMapAdvCluster , checks ... )
3354
3363
}
0 commit comments