Merge import test in regular acceptance tests for a few compute resources (#874)

This commit is contained in:
Vincent Roseberry 2017-12-19 12:43:30 -08:00 committed by GitHub
parent 98a642f354
commit bc03e98998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 125 additions and 352 deletions

View File

@ -1,69 +0,0 @@
package google
import (
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeAddress_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_address.foobar"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeAddressDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeAddress_basic(acctest.RandString(10)),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
/* Disabled pending support for importing beta resources. See:
https://github.com/terraform-providers/terraform-provider-google/issues/694
func testAccComputeAddress_importInternal(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeAddressDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeAddress_internal(acctest.RandString(10)),
},
resource.TestStep{
ResourceName: "google_compute_address.internal",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
ResourceName: "google_compute_address.internal_with_subnet",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
ResourceName: "google_compute_address.internal_with_subnet_and_address",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
*/

View File

@ -1,37 +0,0 @@
package google
import (
"testing"
"fmt"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeAutoscaler_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_autoscaler.foobar"
var it_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
var tp_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
var igm_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
var autoscaler_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeAutoscalerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeAutoscaler_basic(it_name, tp_name, igm_name, autoscaler_name),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -1,31 +0,0 @@
package google
import (
"fmt"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"testing"
)
func TestAccComputeBackendBucket_import(t *testing.T) {
t.Parallel()
backendName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
storageName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendBucketDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeBackendBucket_basic(backendName, storageName),
},
resource.TestStep{
ResourceName: "google_compute_backend_bucket.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -1,33 +0,0 @@
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeDisk_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_disk.foobar"
diskName := fmt.Sprintf("disk-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeDiskDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeDisk_basic(diskName),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -1,34 +0,0 @@
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeFirewall_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_firewall.foobar"
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) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeFirewallDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeFirewall_basic(networkName, firewallName),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -1,34 +0,0 @@
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeForwardingRule_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_forwarding_rule.foobar"
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeForwardingRuleDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeForwardingRule_basic(poolName, ruleName),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -1,34 +0,0 @@
package google
import (
"fmt"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"testing"
)
func TestAccComputeGlobalForwardingRule_import(t *testing.T) {
t.Parallel()
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(fr, proxy1, proxy2, backend, hc, urlmap),
},
resource.TestStep{
ResourceName: "google_compute_global_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
}})
}

View File

@ -1,71 +0,0 @@
package google
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccComputeNetwork_importBasic(t *testing.T) {
t.Parallel()
resourceName := "google_compute_network.foobar"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeNetworkDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_basic(),
}, {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
//ImportStateVerifyIgnore: []string{"ipv4_range", "name"},
},
},
})
}
func TestAccComputeNetwork_importAuto_subnet(t *testing.T) {
t.Parallel()
resourceName := "google_compute_network.bar"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeNetworkDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_auto_subnet(),
}, {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func TestAccComputeNetwork_importCustom_subnet(t *testing.T) {
t.Parallel()
resourceName := "google_compute_network.baz"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeNetworkDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_custom_subnet(),
}, {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -92,6 +92,11 @@ func TestAccComputeAddress_basic(t *testing.T) {
"google_compute_address.foobar", &addr),
),
},
resource.TestStep{
ResourceName: "google_compute_address.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -116,6 +121,23 @@ func TestAccComputeAddress_internal(t *testing.T) {
resource.TestCheckResourceAttr("google_compute_address.internal_with_subnet_and_address", "address", "10.0.42.42"),
),
},
resource.TestStep{
ResourceName: "google_compute_address.internal",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
ResourceName: "google_compute_address.internal_with_subnet",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
ResourceName: "google_compute_address.internal_with_subnet_and_address",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -32,6 +32,12 @@ func TestAccComputeAutoscaler_basic(t *testing.T) {
"google_compute_autoscaler.foobar", &ascaler),
),
},
resource.TestStep{
ResourceName: "google_compute_autoscaler.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -29,6 +29,11 @@ func TestAccComputeBackendBucket_basic(t *testing.T) {
"google_compute_backend_bucket.foobar", &svc),
),
},
resource.TestStep{
ResourceName: "google_compute_backend_bucket.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})

View File

@ -32,6 +32,11 @@ func TestAccComputeDisk_basic(t *testing.T) {
testAccCheckComputeDiskHasLabelFingerprint(&disk, "google_compute_disk.foobar"),
),
},
resource.TestStep{
ResourceName: "google_compute_disk.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -34,6 +34,11 @@ func TestAccComputeFirewall_basic(t *testing.T) {
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
resource.TestStep{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -83,15 +88,22 @@ func TestAccComputeFirewall_priority(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeFirewallDestroy,
Steps: []resource.TestStep{{
Config: testAccComputeFirewall_priority(networkName, firewallName, 1001),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeFirewallExists(
"google_compute_firewall.foobar", &firewall),
testAccCheckComputeFirewallHasPriority(&firewall, 1001),
testAccCheckComputeFirewallApiVersion(&firewall),
),
}},
Steps: []resource.TestStep{
{
Config: testAccComputeFirewall_priority(networkName, firewallName, 1001),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeFirewallExists(
"google_compute_firewall.foobar", &firewall),
testAccCheckComputeFirewallHasPriority(&firewall, 1001),
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -115,6 +127,11 @@ func TestAccComputeFirewall_noSource(t *testing.T) {
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
resource.TestStep{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -139,6 +156,11 @@ func TestAccComputeFirewall_denied(t *testing.T) {
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
resource.TestStep{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -163,6 +185,11 @@ func TestAccComputeFirewall_egress(t *testing.T) {
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
resource.TestStep{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -193,6 +220,11 @@ func TestAccComputeFirewall_serviceAccounts(t *testing.T) {
testAccCheckComputeFirewallApiVersion(&firewall),
),
},
resource.TestStep{
ResourceName: "google_compute_firewall.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -27,6 +27,12 @@ func TestAccComputeForwardingRule_basic(t *testing.T) {
"google_compute_forwarding_rule.foobar"),
),
},
resource.TestStep{
ResourceName: "google_compute_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -49,6 +55,11 @@ func TestAccComputeForwardingRule_singlePort(t *testing.T) {
"google_compute_forwarding_rule.foobar"),
),
},
resource.TestStep{
ResourceName: "google_compute_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -72,6 +83,11 @@ func TestAccComputeForwardingRule_ip(t *testing.T) {
"google_compute_forwarding_rule.foobar"),
),
},
resource.TestStep{
ResourceName: "google_compute_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -99,6 +115,11 @@ func TestAccComputeForwardingRule_internalLoadBalancing(t *testing.T) {
"google_compute_forwarding_rule.foobar2"),
),
},
resource.TestStep{
ResourceName: "google_compute_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -36,6 +36,11 @@ func TestAccComputeGlobalForwardingRule_basic(t *testing.T) {
testAccCheckComputeBetaGlobalForwardingRuleIpVersion("google_compute_global_forwarding_rule.foobar", ""),
),
},
resource.TestStep{
ResourceName: "google_compute_global_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -99,6 +104,11 @@ func TestAccComputeGlobalForwardingRule_ipv6(t *testing.T) {
testAccCheckComputeBetaGlobalForwardingRuleIpVersion("google_compute_global_forwarding_rule.foobar", "IPV6"),
),
},
resource.TestStep{
ResourceName: "google_compute_global_forwarding_rule.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -27,6 +27,11 @@ func TestAccComputeNetwork_basic(t *testing.T) {
"google_compute_network.foobar", &network),
),
},
resource.TestStep{
ResourceName: "google_compute_network.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -50,6 +55,11 @@ func TestAccComputeNetwork_auto_subnet(t *testing.T) {
"google_compute_network.bar", &network),
),
},
resource.TestStep{
ResourceName: "google_compute_network.bar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -73,6 +83,11 @@ func TestAccComputeNetwork_custom_subnet(t *testing.T) {
"google_compute_network.baz", &network),
),
},
resource.TestStep{
ResourceName: "google_compute_network.baz",
ImportState: true,
ImportStateVerify: true,
},
},
})
}