@@ -55,7 +55,27 @@ func TestAccVmwareenginePrivateCloud_vmwareEnginePrivateCloudUpdate(t *testing.T
55
55
},
56
56
57
57
{
58
- Config : testVmwareenginePrivateCloudUpdateConfig (context ),
58
+ Config : testVmwareenginePrivateCloudUpdateNodeConfig (context ),
59
+ Check : resource .ComposeTestCheckFunc (
60
+ acctest .CheckDataSourceStateMatchesResourceStateWithIgnores (
61
+ "data.google_vmwareengine_private_cloud.ds" ,
62
+ "google_vmwareengine_private_cloud.vmw-engine-pc" ,
63
+ map [string ]struct {}{
64
+ "type" : {},
65
+ "deletion_delay_hours" : {},
66
+ "send_deletion_delay_hours_if_zero" : {},
67
+ }),
68
+ ),
69
+ },
70
+ {
71
+ ResourceName : "google_vmwareengine_private_cloud.vmw-engine-pc" ,
72
+ ImportState : true ,
73
+ ImportStateVerify : true ,
74
+ ImportStateVerifyIgnore : []string {"location" , "name" , "update_time" , "type" , "deletion_delay_hours" , "send_deletion_delay_hours_if_zero" },
75
+ },
76
+
77
+ {
78
+ Config : testVmwareenginePrivateCloudUpdateAutoscaleConfig (context ),
59
79
Check : resource .ComposeTestCheckFunc (
60
80
acctest .CheckDataSourceStateMatchesResourceStateWithIgnores (
61
81
"data.google_vmwareengine_private_cloud.ds" ,
@@ -131,27 +151,31 @@ func TestAccVmwareenginePrivateCloud_vmwareEnginePrivateCloudUpdate(t *testing.T
131
151
}
132
152
133
153
func testVmwareenginePrivateCloudCreateConfig (context map [string ]interface {}) string {
134
- return testVmwareenginePrivateCloudConfig (context , "sample description" , "TIME_LIMITED " , 1 , 1 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
154
+ return testVmwareenginePrivateCloudConfig (context , "sample description" , "STANDARD " , 3 , 8 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
135
155
}
136
156
137
- func testVmwareenginePrivateCloudUpdateConfig (context map [string ]interface {}) string {
157
+ func testVmwareenginePrivateCloudUpdateNodeConfig (context map [string ]interface {}) string {
138
158
return testVmwareenginePrivateCloudConfig (context , "sample updated description" , "STANDARD" , 3 , 8 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
139
159
}
140
160
161
+ func testVmwareenginePrivateCloudUpdateAutoscaleConfig (context map [string ]interface {}) string {
162
+ return testVmwareenginePrivateCloudAutoscaleConfig (context , "sample updated description" , "STANDARD" , 3 , 8 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
163
+ }
164
+
141
165
func testVmwareenginePrivateCloudDelayedDeleteConfig (context map [string ]interface {}) string {
142
166
return testVmwareenginePrivateCloudDeletedConfig (context )
143
167
}
144
168
145
169
func testVmwareenginePrivateCloudUndeleteConfig (context map [string ]interface {}) string {
146
- return testVmwareenginePrivateCloudConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
170
+ return testVmwareenginePrivateCloudAutoscaleConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineVcenterNSXCredentailsConfig (context )
147
171
}
148
172
149
173
func testVmwareengineSubnetImportConfig (context map [string ]interface {}) string {
150
- return testVmwareenginePrivateCloudConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineSubnetConfig (context , "192.168.1.0/26" )
174
+ return testVmwareenginePrivateCloudAutoscaleConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineSubnetConfig (context , "192.168.1.0/26" )
151
175
}
152
176
153
177
func testVmwareengineSubnetUpdateConfig (context map [string ]interface {}) string {
154
- return testVmwareenginePrivateCloudConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineSubnetConfig (context , "192.168.2.0/26" )
178
+ return testVmwareenginePrivateCloudAutoscaleConfig (context , "sample updated description" , "STANDARD" , 3 , 0 ) + testVmwareengineSubnetConfig (context , "192.168.2.0/26" )
155
179
}
156
180
157
181
func testVmwareenginePrivateCloudConfig (context map [string ]interface {}, description , pcType string , nodeCount , delayHours int ) string {
@@ -184,6 +208,86 @@ resource "google_vmwareengine_private_cloud" "vmw-engine-pc" {
184
208
node_type_id = "standard-72"
185
209
node_count = "%{node_count}"
186
210
custom_core_count = 32
211
+ }
212
+ autoscaling_settings {
213
+ autoscaling_policies {
214
+ autoscale_policy_id = "autoscaling-policy"
215
+ node_type_id = "standard-72"
216
+ scale_out_size = 1
217
+ storage_thresholds {
218
+ scale_out = 60
219
+ scale_in = 20
220
+ }
221
+ }
222
+ min_cluster_node_count = 3
223
+ max_cluster_node_count = 8
224
+ cool_down_period = "1800s"
225
+ }
226
+ }
227
+ }
228
+
229
+ data "google_vmwareengine_private_cloud" "ds" {
230
+ location = "%{region}-b"
231
+ name = "tf-test-sample-pc%{random_suffix}"
232
+ depends_on = [
233
+ google_vmwareengine_private_cloud.vmw-engine-pc,
234
+ ]
235
+ }
236
+ ` , context )
237
+ }
238
+
239
+ func testVmwareenginePrivateCloudAutoscaleConfig (context map [string ]interface {}, description , pcType string , nodeCount , delayHours int ) string {
240
+ context ["node_count" ] = nodeCount
241
+ context ["delay_hrs" ] = delayHours
242
+ context ["description" ] = description
243
+ context ["type" ] = pcType
244
+ return acctest .Nprintf (`
245
+ resource "google_vmwareengine_network" "vmw-engine-nw" {
246
+ name = "tf-test-pc-nw-%{random_suffix}"
247
+ location = "global"
248
+ type = "STANDARD"
249
+ description = "PC network description."
250
+ }
251
+
252
+ resource "google_vmwareengine_private_cloud" "vmw-engine-pc" {
253
+ location = "%{region}-b"
254
+ name = "tf-test-sample-pc%{random_suffix}"
255
+ description = "%{description}"
256
+ type = "%{type}"
257
+ deletion_delay_hours = "%{delay_hrs}"
258
+ send_deletion_delay_hours_if_zero = true
259
+ network_config {
260
+ management_cidr = "192.168.0.0/24"
261
+ vmware_engine_network = google_vmwareengine_network.vmw-engine-nw.id
262
+ }
263
+ management_cluster {
264
+ cluster_id = "tf-test-sample-mgmt-cluster-custom-core-count%{random_suffix}"
265
+ node_type_configs {
266
+ node_type_id = "standard-72"
267
+ node_count = "%{node_count}"
268
+ custom_core_count = 32
269
+ }
270
+ autoscaling_settings {
271
+ autoscaling_policies {
272
+ autoscale_policy_id = "autoscaling-policy"
273
+ node_type_id = "standard-72"
274
+ scale_out_size = 1
275
+ cpu_thresholds {
276
+ scale_out = 80
277
+ scale_in = 15
278
+ }
279
+ consumed_memory_thresholds {
280
+ scale_out = 75
281
+ scale_in = 20
282
+ }
283
+ storage_thresholds {
284
+ scale_out = 80
285
+ scale_in = 20
286
+ }
287
+ }
288
+ min_cluster_node_count = 3
289
+ max_cluster_node_count = 8
290
+ cool_down_period = "1800s"
187
291
}
188
292
}
189
293
}
0 commit comments