From a8d980923411d8b451fcc18b8fe714644a2256e5 Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Mon, 10 Aug 2020 15:17:47 -0400 Subject: [PATCH] terraform-bundle: re-enable e2e tests (#25516) --- tools/terraform-bundle/config.go | 1 + .../terraform-bundle/e2etest/package_test.go | 28 ++++++------------- .../local-providers/terraform-bundle.hcl | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/terraform-bundle/config.go b/tools/terraform-bundle/config.go index 39f766c6a..20dd61a3a 100644 --- a/tools/terraform-bundle/config.go +++ b/tools/terraform-bundle/config.go @@ -56,6 +56,7 @@ func (c *Config) validate() error { if v, err = c.Terraform.Version.Parse(); err != nil { return fmt.Errorf("terraform.version: %s", err) } + if !zeroThirteen.Allows(v) { return fmt.Errorf("this version of terraform-bundle can only build bundles for Terraform v0.13 and later; build terraform-bundle from a release tag (such as v0.12.*) to construct bundles for earlier versions") } diff --git a/tools/terraform-bundle/e2etest/package_test.go b/tools/terraform-bundle/e2etest/package_test.go index b9d62746f..08ea378d2 100644 --- a/tools/terraform-bundle/e2etest/package_test.go +++ b/tools/terraform-bundle/e2etest/package_test.go @@ -14,10 +14,6 @@ import ( func TestPackage_empty(t *testing.T) { t.Parallel() - // The e2etests can be reenabled when there is a terraform v0.13* release - // available on releases.hashicorp.com. - t.Skip("terraform-bundle e2e tests are temporarily paused") - // This test reaches out to releases.hashicorp.com to download the // template provider, so it can only run if network access is allowed. // We intentionally don't try to stub this here, because there's already @@ -38,10 +34,10 @@ func TestPackage_empty(t *testing.T) { t.Errorf("unexpected stderr output:\n%s", stderr) } - if !strings.Contains(stdout, "Fetching Terraform 0.12.0 core package...") { + if !strings.Contains(stdout, "Fetching Terraform 0.13.0 core package...") { t.Errorf("success message is missing from output:\n%s", stdout) } - if !strings.Contains(stdout, "Creating terraform_0.12.0-bundle") { + if !strings.Contains(stdout, "Creating terraform_0.13.0-bundle") { t.Errorf("success message is missing from output:\n%s", stdout) } if !strings.Contains(stdout, "All done!") { @@ -52,10 +48,6 @@ func TestPackage_empty(t *testing.T) { func TestPackage_manyProviders(t *testing.T) { t.Parallel() - // The e2etests can be reenabled when there is a terraform v0.13* release - // available on releases.hashicorp.com. - t.Skip("terraform-bundle e2e tests are temporarily paused") - // This test reaches out to releases.hashicorp.com to download providers, so // it can only run if network access is allowed. We intentionally don't try // to stub this here, because there's already a stubbed version of this in @@ -98,10 +90,10 @@ func TestPackage_manyProviders(t *testing.T) { t.Errorf("success message is missing from output:\n%s", stdout) } - if !strings.Contains(stdout, "Fetching Terraform 0.12.0 core package...") { + if !strings.Contains(stdout, "Fetching Terraform 0.13.0 core package...") { t.Errorf("success message is missing from output:\n%s", stdout) } - if !strings.Contains(stdout, "Creating terraform_0.12.0-bundle") { + if !strings.Contains(stdout, "Creating terraform_0.13.0-bundle") { t.Errorf("success message is missing from output:\n%s", stdout) } if !strings.Contains(stdout, "All done!") { @@ -114,7 +106,7 @@ func TestPackage_manyProviders(t *testing.T) { t.Fatalf("error reading workdir: %s", err) } for _, file := range files { - if strings.Contains(file.Name(), "terraform_0.12.0-bundle") { + if strings.Contains(file.Name(), "terraform_0.13.0-bundle") { read, err := zip.OpenReader(filepath.Join(tfBundle.WorkDir(), file.Name())) if err != nil { t.Fatalf("Failed to open archive: %s", err) @@ -151,10 +143,6 @@ func TestPackage_manyProviders(t *testing.T) { func TestPackage_localProviders(t *testing.T) { t.Parallel() - // The e2etests can be reenabled when there is a terraform v0.13* release - // available on releases.hashicorp.com. - t.Skip("terraform-bundle e2e tests are temporarily paused") - // This test reaches out to releases.hashicorp.com to download terrafrom, so // it can only run if network access is allowed. The providers are installed // from the local cache. @@ -176,10 +164,10 @@ func TestPackage_localProviders(t *testing.T) { // Here we have to check each provider separately // because it's internally held in a map (i.e. not guaranteed order) - if !strings.Contains(stdout, "Fetching Terraform 0.12.0 core package...") { + if !strings.Contains(stdout, "Fetching Terraform 0.13.0 core package...") { t.Errorf("success message is missing from output:\n%s", stdout) } - if !strings.Contains(stdout, "Creating terraform_0.12.0-bundle") { + if !strings.Contains(stdout, "Creating terraform_0.13.0-bundle") { t.Errorf("success message is missing from output:\n%s", stdout) } if !strings.Contains(stdout, "All done!") { @@ -192,7 +180,7 @@ func TestPackage_localProviders(t *testing.T) { t.Fatalf("error reading workdir: %s", err) } for _, file := range files { - if strings.Contains(file.Name(), "terraform_0.12.0-bundle") { + if strings.Contains(file.Name(), "terraform_0.13.0-bundle") { read, err := zip.OpenReader(filepath.Join(tfBundle.WorkDir(), file.Name())) if err != nil { t.Fatalf("Failed to open archive: %s", err) diff --git a/tools/terraform-bundle/e2etest/testdata/local-providers/terraform-bundle.hcl b/tools/terraform-bundle/e2etest/testdata/local-providers/terraform-bundle.hcl index 2d4e070cf..fd55f6777 100644 --- a/tools/terraform-bundle/e2etest/testdata/local-providers/terraform-bundle.hcl +++ b/tools/terraform-bundle/e2etest/testdata/local-providers/terraform-bundle.hcl @@ -1,5 +1,5 @@ terraform { - version = "0.3.0" + version = "0.13.0" } providers {