From 52462382c98ce54a82c69e92ce6976759830143d Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Wed, 3 Jan 2018 09:26:55 -0500 Subject: [PATCH] Refactor import tests for the remaining compute resources (#909) * Improve instance group manager import tests * Improe instance template & project metadata import test * Improve region autoscaler import test * Improve router interface import test * Improve router peer import test * Improve SSL certs import test * Improve http & https target proxy import tests * Improve target pool import test * Improve url map import test * Improve target ssl & tcp proxy import test * Add import test for instance template disk --- ...ort_compute_instance_group_manager_test.go | 69 -------- google/import_compute_instance_group_test.go | 30 ---- .../import_compute_instance_template_test.go | 147 ------------------ ...port_compute_project_metadata_item_test.go | 30 ---- .../import_compute_region_autoscaler_test.go | 36 ----- .../import_compute_router_interface_test.go | 30 ---- google/import_compute_router_peer_test.go | 30 ---- google/import_compute_ssl_certificate_test.go | 27 ---- .../import_compute_target_http_proxy_test.go | 34 ---- .../import_compute_target_https_proxy_test.go | 30 ---- google/import_compute_target_pool_test.go | 30 ---- .../import_compute_target_ssl_proxy_test.go | 31 ---- .../import_compute_target_tcp_proxy_test.go | 32 ---- google/import_compute_url_map_test.go | 32 ---- ...rce_compute_instance_group_manager_test.go | 13 ++ .../resource_compute_instance_group_test.go | 5 + ...resource_compute_instance_template_test.go | 60 +++++++ ...urce_compute_project_metadata_item_test.go | 14 +- ...resource_compute_region_autoscaler_test.go | 5 + .../resource_compute_router_interface_test.go | 5 + google/resource_compute_router_peer_test.go | 5 + .../resource_compute_ssl_certificate_test.go | 17 +- ...resource_compute_target_http_proxy_test.go | 5 + ...esource_compute_target_https_proxy_test.go | 5 + google/resource_compute_target_pool_test.go | 5 + .../resource_compute_target_ssl_proxy_test.go | 5 + .../resource_compute_target_tcp_proxy_test.go | 5 + google/resource_compute_url_map_test.go | 6 + 28 files changed, 142 insertions(+), 601 deletions(-) delete mode 100644 google/import_compute_instance_group_manager_test.go delete mode 100644 google/import_compute_instance_group_test.go delete mode 100644 google/import_compute_instance_template_test.go delete mode 100644 google/import_compute_project_metadata_item_test.go delete mode 100644 google/import_compute_region_autoscaler_test.go delete mode 100644 google/import_compute_router_interface_test.go delete mode 100644 google/import_compute_router_peer_test.go delete mode 100644 google/import_compute_ssl_certificate_test.go delete mode 100644 google/import_compute_target_http_proxy_test.go delete mode 100644 google/import_compute_target_https_proxy_test.go delete mode 100644 google/import_compute_target_pool_test.go delete mode 100644 google/import_compute_target_ssl_proxy_test.go delete mode 100644 google/import_compute_target_tcp_proxy_test.go delete mode 100644 google/import_compute_url_map_test.go diff --git a/google/import_compute_instance_group_manager_test.go b/google/import_compute_instance_group_manager_test.go deleted file mode 100644 index 0dc6207f..00000000 --- a/google/import_compute_instance_group_manager_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package google - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccInstanceGroupManager_importBasic(t *testing.T) { - t.Parallel() - - resourceName1 := "google_compute_instance_group_manager.igm-basic" - resourceName2 := "google_compute_instance_group_manager.igm-no-tp" - template := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - target := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - igm1 := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - igm2 := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckInstanceGroupManagerDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccInstanceGroupManager_basic(template, target, igm1, igm2), - }, - - resource.TestStep{ - ResourceName: resourceName1, - ImportState: true, - ImportStateVerify: true, - }, - - resource.TestStep{ - ResourceName: resourceName2, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccInstanceGroupManager_importUpdate(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_group_manager.igm-update" - template := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - target := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckInstanceGroupManagerDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccInstanceGroupManager_update(template, target, igm), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_instance_group_test.go b/google/import_compute_instance_group_test.go deleted file mode 100644 index 65ec8026..00000000 --- a/google/import_compute_instance_group_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeInstanceGroup_import(t *testing.T) { - t.Parallel() - - instanceName := fmt.Sprintf("instancegroup-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccComputeInstanceGroup_destroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceGroup_basic(instanceName), - }, - resource.TestStep{ - ResourceName: "google_compute_instance_group.basic", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_instance_template_test.go b/google/import_compute_instance_template_test.go deleted file mode 100644 index 180b1149..00000000 --- a/google/import_compute_instance_template_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package google - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeInstanceTemplate_importBasic(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_basic(), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccComputeInstanceTemplate_importIp(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_ip(), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccComputeInstanceTemplate_importDisks(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_disks(), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccComputeInstanceTemplate_importSubnetAuto(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - network := "network-" + acctest.RandString(10) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_subnet_auto(network), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccComputeInstanceTemplate_importSubnetCustom(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_subnet_custom(), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccComputeInstanceTemplate_importPrimaryAliasIpRange(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_instance_template.foobar" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceTemplateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeInstanceTemplate_primaryAliasIpRange(acctest.RandString(10)), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_project_metadata_item_test.go b/google/import_compute_project_metadata_item_test.go deleted file mode 100644 index 8613342c..00000000 --- a/google/import_compute_project_metadata_item_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeProjectMetadataItem_importBasic(t *testing.T) { - t.Parallel() - - key := "myKey" + acctest.RandString(10) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckProjectMetadataItemDestroy, - Steps: []resource.TestStep{ - { - Config: testAccProjectMetadataItem_basicWithResourceName("foobar", key, "myValue"), - }, - { - ResourceName: "google_compute_project_metadata_item.foobar", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_region_autoscaler_test.go b/google/import_compute_region_autoscaler_test.go deleted file mode 100644 index bd3c896b..00000000 --- a/google/import_compute_region_autoscaler_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package google - -import ( - "testing" - - "fmt" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeRegionAutoscaler_importBasic(t *testing.T) { - resourceName := "google_compute_region_autoscaler.foobar" - - var it_name = fmt.Sprintf("region-autoscaler-test-%s", acctest.RandString(10)) - var tp_name = fmt.Sprintf("region-autoscaler-test-%s", acctest.RandString(10)) - var igm_name = fmt.Sprintf("region-autoscaler-test-%s", acctest.RandString(10)) - var autoscaler_name = fmt.Sprintf("region-autoscaler-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeRegionAutoscalerDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeRegionAutoscaler_basic(it_name, tp_name, igm_name, autoscaler_name), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_router_interface_test.go b/google/import_compute_router_interface_test.go deleted file mode 100644 index 4912bd96..00000000 --- a/google/import_compute_router_interface_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeRouterInterface_import(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_router_interface.foobar" - testId := acctest.RandString(10) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeRouterInterfaceBasic(testId), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_router_peer_test.go b/google/import_compute_router_peer_test.go deleted file mode 100644 index 80d98363..00000000 --- a/google/import_compute_router_peer_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeRouterPeer_import(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_router_peer.foobar" - testId := acctest.RandString(10) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeRouterPeerBasic(testId), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_ssl_certificate_test.go b/google/import_compute_ssl_certificate_test.go deleted file mode 100644 index 8f83db71..00000000 --- a/google/import_compute_ssl_certificate_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package google - -import ( - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeSslCertificate_import(t *testing.T) { - t.Parallel() - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeSslCertificateDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeSslCertificate_import(), - }, - resource.TestStep{ - ResourceName: "google_compute_ssl_certificate.foobar", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key"}, - }, - }, - }) -} diff --git a/google/import_compute_target_http_proxy_test.go b/google/import_compute_target_http_proxy_test.go deleted file mode 100644 index a0a41562..00000000 --- a/google/import_compute_target_http_proxy_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeTargetHttpProxy_import(t *testing.T) { - t.Parallel() - - target := fmt.Sprintf("thttp-test-%s", acctest.RandString(10)) - backend := fmt.Sprintf("thttp-test-%s", acctest.RandString(10)) - hc := fmt.Sprintf("thttp-test-%s", acctest.RandString(10)) - urlmap1 := fmt.Sprintf("thttp-test-%s", acctest.RandString(10)) - urlmap2 := fmt.Sprintf("thttp-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeTargetHttpProxyDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeTargetHttpProxy_basic1(target, backend, hc, urlmap1, urlmap2), - }, - resource.TestStep{ - ResourceName: "google_compute_target_http_proxy.foobar", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_target_https_proxy_test.go b/google/import_compute_target_https_proxy_test.go deleted file mode 100644 index be2eea5a..00000000 --- a/google/import_compute_target_https_proxy_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeTargetHttpsProxy_import(t *testing.T) { - t.Parallel() - - id := fmt.Sprintf("thttps-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeTargetHttpsProxyDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeTargetHttpsProxy_basic1(id), - }, - resource.TestStep{ - ResourceName: "google_compute_target_https_proxy.foobar", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_target_pool_test.go b/google/import_compute_target_pool_test.go deleted file mode 100644 index abe8333c..00000000 --- a/google/import_compute_target_pool_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package google - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccComputeTargetPool_importBasic(t *testing.T) { - t.Parallel() - - resourceName := "google_compute_target_pool.foo" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeTargetPoolDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeTargetPool_basic(), - }, - - resource.TestStep{ - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_target_ssl_proxy_test.go b/google/import_compute_target_ssl_proxy_test.go deleted file mode 100644 index f7b762d3..00000000 --- a/google/import_compute_target_ssl_proxy_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeTargetSslProxy_import(t *testing.T) { - target := fmt.Sprintf("tssl-test-%s", acctest.RandString(10)) - cert := fmt.Sprintf("tssl-test-%s", acctest.RandString(10)) - backend := fmt.Sprintf("tssl-test-%s", acctest.RandString(10)) - hc := fmt.Sprintf("tssl-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeTargetSslProxyDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeTargetSslProxy_basic1(target, cert, backend, hc), - }, - resource.TestStep{ - ResourceName: "google_compute_target_ssl_proxy.foobar", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_target_tcp_proxy_test.go b/google/import_compute_target_tcp_proxy_test.go deleted file mode 100644 index 11ed1b82..00000000 --- a/google/import_compute_target_tcp_proxy_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeTargetTcpProxy_import(t *testing.T) { - t.Parallel() - - target := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10)) - backend := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10)) - hc := fmt.Sprintf("ttcp-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeTargetTcpProxyDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeTargetTcpProxy_basic1(target, backend, hc), - }, - resource.TestStep{ - ResourceName: "google_compute_target_tcp_proxy.foobar", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/google/import_compute_url_map_test.go b/google/import_compute_url_map_test.go deleted file mode 100644 index e4934bb1..00000000 --- a/google/import_compute_url_map_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package google - -import ( - "fmt" - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "testing" -) - -func TestAccComputeUrlMap_import(t *testing.T) { - t.Parallel() - - bsName := fmt.Sprintf("bs-test-%s", acctest.RandString(10)) - hcName := fmt.Sprintf("hc-test-%s", acctest.RandString(10)) - umName := fmt.Sprintf("um-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeUrlMapDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccComputeUrlMap_basic1(bsName, hcName, umName), - }, - resource.TestStep{ - ResourceName: "google_compute_url_map.foobar", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"host_rule", "path_matcher", "test"}, - }, - }}) -} diff --git a/google/resource_compute_instance_group_manager_test.go b/google/resource_compute_instance_group_manager_test.go index 0cff3c36..977b9b67 100644 --- a/google/resource_compute_instance_group_manager_test.go +++ b/google/resource_compute_instance_group_manager_test.go @@ -40,6 +40,16 @@ func TestAccInstanceGroupManager_basic(t *testing.T) { "google_compute_instance_group_manager.igm-no-tp", &manager), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_group_manager.igm-basic", + ImportState: true, + ImportStateVerify: true, + }, + resource.TestStep{ + ResourceName: "google_compute_instance_group_manager.igm-no-tp", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -225,6 +235,9 @@ func TestAccInstanceGroupManager_autoHealingPolicies(t *testing.T) { testAccCheckInstanceGroupManagerAutoHealingPolicies("google_compute_instance_group_manager.igm-basic", hck, 10), ), }, + // TODO: Add import test for auto healing policies + // Import doesn't work for auto healing policies because import is not supported + // for beta features. See https://github.com/terraform-providers/terraform-provider-google/issues/694 }, }) } diff --git a/google/resource_compute_instance_group_test.go b/google/resource_compute_instance_group_test.go index aca558d5..ba91f78a 100644 --- a/google/resource_compute_instance_group_test.go +++ b/google/resource_compute_instance_group_test.go @@ -31,6 +31,11 @@ func TestAccComputeInstanceGroup_basic(t *testing.T) { "google_compute_instance_group.empty", &instanceGroup), ), }, + { + ResourceName: "google_compute_instance_group.basic", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_instance_template_test.go b/google/resource_compute_instance_template_test.go index ac57ec57..71a1e876 100644 --- a/google/resource_compute_instance_template_test.go +++ b/google/resource_compute_instance_template_test.go @@ -35,6 +35,11 @@ func TestAccComputeInstanceTemplate_basic(t *testing.T) { testAccCheckComputeInstanceTemplateContainsLabel(&instanceTemplate, "my_label", "foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -58,6 +63,11 @@ func TestAccComputeInstanceTemplate_preemptible(t *testing.T) { testAccCheckComputeInstanceTemplatePreemptible(&instanceTemplate, true), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -80,6 +90,11 @@ func TestAccComputeInstanceTemplate_IP(t *testing.T) { testAccCheckComputeInstanceTemplateNetwork(&instanceTemplate), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -105,6 +120,11 @@ func TestAccComputeInstanceTemplate_networkIP(t *testing.T) { "google_compute_instance_template.foobar", networkIP, &instanceTemplate), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -129,6 +149,11 @@ func TestAccComputeInstanceTemplate_address(t *testing.T) { "google_compute_instance_template.foobar", address, &instanceTemplate), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -152,6 +177,11 @@ func TestAccComputeInstanceTemplate_disks(t *testing.T) { testAccCheckComputeInstanceTemplateDisk(&instanceTemplate, "terraform-test-foobar", false, false), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -175,6 +205,11 @@ func TestAccComputeInstanceTemplate_subnet_auto(t *testing.T) { testAccCheckComputeInstanceTemplateNetworkName(&instanceTemplate, network), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -197,6 +232,11 @@ func TestAccComputeInstanceTemplate_subnet_custom(t *testing.T) { testAccCheckComputeInstanceTemplateSubnetwork(&instanceTemplate), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -265,6 +305,11 @@ func TestAccComputeInstanceTemplate_primaryAliasIpRange(t *testing.T) { testAccCheckComputeInstanceTemplateHasAliasIpRange(&instanceTemplate, "", "/24"), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -286,6 +331,11 @@ func TestAccComputeInstanceTemplate_secondaryAliasIpRange(t *testing.T) { testAccCheckComputeInstanceTemplateHasAliasIpRange(&instanceTemplate, "inst-test-secondary", "/24"), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -307,6 +357,11 @@ func TestAccComputeInstanceTemplate_guestAccelerator(t *testing.T) { testAccCheckComputeInstanceTemplateHasGuestAccelerator(&instanceTemplate, "nvidia-tesla-k80", 1), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) @@ -329,6 +384,11 @@ func TestAccComputeInstanceTemplate_minCpuPlatform(t *testing.T) { testAccCheckComputeInstanceTemplateHasMinCpuPlatform(&instanceTemplate, DEFAULT_MIN_CPU_TEST_VALUE), ), }, + resource.TestStep{ + ResourceName: "google_compute_instance_template.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_project_metadata_item_test.go b/google/resource_compute_project_metadata_item_test.go index 95e770ee..a4334959 100644 --- a/google/resource_compute_project_metadata_item_test.go +++ b/google/resource_compute_project_metadata_item_test.go @@ -22,11 +22,16 @@ func TestAccComputeProjectMetadataItem_basic(t *testing.T) { CheckDestroy: testAccCheckProjectMetadataItemDestroy, Steps: []resource.TestStep{ { - Config: testAccProjectMetadataItem_basic(key, "myValue"), + Config: testAccProjectMetadataItem_basicWithResourceName("foobar", key, "myValue"), Check: resource.ComposeTestCheckFunc( testAccCheckProjectMetadataItem_hasMetadata(key, "myValue"), ), }, + { + ResourceName: "google_compute_project_metadata_item.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -67,11 +72,16 @@ func TestAccComputeProjectMetadataItem_basicWithEmptyVal(t *testing.T) { CheckDestroy: testAccCheckProjectMetadataItemDestroy, Steps: []resource.TestStep{ { - Config: testAccProjectMetadataItem_basic(key, ""), + Config: testAccProjectMetadataItem_basicWithResourceName("foobar", key, ""), Check: resource.ComposeTestCheckFunc( testAccCheckProjectMetadataItem_hasMetadata(key, ""), ), }, + { + ResourceName: "google_compute_project_metadata_item.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_region_autoscaler_test.go b/google/resource_compute_region_autoscaler_test.go index 755d96a4..f295eae5 100644 --- a/google/resource_compute_region_autoscaler_test.go +++ b/google/resource_compute_region_autoscaler_test.go @@ -30,6 +30,11 @@ func TestAccComputeRegionAutoscaler_basic(t *testing.T) { "google_compute_region_autoscaler.foobar", &ascaler), ), }, + resource.TestStep{ + ResourceName: "google_compute_region_autoscaler.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_router_interface_test.go b/google/resource_compute_router_interface_test.go index 146ea7bf..ca383b21 100644 --- a/google/resource_compute_router_interface_test.go +++ b/google/resource_compute_router_interface_test.go @@ -23,6 +23,11 @@ func TestAccComputeRouterInterface_basic(t *testing.T) { Check: testAccCheckComputeRouterInterfaceExists( "google_compute_router_interface.foobar"), }, + resource.TestStep{ + ResourceName: "google_compute_router_interface.foobar", + ImportState: true, + ImportStateVerify: true, + }, resource.TestStep{ Config: testAccComputeRouterInterfaceKeepRouter(testId), Check: testAccCheckComputeRouterInterfaceDelete( diff --git a/google/resource_compute_router_peer_test.go b/google/resource_compute_router_peer_test.go index 2f3d9732..04c89f6d 100644 --- a/google/resource_compute_router_peer_test.go +++ b/google/resource_compute_router_peer_test.go @@ -23,6 +23,11 @@ func TestAccComputeRouterPeer_basic(t *testing.T) { Check: testAccCheckComputeRouterPeerExists( "google_compute_router_peer.foobar"), }, + resource.TestStep{ + ResourceName: "google_compute_router_peer.foobar", + ImportState: true, + ImportStateVerify: true, + }, resource.TestStep{ Config: testAccComputeRouterPeerKeepRouter(testId), Check: testAccCheckComputeRouterPeerDelete( diff --git a/google/resource_compute_ssl_certificate_test.go b/google/resource_compute_ssl_certificate_test.go index 96b9be51..7bf9b940 100644 --- a/google/resource_compute_ssl_certificate_test.go +++ b/google/resource_compute_ssl_certificate_test.go @@ -24,6 +24,12 @@ func TestAccComputeSslCertificate_basic(t *testing.T) { "google_compute_ssl_certificate.foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_ssl_certificate.foobar", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"private_key"}, + }, }, }) } @@ -142,14 +148,3 @@ resource "google_compute_ssl_certificate" "foobar" { } `, acctest.RandString(10)) } - -func testAccComputeSslCertificate_import() string { - return fmt.Sprintf(` -resource "google_compute_ssl_certificate" "foobar" { - name = "sslcert-test-%s" - description = "very descriptive" - private_key = "${file("test-fixtures/ssl_cert/test.key")}" - certificate = "${file("test-fixtures/ssl_cert/test.crt")}" -} -`, acctest.RandString(10)) -} diff --git a/google/resource_compute_target_http_proxy_test.go b/google/resource_compute_target_http_proxy_test.go index 6665a8c8..cd77c598 100644 --- a/google/resource_compute_target_http_proxy_test.go +++ b/google/resource_compute_target_http_proxy_test.go @@ -30,6 +30,11 @@ func TestAccComputeTargetHttpProxy_basic(t *testing.T) { "google_compute_target_http_proxy.foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_target_http_proxy.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_target_https_proxy_test.go b/google/resource_compute_target_https_proxy_test.go index 09180411..62845de3 100644 --- a/google/resource_compute_target_https_proxy_test.go +++ b/google/resource_compute_target_https_proxy_test.go @@ -31,6 +31,11 @@ func TestAccComputeTargetHttpsProxy_basic(t *testing.T) { testAccComputeTargetHttpsProxyHasSslCertificate("httpsproxy-test-cert1-"+resourceSuffix, &proxy), ), }, + resource.TestStep{ + ResourceName: "google_compute_target_https_proxy.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_target_pool_test.go b/google/resource_compute_target_pool_test.go index 3979eef0..c4c9099a 100644 --- a/google/resource_compute_target_pool_test.go +++ b/google/resource_compute_target_pool_test.go @@ -28,6 +28,11 @@ func TestAccComputeTargetPool_basic(t *testing.T) { testAccCheckComputeTargetPoolHealthCheck("google_compute_target_pool.bar", "google_compute_http_health_check.foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_target_pool.foo", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_target_ssl_proxy_test.go b/google/resource_compute_target_ssl_proxy_test.go index cc668484..d25e46cf 100644 --- a/google/resource_compute_target_ssl_proxy_test.go +++ b/google/resource_compute_target_ssl_proxy_test.go @@ -27,6 +27,11 @@ func TestAccComputeTargetSslProxy_basic(t *testing.T) { "google_compute_target_ssl_proxy.foobar", "NONE", cert), ), }, + resource.TestStep{ + ResourceName: "google_compute_target_ssl_proxy.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_target_tcp_proxy_test.go b/google/resource_compute_target_tcp_proxy_test.go index bc9314fa..dfbbf7dd 100644 --- a/google/resource_compute_target_tcp_proxy_test.go +++ b/google/resource_compute_target_tcp_proxy_test.go @@ -28,6 +28,11 @@ func TestAccComputeTargetTcpProxy_basic(t *testing.T) { "google_compute_target_tcp_proxy.foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_target_tcp_proxy.foobar", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/google/resource_compute_url_map_test.go b/google/resource_compute_url_map_test.go index f5dd3383..ba10f196 100644 --- a/google/resource_compute_url_map_test.go +++ b/google/resource_compute_url_map_test.go @@ -27,6 +27,12 @@ func TestAccComputeUrlMap_basic(t *testing.T) { "google_compute_url_map.foobar"), ), }, + resource.TestStep{ + ResourceName: "google_compute_url_map.foobar", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"host_rule", "path_matcher", "test"}, + }, }, }) }