Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more VCR tests #3531

Merged
merged 7 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
- !ruby/object:Provider::Terraform::Examples
name: "instance_group_named_port_gke"
primary_resource_id: "my_port"
# Multiple fine-grained resources
skip_vcr: true
vars:
network_name: "container-network"
subnetwork_name: "container-subnetwork"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestAccDataSourceMonitoringService_AppEngine(t *testing.T) {
resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestAccKmsSecret_basic(t *testing.T) {
// Nested tests confuse VCR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you file an issue to fix this?

skipIfVcr(t)
t.Parallel()

projectOrg := getTestOrgFromEnv(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func TestAccStorageSignedUrl_basic(t *testing.T) {
}

func TestAccStorageSignedUrl_accTest(t *testing.T) {
// URL includes an expires time
skipIfVcr(t)
t.Parallel()

bucketName := fmt.Sprintf("tf-test-bucket-%d", randInt(t))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func TestAccInstanceGroupManager_stateful(t *testing.T) {
igm := fmt.Sprintf("igm-test-%s", randString(t, 10))
hck := fmt.Sprintf("igm-test-%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckInstanceGroupManagerDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"regexp"
"sort"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -1849,7 +1850,7 @@ func TestAccComputeInstance_resourcePolicyCollocate(t *testing.T) {

instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
Expand Down Expand Up @@ -2866,6 +2867,7 @@ func testAccComputeInstance_disks_encryption(bootEncryptionKey string, diskNameT
for k := range diskNameToEncryptionKey {
diskNames = append(diskNames, k)
}
sort.Strings(diskNames)
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func TestAccRegionInstanceGroupManager_stateful(t *testing.T) {
template := fmt.Sprintf("igm-test-%s", randString(t, 10))
igm := fmt.Sprintf("igm-test-%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRegionInstanceGroupManagerDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestAccComputeResourcePolicy_attached(t *testing.T) {
t.Parallel()

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeResourcePolicyDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func TestAccDialogflowEntityType_update(t *testing.T) {
context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"billing_account": getTestBillingAccountFromEnv(t),
"random_suffix": acctest.RandString(10),
"random_suffix": randString(t, 10),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccDialogflowIntent_basic(t *testing.T) {
"random_suffix": randString(t, 10),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand All @@ -42,7 +42,7 @@ func TestAccDialogflowIntent_update(t *testing.T) {
"random_suffix": randString(t, 10),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccFirebaseWebApp_firebaseWebAppFull(t *testing.T) {
"display_name": "Display Name N",
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func TestAccFolderIamBinding_basic(t *testing.T) {

// Test that multiple IAM bindings can be applied to a folder, one at a time
func TestAccFolderIamBinding_multiple(t *testing.T) {
// Multiple fine-grained resources
skipIfVcr(t)
t.Parallel()

org := getTestOrgFromEnv(t)
Expand Down
2 changes: 2 additions & 0 deletions third_party/terraform/tests/resource_kms_crypto_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func TestAccKmsCryptoKey_basic(t *testing.T) {
}

func TestAccKmsCryptoKey_rotation(t *testing.T) {
// when rotation is set, next rotation time is set using time.Now
skipIfVcr(t)
t.Parallel()

projectId := fmt.Sprintf("tf-test-%d", randInt(t))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAccLoggingBucketConfigFolder_basic(t *testing.T) {
"org_id": getTestOrgFromEnv(t),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestAccLoggingBucketConfigProject_basic(t *testing.T) {
"org_id": getTestOrgFromEnv(t),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestAccLoggingBucketConfigBillingAccount_basic(t *testing.T) {
"org_id": getTestOrgFromEnv(t),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestAccLoggingBucketConfigOrganization_basic(t *testing.T) {
"org_id": getTestOrgFromEnv(t),
}

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down
12 changes: 6 additions & 6 deletions third_party/terraform/tests/resource_monitoring_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAccMonitoringSlo_basic(t *testing.T) {
t.Parallel()

var generatedId string
resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestAccMonitoringSlo_requestBased(t *testing.T) {

randomSuffix := randString(t, 10)

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestAccMonitoringSlo_windowBased_updateSlis(t *testing.T) {

randomSuffix := randString(t, 10)

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestAccMonitoringSlo_windowBasedGoodTotalRatioThresholdSlis(t *testing.T) {

randomSuffix := randString(t, 10)

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestAccMonitoringSlo_windowBasedMetricMeanRangeSlis(t *testing.T) {

randomSuffix := randString(t, 10)

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down Expand Up @@ -331,7 +331,7 @@ func TestAccMonitoringSlo_windowBasedMetricSumRangeSlis(t *testing.T) {

randomSuffix := randString(t, 10)

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitoringSloDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func TestAccServiceDirectoryEndpoint_serviceDirectoryEndpointUpdateExample(t *te

project := getTestProjectFromEnv()
location := "us-central1"
testId := fmt.Sprintf("tf-test-example-endpoint%s", acctest.RandString(10))
testId := fmt.Sprintf("tf-test-example-endpoint%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceDirectoryEndpointDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestAccServiceDirectoryNamespace_serviceDirectoryNamespaceUpdateExample(t *
location := "us-central1"
testId := fmt.Sprintf("tf-test-example-namespace%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceDirectoryNamespaceDestroyProducer(t),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccServiceDirectoryService_serviceDirectoryServiceUpdateExample(t *test
location := "us-central1"
testId := fmt.Sprintf("tf-test-example-service%s", randString(t, 10))

resource.Test(t, resource.TestCase{
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceDirectoryServiceDestroyProducer(t),
Expand Down
2 changes: 2 additions & 0 deletions third_party/terraform/tests/resource_storage_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ func TestAccStorageBucket_defaultEventBasedHold(t *testing.T) {
}

func TestAccStorageBucket_encryption(t *testing.T) {
// when rotation is set, next rotation time is set using time.Now
skipIfVcr(t)
t.Parallel()

context := map[string]interface{}{
Expand Down
4 changes: 4 additions & 0 deletions third_party/terraform/utils/provider_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ func TestAccProviderBasePath_setInvalidBasePath(t *testing.T) {
}

func TestAccProviderUserProjectOverride(t *testing.T) {
// Parallel fine-grained resource creation
skipIfVcr(t)
t.Parallel()

org := getTestOrgFromEnv(t)
Expand Down Expand Up @@ -536,6 +538,8 @@ func TestAccProviderUserProjectOverride(t *testing.T) {
// Do the same thing as TestAccProviderUserProjectOverride, but using a resource that gets its project via
// a reference to a different resource instead of a project field.
func TestAccProviderIndirectUserProjectOverride(t *testing.T) {
// Parallel fine-grained resource creation
skipIfVcr(t)
t.Parallel()

org := getTestOrgFromEnv(t)
Expand Down