mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-06 10:12:39 +00:00
![Dana Hoffman](/assets/img/avatar_default.png)
We had a failure in the last CI run while waiting for this resource to be created, so let's increase the timeout. ``` ------- Stdout: ------- === RUN TestAccDataSourceRegionInstanceGroup --- FAIL: TestAccDataSourceRegionInstanceGroup (631.53s) testing.go:518: Step 0 error: Error applying: 1 error(s) occurred: * google_compute_region_instance_group_manager.foo: 1 error(s) occurred: * google_compute_region_instance_group_manager.foo: timeout while waiting for state to become 'created' (last state: 'creating', timeout: 5m0s) testing.go:579: Error destroying resource! WARNING: Dangling resources may exist. The full state and error is shown below. Error: Error refreshing: 1 error(s) occurred: * google_compute_region_instance_group_manager.foo: 1 error(s) occurred: * google_compute_region_instance_group_manager.foo: google_compute_region_instance_group_manager.foo: timeout while waiting for state to become 'created' (last state: 'creating', timeout: 5m0s) State: FAIL ```
90 lines
2.3 KiB
Go
90 lines
2.3 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccDataSourceRegionInstanceGroup(t *testing.T) {
|
|
t.Parallel()
|
|
name := "acctest-" + acctest.RandString(6)
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccDataSourceRegionInstanceGroup_basic(name),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "name", name),
|
|
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "project", getTestProjectFromEnv()),
|
|
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "instances.#", "10")),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccDataSourceRegionInstanceGroup_basic(instanceManagerName string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_compute_health_check" "autohealing" {
|
|
name = "%s"
|
|
check_interval_sec = 1
|
|
timeout_sec = 1
|
|
healthy_threshold = 2
|
|
unhealthy_threshold = 10
|
|
|
|
http_health_check {
|
|
request_path = "/"
|
|
port = "80"
|
|
}
|
|
}
|
|
|
|
resource "google_compute_target_pool" "foo" {
|
|
name = "%s"
|
|
}
|
|
|
|
data "google_compute_image" "debian" {
|
|
project = "debian-cloud"
|
|
name = "debian-9-stretch-v20171129"
|
|
}
|
|
|
|
resource "google_compute_instance_template" "foo" {
|
|
machine_type = "n1-standard-1"
|
|
disk {
|
|
source_image = "${data.google_compute_image.debian.self_link}"
|
|
}
|
|
network_interface {
|
|
access_config {
|
|
}
|
|
network = "default"
|
|
}
|
|
}
|
|
|
|
resource "google_compute_region_instance_group_manager" "foo" {
|
|
name = "%s"
|
|
base_instance_name = "foo"
|
|
instance_template = "${google_compute_instance_template.foo.self_link}"
|
|
region = "us-central1"
|
|
target_pools = ["${google_compute_target_pool.foo.self_link}"]
|
|
target_size = 10
|
|
|
|
named_port {
|
|
name = "web"
|
|
port = 80
|
|
}
|
|
wait_for_instances = true
|
|
|
|
auto_healing_policies {
|
|
health_check = "${google_compute_health_check.autohealing.self_link}"
|
|
initial_delay_sec = 10
|
|
}
|
|
}
|
|
|
|
data "google_compute_region_instance_group" "data_source" {
|
|
self_link = "${google_compute_region_instance_group_manager.foo.instance_group}"
|
|
}
|
|
`, acctest.RandomWithPrefix("test-rigm-"), acctest.RandomWithPrefix("test-rigm-"), instanceManagerName)
|
|
}
|