Skip to content

Commit 7dc7f02

Browse files
authored
Update resource_compute_region_backend_service_test.go.tmpl
1 parent aff9e5d commit 7dc7f02

File tree

1 file changed

+19
-109
lines changed

1 file changed

+19
-109
lines changed

mmv1/third_party/terraform/services/compute/resource_compute_region_backend_service_test.go.tmpl

+19-109
Original file line numberDiff line numberDiff line change
@@ -402,52 +402,14 @@ func TestAccComputeRegionBackendService_withLogConfig(t *testing.T) {
402402
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroyProducer(t),
403403
Steps: []resource.TestStep{
404404
{
405-
// Test: Initial setup with minimal config
406-
Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 1.0, "INCLUDE_ALL_OPTIONAL"),
405+
Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName),
407406
},
408407
{
409408
ResourceName: "google_compute_region_backend_service.foobar",
410409
ImportState: true,
411410
ImportStateVerify: true,
412411
},
413412
{
414-
// Test: Update to EXCLUDE_ALL_OPTIONAL mode
415-
Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 0.5, "EXCLUDE_ALL_OPTIONAL"),
416-
},
417-
{
418-
ResourceName: "google_compute_region_backend_service.foobar",
419-
ImportState: true,
420-
ImportStateVerify: true,
421-
},
422-
{
423-
// Test: Update to CUSTOM mode with fields
424-
Config: testAccComputeRegionBackendService_withLogConfigOptionalFields(serviceName, checkName),
425-
},
426-
{
427-
ResourceName: "google_compute_region_backend_service.foobar",
428-
ImportState: true,
429-
ImportStateVerify: true,
430-
},
431-
{
432-
// Test: CUSTOM mode with empty fields
433-
Config: testAccComputeRegionBackendService_withLogConfigCustomEmpty(serviceName, checkName),
434-
},
435-
{
436-
ResourceName: "google_compute_region_backend_service.foobar",
437-
ImportState: true,
438-
ImportStateVerify: true,
439-
},
440-
{
441-
// Test: Minimum sample rate
442-
Config: testAccComputeRegionBackendService_withLogConfig(serviceName, checkName, 0.0, "INCLUDE_ALL_OPTIONAL"),
443-
},
444-
{
445-
ResourceName: "google_compute_region_backend_service.foobar",
446-
ImportState: true,
447-
ImportStateVerify: true,
448-
},
449-
{
450-
// Test: Disable logging
451413
Config: testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, checkName),
452414
},
453415
{
@@ -1294,85 +1256,29 @@ resource "google_compute_region_security_policy" "policy" {
12941256
}
12951257
{{- end }}
12961258

1297-
func testAccComputeRegionBackendService_withLogConfig(serviceName, checkName string, sampleRate float64, optionalMode string) string {
1259+
func testAccComputeRegionBackendService_withLogConfig(serviceName, checkName string) string {
12981260
return fmt.Sprintf(`
12991261
resource "google_compute_region_backend_service" "foobar" {
13001262
name = "%s"
1301-
health_checks = [google_compute_health_check.health_check.self_link]
1302-
port_name = "http"
1303-
protocol = "HTTP"
1304-
load_balancing_scheme = "INTERNAL_MANAGED"
1305-
locality_lb_policy = "ROUND_ROBIN"
1306-
1307-
log_config {
1308-
enable = true
1309-
sample_rate = %v
1310-
optional_mode = "%s"
1311-
}
1312-
}
1313-
1314-
resource "google_compute_health_check" "health_check" {
1315-
name = "%s"
1316-
http_health_check {
1317-
port = 80
1318-
}
1319-
}
1320-
`, serviceName, sampleRate, optionalMode, checkName)
1321-
}
1322-
1323-
func testAccComputeRegionBackendService_withLogConfigOptionalFields(serviceName, checkName string) string {
1324-
return fmt.Sprintf(`
1325-
resource "google_compute_region_backend_service" "foobar" {
1326-
name = "%s"
1327-
health_checks = [google_compute_health_check.health_check.self_link]
1328-
port_name = "http"
1263+
region = "us-central1"
1264+
health_checks = [google_compute_region_health_check.health_check.self_link]
13291265
protocol = "HTTP"
13301266
load_balancing_scheme = "INTERNAL_MANAGED"
13311267
locality_lb_policy = "ROUND_ROBIN"
13321268

13331269
log_config {
13341270
enable = true
1335-
sample_rate = 0.5
1336-
optional_mode = "CUSTOM"
1337-
optional_fields = [
1338-
"PROTOCOL",
1339-
"RESPONSE_CODE",
1340-
"REQUEST_METHOD",
1341-
"URL_MAP",
1342-
"BACKEND_TARGET"
1343-
]
1271+
sample_rate = 1.0
1272+
optional_mode = "INCLUDE_ALL_OPTIONAL"
13441273
}
13451274
}
13461275

1347-
resource "google_compute_health_check" "health_check" {
1348-
name = "%s"
1349-
http_health_check {
1350-
port = 80
1351-
}
1352-
}
1353-
`, serviceName, checkName)
1354-
}
1355-
1356-
func testAccComputeRegionBackendService_withLogConfigCustomEmpty(serviceName, checkName string) string {
1357-
return fmt.Sprintf(`
1358-
resource "google_compute_region_backend_service" "foobar" {
1359-
name = "%s"
1360-
health_checks = [google_compute_health_check.health_check.self_link]
1361-
port_name = "http"
1362-
protocol = "HTTP"
1363-
load_balancing_scheme = "INTERNAL_MANAGED"
1364-
locality_lb_policy = "ROUND_ROBIN"
1365-
1366-
log_config {
1367-
enable = true
1368-
sample_rate = 0.5
1369-
optional_mode = "CUSTOM"
1370-
optional_fields = []
1371-
}
1372-
}
1276+
resource "google_compute_region_health_check" "health_check" {
1277+
name = "%s"
1278+
region = "us-central1"
1279+
check_interval_sec = 1
1280+
timeout_sec = 1
13731281

1374-
resource "google_compute_health_check" "health_check" {
1375-
name = "%s"
13761282
http_health_check {
13771283
port = 80
13781284
}
@@ -1384,8 +1290,8 @@ func testAccComputeRegionBackendService_withLogConfigDisabled(serviceName, check
13841290
return fmt.Sprintf(`
13851291
resource "google_compute_region_backend_service" "foobar" {
13861292
name = "%s"
1387-
health_checks = [google_compute_health_check.health_check.self_link]
1388-
port_name = "http"
1293+
region = "us-central1"
1294+
health_checks = [google_compute_region_health_check.health_check.self_link]
13891295
protocol = "HTTP"
13901296
load_balancing_scheme = "INTERNAL_MANAGED"
13911297
locality_lb_policy = "ROUND_ROBIN"
@@ -1395,8 +1301,12 @@ resource "google_compute_region_backend_service" "foobar" {
13951301
}
13961302
}
13971303

1398-
resource "google_compute_health_check" "health_check" {
1399-
name = "%s"
1304+
resource "google_compute_region_health_check" "health_check" {
1305+
name = "%s"
1306+
region = "us-central1"
1307+
check_interval_sec = 1
1308+
timeout_sec = 1
1309+
14001310
http_health_check {
14011311
port = 80
14021312
}

0 commit comments

Comments
 (0)