Skip to content

Commit 62e1a9a

Browse files
chore: Updates logic in TPF to behave similarly to SDKv2 when blocks are deleted from the config (#3140)
* copy read_only_specs from state if unknown in plan * temporary comment mocked tests * AdjustReadOnlySpecs improvement getting info from state or electable_specs * try previous unknown logic * typo * pending auto-scaling logic * keep region_configs children if not in plan but still in state * simplify list assigments * don't do unknown optimizations to check tests * undo comment changes * todo doc * fix analytics_specs optimization * don't run AdjustRegionConfigsChildren if upgrading sharding config * don't use state for auto_scaling if not enabled * typo * uncomment mocked acceptance tests * update requests in mocked acceptance tests * add test step to check analytics_spec when deleted from config * adjust replica set test to analytics spec removal with other updates * inlcude test step verifying removal of autoscaling preserves previous state * inlcude test step verifying removal of analytics auto scaling preserves previous state * fix incorrect check in TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling * keep auto-scaling logic if there are changes in root but not in replication_specs so we leave unknowns in auto-scale related fields * test block removals in region_configs: TestAccMockableAdvancedCluster_removeBlocksFromConfig * generate captured data TestAccMockableAdvancedCluster_shardedAddAnalyticsAndAutoScaling * fix replicaSetAWSProvider test case by ensuring plan modifier does not set disk_size_gb value from state if it is also defined at root level --------- Co-authored-by: Agustin Bettati <[email protected]>
1 parent 2f0d440 commit 62e1a9a

14 files changed

+1056
-120
lines changed

internal/service/advancedcluster/resource_advanced_cluster_migration_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,25 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
5252
Steps: []resource.TestStep{
5353
{
5454
ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease),
55-
Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 3),
56-
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 3, false, false),
55+
Config: configReplicaSetAWSProvider(t, false, ReplicaSetAWSConfig{
56+
ProjectID: projectID,
57+
ClusterName: clusterName,
58+
DiskSizeGB: 60,
59+
NodeCountElectable: 3,
60+
WithAnalyticsSpecs: true,
61+
}),
62+
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 3, false, false),
5763
},
5864
{
5965
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
60-
Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 5),
61-
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 5, true, true),
66+
Config: configReplicaSetAWSProvider(t, false, ReplicaSetAWSConfig{
67+
ProjectID: projectID,
68+
ClusterName: clusterName,
69+
DiskSizeGB: 60,
70+
NodeCountElectable: 5,
71+
WithAnalyticsSpecs: true,
72+
}),
73+
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 5, true, true),
6274
},
6375
},
6476
})

internal/service/advancedcluster/resource_advanced_cluster_test.go

Lines changed: 229 additions & 40 deletions
Large diffs are not rendered by default.

internal/service/advancedcluster/testdata/TestAccMockableAdvancedCluster_removeBlocksFromConfig.yaml

Lines changed: 312 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"clusterType": "GEOSHARDED",
3+
"labels": [],
4+
"name": "{clusterName}",
5+
"replicationSpecs": [
6+
{
7+
"regionConfigs": [
8+
{
9+
"analyticsAutoScaling": {
10+
"compute": {
11+
"enabled": true,
12+
"maxInstanceSize": "M30",
13+
"minInstanceSize": "M10",
14+
"scaleDownEnabled": true
15+
},
16+
"diskGB": {
17+
"enabled": true
18+
}
19+
},
20+
"autoScaling": {
21+
"compute": {
22+
"enabled": true,
23+
"maxInstanceSize": "M30",
24+
"minInstanceSize": "M10",
25+
"scaleDownEnabled": true
26+
},
27+
"diskGB": {
28+
"enabled": true
29+
}
30+
},
31+
"electableSpecs": {
32+
"instanceSize": "M10",
33+
"nodeCount": 5
34+
},
35+
"priority": 7,
36+
"providerName": "AWS",
37+
"readOnlySpecs": {
38+
"instanceSize": "M10",
39+
"nodeCount": 2
40+
},
41+
"regionName": "US_EAST_1"
42+
}
43+
],
44+
"zoneName": "Zone 1"
45+
},
46+
{
47+
"regionConfigs": [
48+
{
49+
"analyticsAutoScaling": {
50+
"compute": {
51+
"enabled": true,
52+
"maxInstanceSize": "M30",
53+
"minInstanceSize": "M10",
54+
"scaleDownEnabled": true
55+
},
56+
"diskGB": {
57+
"enabled": true
58+
}
59+
},
60+
"analyticsSpecs": {
61+
"instanceSize": "M10",
62+
"nodeCount": 4
63+
},
64+
"autoScaling": {
65+
"compute": {
66+
"enabled": true,
67+
"maxInstanceSize": "M30",
68+
"minInstanceSize": "M10",
69+
"scaleDownEnabled": true
70+
},
71+
"diskGB": {
72+
"enabled": true
73+
}
74+
},
75+
"electableSpecs": {
76+
"instanceSize": "M10",
77+
"nodeCount": 3
78+
},
79+
"priority": 7,
80+
"providerName": "AWS",
81+
"readOnlySpecs": {
82+
"instanceSize": "M10",
83+
"nodeCount": 1
84+
},
85+
"regionName": "US_WEST_2"
86+
}
87+
],
88+
"zoneName": "Zone 2"
89+
}
90+
],
91+
"tags": []
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"replicationSpecs": [
3+
{
4+
"regionConfigs": [
5+
{
6+
"analyticsAutoScaling": {
7+
"compute": {
8+
"enabled": true,
9+
"maxInstanceSize": "M30",
10+
"minInstanceSize": "M10",
11+
"scaleDownEnabled": true
12+
},
13+
"diskGB": {
14+
"enabled": true
15+
}
16+
},
17+
"autoScaling": {
18+
"compute": {
19+
"enabled": true,
20+
"maxInstanceSize": "M30",
21+
"minInstanceSize": "M10",
22+
"scaleDownEnabled": true
23+
},
24+
"diskGB": {
25+
"enabled": true
26+
}
27+
},
28+
"electableSpecs": {
29+
"diskSizeGB": 10,
30+
"instanceSize": "M10",
31+
"nodeCount": 5
32+
},
33+
"priority": 7,
34+
"providerName": "AWS",
35+
"readOnlySpecs": {
36+
"diskSizeGB": 10,
37+
"instanceSize": "M10",
38+
"nodeCount": 2
39+
},
40+
"regionName": "US_EAST_1"
41+
}
42+
],
43+
"zoneName": "Zone 1"
44+
},
45+
{
46+
"regionConfigs": [
47+
{
48+
"analyticsAutoScaling": {
49+
"compute": {
50+
"enabled": true,
51+
"maxInstanceSize": "M30",
52+
"minInstanceSize": "M10",
53+
"scaleDownEnabled": true
54+
},
55+
"diskGB": {
56+
"enabled": true
57+
}
58+
},
59+
"analyticsSpecs": {
60+
"diskIOPS": 3000,
61+
"diskSizeGB": 10,
62+
"ebsVolumeType": "STANDARD",
63+
"instanceSize": "M10",
64+
"nodeCount": 4
65+
},
66+
"autoScaling": {
67+
"compute": {
68+
"enabled": true,
69+
"maxInstanceSize": "M30",
70+
"minInstanceSize": "M10",
71+
"scaleDownEnabled": true
72+
},
73+
"diskGB": {
74+
"enabled": true
75+
}
76+
},
77+
"electableSpecs": {
78+
"diskSizeGB": 10,
79+
"instanceSize": "M20",
80+
"nodeCount": 3
81+
},
82+
"priority": 7,
83+
"providerName": "AWS",
84+
"readOnlySpecs": {
85+
"diskSizeGB": 10,
86+
"instanceSize": "M20",
87+
"nodeCount": 1
88+
},
89+
"regionName": "US_WEST_2"
90+
}
91+
],
92+
"zoneName": "Zone 2"
93+
}
94+
]
95+
}

internal/service/advancedcluster/testdata/TestAccMockableAdvancedCluster_removeBlocksFromConfig/03_01_DELETE__api_atlas_v2_groups_{groupId}_clusters_{clusterName}_2023-02-01.json

Whitespace-only changes.

0 commit comments

Comments
 (0)