Skip to content

Commit

Permalink
test updating max_utilization field of backend service
Browse files Browse the repository at this point in the history
  • Loading branch information
hyww committed Oct 16, 2020
1 parent 6fca18a commit 30bdd16
Showing 1 changed file with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,44 @@ func TestAccComputeBackendService_withBackend(t *testing.T) {
})
}

func TestAccComputeBackendService_withBackendAndMaxUtilization(t *testing.T) {
serviceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
igName := fmt.Sprintf("tf-test-%s", randString(t, 10))
itName := fmt.Sprintf("tf-test-%s", randString(t, 10))
checkName := fmt.Sprintf("tf-test-%s", randString(t, 10))
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroyProducer(t),
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeBackendService_withBackend(
serviceName, igName, itName, checkName, 10),
},
resource.TestStep{
ResourceName: "google_compute_backend_service.lipsum",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: testAccComputeBackendService_withBackendAndMaxUtilization(
serviceName, igName, itName, checkName, 10),
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
resource.TestStep{
Config: testAccComputeBackendService_withBackendAndMaxUtilization(
serviceName, igName, itName, checkName, 10),
},
resource.TestStep{
ResourceName: "google_compute_backend_service.lipsum",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccComputeBackendService_withBackendAndIAP(t *testing.T) {
serviceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
igName := fmt.Sprintf("tf-test-%s", randString(t, 10))
Expand Down Expand Up @@ -941,6 +979,64 @@ resource "google_compute_http_health_check" "default" {
`, serviceName, timeout, igName, itName, checkName)
}

func testAccComputeBackendService_withBackendAndMaxUtilization(
serviceName, igName, itName, checkName string, timeout int64) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_backend_service" "lipsum" {
name = "%s"
description = "Hello World 1234"
port_name = "http"
protocol = "HTTP"
timeout_sec = %v

backend {
group = google_compute_instance_group_manager.foobar.instance_group
max_utilization = 1.0
}

health_checks = [google_compute_http_health_check.default.self_link]
}

resource "google_compute_instance_group_manager" "foobar" {
name = "%s"
version {
instance_template = google_compute_instance_template.foobar.self_link
name = "primary"
}
base_instance_name = "foobar"
zone = "us-central1-f"
target_size = 1
}

resource "google_compute_instance_template" "foobar" {
name = "%s"
machine_type = "e2-medium"

network_interface {
network = "default"
}

disk {
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
boot = true
}
}

resource "google_compute_http_health_check" "default" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
`, serviceName, timeout, igName, itName, checkName)
}

func testAccComputeBackendService_withBackendAndIAP(
serviceName, igName, itName, checkName string, timeout int64) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 30bdd16

Please sign in to comment.