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