Merge pull request #4520 from lwander/b-gcp-acctest-hardcode-name
provider/google: Limit hardcoded test resource names
This commit is contained in:
commit
e7057805af
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestAccComputeFirewall_basic(t *testing.T) {
|
||||
var firewall compute.Firewall
|
||||
networkName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
firewallName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -19,7 +21,7 @@ func TestAccComputeFirewall_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeFirewallDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeFirewall_basic,
|
||||
Config: testAccComputeFirewall_basic(networkName, firewallName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeFirewallExists(
|
||||
"google_compute_firewall.foobar", &firewall),
|
||||
|
@ -31,6 +33,8 @@ func TestAccComputeFirewall_basic(t *testing.T) {
|
|||
|
||||
func TestAccComputeFirewall_update(t *testing.T) {
|
||||
var firewall compute.Firewall
|
||||
networkName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
firewallName := fmt.Sprintf("firewall-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -38,14 +42,14 @@ func TestAccComputeFirewall_update(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeFirewallDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeFirewall_basic,
|
||||
Config: testAccComputeFirewall_basic(networkName, firewallName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeFirewallExists(
|
||||
"google_compute_firewall.foobar", &firewall),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeFirewall_update,
|
||||
Config: testAccComputeFirewall_update(networkName, firewallName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeFirewallExists(
|
||||
"google_compute_firewall.foobar", &firewall),
|
||||
|
@ -119,37 +123,41 @@ func testAccCheckComputeFirewallPorts(
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeFirewall_basic = fmt.Sprintf(`
|
||||
resource "google_compute_network" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
ipv4_range = "10.0.0.0/16"
|
||||
func testAccComputeFirewall_basic(network, firewall string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
ipv4_range = "10.0.0.0/16"
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
network = "${google_compute_network.foobar.name}"
|
||||
source_tags = ["foo"]
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
}
|
||||
}`, network, firewall)
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
network = "${google_compute_network.foobar.name}"
|
||||
source_tags = ["foo"]
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
func testAccComputeFirewall_update(network, firewall string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
ipv4_range = "10.0.0.0/16"
|
||||
}
|
||||
}`, acctest.RandString(10), acctest.RandString(10))
|
||||
|
||||
var testAccComputeFirewall_update = fmt.Sprintf(`
|
||||
resource "google_compute_network" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
ipv4_range = "10.0.0.0/16"
|
||||
resource "google_compute_firewall" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
network = "${google_compute_network.foobar.name}"
|
||||
source_tags = ["foo"]
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["80-255"]
|
||||
}
|
||||
}`, network, firewall)
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "foobar" {
|
||||
name = "firewall-test-%s"
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
network = "${google_compute_network.foobar.name}"
|
||||
source_tags = ["foo"]
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["80-255"]
|
||||
}
|
||||
}`, acctest.RandString(10), acctest.RandString(10))
|
||||
|
|
|
@ -10,13 +10,20 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeGlobalForwardingRule_basic(t *testing.T) {
|
||||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy1 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy2 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeGlobalForwardingRule_basic1,
|
||||
Config: testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
|
@ -27,13 +34,20 @@ func TestAccComputeGlobalForwardingRule_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccComputeGlobalForwardingRule_update(t *testing.T) {
|
||||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy1 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy2 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeGlobalForwardingRule_basic1,
|
||||
Config: testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
|
@ -41,7 +55,7 @@ func TestAccComputeGlobalForwardingRule_update(t *testing.T) {
|
|||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccComputeGlobalForwardingRule_basic2,
|
||||
Config: testAccComputeGlobalForwardingRule_basic2(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
|
@ -96,116 +110,116 @@ func testAccCheckComputeGlobalForwardingRuleExists(n string) resource.TestCheckF
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeGlobalForwardingRule_basic1 = fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "gforward-test-%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar1.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "gforward-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "gforward-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "gforward-test-%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "gforward-test-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
name = "gforward-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
func testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar1.self_link}"
|
||||
}
|
||||
path_matcher {
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}`, fr, proxy1, proxy2, backend, hc, urlmap)
|
||||
}
|
||||
|
||||
func testAccComputeGlobalForwardingRule_basic2(fr, proxy1, proxy2, backend, hc, urlmap string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar2.self_link}"
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10),
|
||||
acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
||||
var testAccComputeGlobalForwardingRule_basic2 = fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "gforward-test-%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar2.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "gforward-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "gforward-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "gforward-test-%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "gforward-test-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
name = "gforward-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
path_matcher {
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}`, fr, proxy1, proxy2, backend, hc, urlmap)
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10),
|
||||
acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
|
|
@ -14,13 +14,18 @@ import (
|
|||
func TestAccInstanceGroupManager_basic(t *testing.T) {
|
||||
var manager compute.InstanceGroupManager
|
||||
|
||||
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,
|
||||
Config: testAccInstanceGroupManager_basic(template, target, igm1, igm2),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceGroupManagerExists(
|
||||
"google_compute_instance_group_manager.igm-basic", &manager),
|
||||
|
@ -35,26 +40,31 @@ func TestAccInstanceGroupManager_basic(t *testing.T) {
|
|||
func TestAccInstanceGroupManager_update(t *testing.T) {
|
||||
var manager compute.InstanceGroupManager
|
||||
|
||||
template1 := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
|
||||
target := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
|
||||
template2 := 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,
|
||||
Config: testAccInstanceGroupManager_update(template1, target, igm),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceGroupManagerExists(
|
||||
"google_compute_instance_group_manager.igm-update", &manager),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccInstanceGroupManager_update2,
|
||||
Config: testAccInstanceGroupManager_update2(template1, target, template2, igm),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceGroupManagerExists(
|
||||
"google_compute_instance_group_manager.igm-update", &manager),
|
||||
testAccCheckInstanceGroupManagerUpdated(
|
||||
"google_compute_instance_group_manager.igm-update", 3,
|
||||
"google_compute_target_pool.igm-update", "terraform-test-igm-update2"),
|
||||
"google_compute_target_pool.igm-update", template2),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -147,164 +157,170 @@ func testAccCheckInstanceGroupManagerUpdated(n string, size int64, targetPool st
|
|||
}
|
||||
}
|
||||
|
||||
var testAccInstanceGroupManager_basic = fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-basic" {
|
||||
name = "igm-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccInstanceGroupManager_basic(template, target, igm1, igm2 string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-basic" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
resource "google_compute_target_pool" "igm-basic" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
resource "google_compute_instance_group_manager" "igm-basic" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "%s"
|
||||
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-basic.self_link}"]
|
||||
base_instance_name = "igm-basic"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
resource "google_compute_instance_group_manager" "igm-no-tp" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "%s"
|
||||
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
|
||||
base_instance_name = "igm-no-tp"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}
|
||||
`, template, target, igm1, igm2)
|
||||
}
|
||||
|
||||
resource "google_compute_target_pool" "igm-basic" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "igm-test-%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
func testAccInstanceGroupManager_update(template, target, igm string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-update" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
resource "google_compute_instance_group_manager" "igm-basic" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "igm-test-%s"
|
||||
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-basic.self_link}"]
|
||||
base_instance_name = "igm-basic"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
resource "google_compute_instance_group_manager" "igm-no-tp" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "igm-test-%s"
|
||||
instance_template = "${google_compute_instance_template.igm-basic.self_link}"
|
||||
base_instance_name = "igm-no-tp"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
var testAccInstanceGroupManager_update = fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-update" {
|
||||
name = "igm-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
resource "google_compute_target_pool" "igm-update" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
resource "google_compute_instance_group_manager" "igm-update" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "%s"
|
||||
instance_template = "${google_compute_instance_template.igm-update.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-update.self_link}"]
|
||||
base_instance_name = "igm-update"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}`, template, target, igm)
|
||||
}
|
||||
|
||||
resource "google_compute_target_pool" "igm-update" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "igm-test-%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
|
||||
resource "google_compute_instance_group_manager" "igm-update" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "igm-test-%s"
|
||||
instance_template = "${google_compute_instance_template.igm-update.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-update.self_link}"]
|
||||
base_instance_name = "igm-update"
|
||||
zone = "us-central1-c"
|
||||
target_size = 2
|
||||
}`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
||||
// Change IGM's instance template and target size
|
||||
var testAccInstanceGroupManager_update2 = fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-update" {
|
||||
name = "igm-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccInstanceGroupManager_update2(template1, target, template2, igm string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance_template" "igm-update" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
resource "google_compute_target_pool" "igm-update" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
resource "google_compute_instance_template" "igm-update2" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
resource "google_compute_instance_group_manager" "igm-update" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "%s"
|
||||
instance_template = "${google_compute_instance_template.igm-update2.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-update.self_link}"]
|
||||
base_instance_name = "igm-update"
|
||||
zone = "us-central1-c"
|
||||
target_size = 3
|
||||
}`, template1, target, template2, igm)
|
||||
}
|
||||
|
||||
resource "google_compute_target_pool" "igm-update" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "igm-test-%s"
|
||||
session_affinity = "CLIENT_IP_PROTO"
|
||||
}
|
||||
|
||||
resource "google_compute_instance_template" "igm-update2" {
|
||||
name = "igm-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
source_image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
auto_delete = true
|
||||
boot = true
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance_group_manager" "igm-update" {
|
||||
description = "Terraform test instance group manager"
|
||||
name = "igm-test-%s"
|
||||
instance_template = "${google_compute_instance_template.igm-update2.self_link}"
|
||||
target_pools = ["${google_compute_target_pool.igm-update.self_link}"]
|
||||
base_instance_name = "igm-update"
|
||||
zone = "us-central1-c"
|
||||
target_size = 3
|
||||
}`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
func TestAccComputeInstance_basic_deprecated_network(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -20,13 +21,13 @@ func TestAccComputeInstance_basic_deprecated_network(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic_deprecated_network,
|
||||
Config: testAccComputeInstance_basic_deprecated_network(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceTag(&instance, "foo"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "foo", "bar"),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -35,6 +36,7 @@ func TestAccComputeInstance_basic_deprecated_network(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_basic1(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -42,14 +44,14 @@ func TestAccComputeInstance_basic1(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic,
|
||||
Config: testAccComputeInstance_basic(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceTag(&instance, "foo"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "foo", "bar"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "baz", "qux"),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -58,6 +60,7 @@ func TestAccComputeInstance_basic1(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_basic2(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -65,13 +68,13 @@ func TestAccComputeInstance_basic2(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic2,
|
||||
Config: testAccComputeInstance_basic2(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceTag(&instance, "foo"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "foo", "bar"),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -80,6 +83,7 @@ func TestAccComputeInstance_basic2(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_basic3(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -87,13 +91,13 @@ func TestAccComputeInstance_basic3(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic3,
|
||||
Config: testAccComputeInstance_basic3(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceTag(&instance, "foo"),
|
||||
testAccCheckComputeInstanceMetadata(&instance, "foo", "bar"),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -102,6 +106,8 @@ func TestAccComputeInstance_basic3(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_IP(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var ipName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -109,7 +115,7 @@ func TestAccComputeInstance_IP(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_ip,
|
||||
Config: testAccComputeInstance_ip(ipName, instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -122,6 +128,8 @@ func TestAccComputeInstance_IP(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_disks(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
var diskName = fmt.Sprintf("instance-testd-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -129,12 +137,12 @@ func TestAccComputeInstance_disks(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_disks,
|
||||
Config: testAccComputeInstance_disks(diskName, instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test-disk", false, false),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, diskName, false, false),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -143,6 +151,7 @@ func TestAccComputeInstance_disks(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_local_ssd(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -150,11 +159,11 @@ func TestAccComputeInstance_local_ssd(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_local_ssd,
|
||||
Config: testAccComputeInstance_local_ssd(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.local-ssd", &instance),
|
||||
testAccCheckComputeInstanceDisk(&instance, "terraform-test", true, true),
|
||||
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -163,6 +172,7 @@ func TestAccComputeInstance_local_ssd(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_update_deprecated_network(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -170,14 +180,14 @@ func TestAccComputeInstance_update_deprecated_network(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic_deprecated_network,
|
||||
Config: testAccComputeInstance_basic_deprecated_network(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_update_deprecated_network,
|
||||
Config: testAccComputeInstance_update_deprecated_network(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -192,6 +202,7 @@ func TestAccComputeInstance_update_deprecated_network(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_forceNewAndChangeMetadata(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -199,14 +210,14 @@ func TestAccComputeInstance_forceNewAndChangeMetadata(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic,
|
||||
Config: testAccComputeInstance_basic(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_forceNewAndChangeMetadata,
|
||||
Config: testAccComputeInstance_forceNewAndChangeMetadata(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -220,6 +231,7 @@ func TestAccComputeInstance_forceNewAndChangeMetadata(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_update(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -227,14 +239,14 @@ func TestAccComputeInstance_update(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_basic,
|
||||
Config: testAccComputeInstance_basic(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_update,
|
||||
Config: testAccComputeInstance_update(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -250,6 +262,7 @@ func TestAccComputeInstance_update(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_service_account(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -257,7 +270,7 @@ func TestAccComputeInstance_service_account(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_service_account,
|
||||
Config: testAccComputeInstance_service_account(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -275,6 +288,7 @@ func TestAccComputeInstance_service_account(t *testing.T) {
|
|||
|
||||
func TestAccComputeInstance_scheduling(t *testing.T) {
|
||||
var instance compute.Instance
|
||||
var instanceName = fmt.Sprintf("instance-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -282,7 +296,7 @@ func TestAccComputeInstance_scheduling(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeInstance_scheduling,
|
||||
Config: testAccComputeInstance_scheduling(instanceName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeInstanceExists(
|
||||
"google_compute_instance.foobar", &instance),
|
||||
|
@ -437,276 +451,300 @@ func testAccCheckComputeInstanceServiceAccount(instance *compute.Instance, scope
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeInstance_basic_deprecated_network = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccComputeInstance_basic_deprecated_network(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network {
|
||||
source = "default"
|
||||
}
|
||||
network {
|
||||
source = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
var testAccComputeInstance_update_deprecated_network = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["baz"]
|
||||
func testAccComputeInstance_update_deprecated_network(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["baz"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network {
|
||||
source = "default"
|
||||
}
|
||||
network {
|
||||
source = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
var testAccComputeInstance_basic = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccComputeInstance_basic(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
baz = "qux"
|
||||
}
|
||||
metadata {
|
||||
foo = "bar"
|
||||
baz = "qux"
|
||||
}
|
||||
|
||||
metadata_startup_script = "echo Hello"
|
||||
}`, acctest.RandString(10))
|
||||
metadata_startup_script = "echo Hello"
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
var testAccComputeInstance_basic2 = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccComputeInstance_basic2(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "debian-cloud/debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
var testAccComputeInstance_basic3 = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
func testAccComputeInstance_basic3(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
can_ip_forward = false
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
// Update zone to ForceNew, and change metadata k/v entirely
|
||||
// Generates diff mismatch
|
||||
var testAccComputeInstance_forceNewAndChangeMetadata = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
zone = "us-central1-b"
|
||||
tags = ["baz"]
|
||||
func testAccComputeInstance_forceNewAndChangeMetadata(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
zone = "us-central1-b"
|
||||
tags = ["baz"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config { }
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config { }
|
||||
}
|
||||
|
||||
metadata {
|
||||
qux = "true"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
metadata {
|
||||
qux = "true"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
// Update metadata, tags, and network_interface
|
||||
var testAccComputeInstance_update = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["baz"]
|
||||
func testAccComputeInstance_update(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["baz"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config { }
|
||||
}
|
||||
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
|
||||
var testAccComputeInstance_ip = fmt.Sprintf(`
|
||||
resource "google_compute_address" "foo" {
|
||||
name = "instance-test-%s"
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config {
|
||||
nat_ip = "${google_compute_address.foo.address}"
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, acctest.RandString(10), acctest.RandString(10))
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config { }
|
||||
}
|
||||
|
||||
var testAccComputeInstance_disks = fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
size = 10
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
func testAccComputeInstance_ip(ip, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_address" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
|
||||
disk {
|
||||
disk = "${google_compute_disk.foobar.name}"
|
||||
auto_delete = false
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
tags = ["foo", "bar"]
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
access_config {
|
||||
nat_ip = "${google_compute_address.foo.address}"
|
||||
}
|
||||
}
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, ip, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_disks(disk, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
size = 10
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, acctest.RandString(10), acctest.RandString(10))
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
var testAccComputeInstance_local_ssd = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "local-ssd" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
disk {
|
||||
disk = "${google_compute_disk.foobar.name}"
|
||||
auto_delete = false
|
||||
}
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
disk {
|
||||
type = "local-ssd"
|
||||
scratch = true
|
||||
}
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, disk, instance)
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
func testAccComputeInstance_local_ssd(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "local-ssd" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
}`, acctest.RandString(10))
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
var testAccComputeInstance_service_account = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
disk {
|
||||
type = "local-ssd"
|
||||
scratch = true
|
||||
}
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
service_account {
|
||||
scopes = [
|
||||
"userinfo-email",
|
||||
"compute-ro",
|
||||
"storage-ro",
|
||||
]
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
func testAccComputeInstance_service_account(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
var testAccComputeInstance_scheduling = fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "instance-test-%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
service_account {
|
||||
scopes = [
|
||||
"userinfo-email",
|
||||
"compute-ro",
|
||||
"storage-ro",
|
||||
]
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
||||
scheduling {
|
||||
}
|
||||
}`, acctest.RandString(10))
|
||||
func testAccComputeInstance_scheduling(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
disk {
|
||||
image = "debian-7-wheezy-v20140814"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
scheduling {
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeTargetHttpProxy_basic(t *testing.T) {
|
||||
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) },
|
||||
|
@ -17,7 +22,7 @@ func TestAccComputeTargetHttpProxy_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeTargetHttpProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeTargetHttpProxy_basic1,
|
||||
Config: testAccComputeTargetHttpProxy_basic1(target, backend, hc, urlmap1, urlmap2),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeTargetHttpProxyExists(
|
||||
"google_compute_target_http_proxy.foobar"),
|
||||
|
@ -28,6 +33,11 @@ func TestAccComputeTargetHttpProxy_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccComputeTargetHttpProxy_update(t *testing.T) {
|
||||
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) },
|
||||
|
@ -35,7 +45,7 @@ func TestAccComputeTargetHttpProxy_update(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeTargetHttpProxyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeTargetHttpProxy_basic1,
|
||||
Config: testAccComputeTargetHttpProxy_basic1(target, backend, hc, urlmap1, urlmap2),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeTargetHttpProxyExists(
|
||||
"google_compute_target_http_proxy.foobar"),
|
||||
|
@ -43,7 +53,7 @@ func TestAccComputeTargetHttpProxy_update(t *testing.T) {
|
|||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccComputeTargetHttpProxy_basic2,
|
||||
Config: testAccComputeTargetHttpProxy_basic2(target, backend, hc, urlmap1, urlmap2),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeTargetHttpProxyExists(
|
||||
"google_compute_target_http_proxy.foobar"),
|
||||
|
@ -98,130 +108,134 @@ func testAccCheckComputeTargetHttpProxyExists(n string) resource.TestCheckFunc {
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeTargetHttpProxy_basic1 = fmt.Sprintf(`
|
||||
resource "google_compute_target_http_proxy" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "httpproxy-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar1.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "httpproxy-test-%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "httpproxy-test-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar1" {
|
||||
name = "httpproxy-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
func testAccComputeTargetHttpProxy_basic1(target, backend, hc, urlmap1, urlmap2 string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_http_proxy" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar1.self_link}"
|
||||
}
|
||||
path_matcher {
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar1" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar2" {
|
||||
name = "httpproxy-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
resource "google_compute_url_map" "foobar2" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
`, target, backend, hc, urlmap1, urlmap2)
|
||||
}
|
||||
|
||||
func testAccComputeTargetHttpProxy_basic2(target, backend, hc, urlmap1, urlmap2 string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_target_http_proxy" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar2.self_link}"
|
||||
}
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
||||
var testAccComputeTargetHttpProxy_basic2 = fmt.Sprintf(`
|
||||
resource "google_compute_target_http_proxy" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "httpproxy-test-%s"
|
||||
url_map = "${google_compute_url_map.foobar2.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "httpproxy-test-%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "httpproxy-test-%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar1" {
|
||||
name = "httpproxy-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
path_matcher {
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar1" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar2" {
|
||||
name = "httpproxy-test-%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
resource "google_compute_url_map" "foobar2" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
`, target, backend, hc, urlmap1, urlmap2)
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
|
||||
|
|
|
@ -10,16 +10,17 @@ import (
|
|||
)
|
||||
|
||||
func TestAccDnsRecordSet_basic(t *testing.T) {
|
||||
zoneName := fmt.Sprintf("dnszone-test-%s", acctest.RandString(10))
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDnsRecordSetDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccDnsRecordSet_basic,
|
||||
Config: testAccDnsRecordSet_basic(zoneName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDnsRecordSetExists(
|
||||
"google_dns_record_set.foobar"),
|
||||
"google_dns_record_set.foobar", zoneName),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -43,11 +44,11 @@ func testAccCheckDnsRecordSetDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckDnsRecordSetExists(name string) resource.TestCheckFunc {
|
||||
func testAccCheckDnsRecordSetExists(resourceType, resourceName string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[name]
|
||||
rs, ok := s.RootModule().Resources[resourceType]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
return fmt.Errorf("Not found: %s", resourceName)
|
||||
}
|
||||
|
||||
dnsName := rs.Primary.Attributes["name"]
|
||||
|
@ -60,7 +61,7 @@ func testAccCheckDnsRecordSetExists(name string) resource.TestCheckFunc {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
resp, err := config.clientDns.ResourceRecordSets.List(
|
||||
config.Project, "terraform-test-zone").Name(dnsName).Type(dnsType).Do()
|
||||
config.Project, resourceName).Name(dnsName).Type(dnsType).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error confirming DNS RecordSet existence: %#v", err)
|
||||
}
|
||||
|
@ -77,17 +78,19 @@ func testAccCheckDnsRecordSetExists(name string) resource.TestCheckFunc {
|
|||
}
|
||||
}
|
||||
|
||||
var testAccDnsRecordSet_basic = fmt.Sprintf(`
|
||||
resource "google_dns_managed_zone" "parent-zone" {
|
||||
name = "dnsrecord-test-%s"
|
||||
dns_name = "terraform.test."
|
||||
description = "Test Description"
|
||||
func testAccDnsRecordSet_basic(zoneName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_dns_managed_zone" "parent-zone" {
|
||||
name = "%s"
|
||||
dns_name = "terraform.test."
|
||||
description = "Test Description"
|
||||
}
|
||||
resource "google_dns_record_set" "foobar" {
|
||||
managed_zone = "${google_dns_managed_zone.parent-zone.name}"
|
||||
name = "test-record.terraform.test."
|
||||
type = "A"
|
||||
rrdatas = ["127.0.0.1", "127.0.0.10"]
|
||||
ttl = 600
|
||||
}
|
||||
`, zoneName)
|
||||
}
|
||||
resource "google_dns_record_set" "foobar" {
|
||||
managed_zone = "${google_dns_managed_zone.parent-zone.name}"
|
||||
name = "test-record.terraform.test."
|
||||
type = "A"
|
||||
rrdatas = ["127.0.0.1", "127.0.0.10"]
|
||||
ttl = 600
|
||||
}
|
||||
`, acctest.RandString(10))
|
||||
|
|
|
@ -101,7 +101,7 @@ func testAccGoogleSqlDatabaseDestroy(s *terraform.State) error {
|
|||
|
||||
var testGoogleSqlDatabase_basic = fmt.Sprintf(`
|
||||
resource "google_sql_database_instance" "instance" {
|
||||
name = "sqldatabase-test-%s"
|
||||
name = "sqldatabasetest%s"
|
||||
region = "us-central"
|
||||
settings {
|
||||
tier = "D0"
|
||||
|
@ -109,7 +109,7 @@ resource "google_sql_database_instance" "instance" {
|
|||
}
|
||||
|
||||
resource "google_sql_database" "database" {
|
||||
name = "sqldatabase-test-%s"
|
||||
name = "sqldatabasetest%s"
|
||||
instance = "${google_sql_database_instance.instance.name}"
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10))
|
||||
|
|
Loading…
Reference in New Issue