Merge pull request #22918 from hashicorp/mildwonkey/to-e2e-or-not-e2e

Sundry fixes to e2e tests
This commit is contained in:
Kristin Laemmert 2019-09-27 08:46:04 -04:00 committed by GitHub
commit 006ef022e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"reflect"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -45,6 +46,9 @@ func prepareEtcdv3(t *testing.T) {
t.Log("etcd server tests require setting TF_ACC or TF_ETCDV3_TEST") t.Log("etcd server tests require setting TF_ACC or TF_ETCDV3_TEST")
t.Skip() t.Skip()
} }
if reflect.DeepEqual(etcdv3Endpoints, []string{""}) {
t.Fatal("etcd server tests require setting TF_ETCDV3_ENDPOINTS")
}
cleanupEtcdv3(t) cleanupEtcdv3(t)
} }

View File

@ -53,7 +53,7 @@ func New() backend.Backend {
"insecure_skip_tls_verify": { "insecure_skip_tls_verify": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("TRITON_SKIP_TLS_VERIFY", ""), DefaultFunc: schema.EnvDefaultFunc("TRITON_SKIP_TLS_VERIFY", false),
}, },
"path": { "path": {

View File

@ -18,6 +18,14 @@ func testACC(t *testing.T) {
t.Log("Manta backend tests require setting TF_ACC or TF_MANTA_TEST") t.Log("Manta backend tests require setting TF_ACC or TF_MANTA_TEST")
t.Skip() t.Skip()
} }
skip = os.Getenv("TRITON_ACCOUNT") == "" && os.Getenv("SDC_ACCOUNT") == ""
if skip {
t.Fatal("Manta backend tests require setting TRITON_ACCOUNT or SDC_ACCOUNT")
}
skip = os.Getenv("TRITON_KEY_ID") == "" && os.Getenv("SDC_KEY_ID") == ""
if skip {
t.Fatal("Manta backend tests require setting TRITON_KEY_ID or SDC_KEY_ID")
}
} }
func TestBackend_impl(t *testing.T) { func TestBackend_impl(t *testing.T) {

View File

@ -6,11 +6,12 @@ import (
"testing" "testing"
"time" "time"
"strings"
"github.com/aliyun/aliyun-oss-go-sdk/oss" "github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/aliyun/aliyun-tablestore-go-sdk/tablestore" "github.com/aliyun/aliyun-tablestore-go-sdk/tablestore"
"github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/configs/hcl2shim" "github.com/hashicorp/terraform/configs/hcl2shim"
"strings"
) )
// verify that we are doing ACC tests or the OSS tests specifically // verify that we are doing ACC tests or the OSS tests specifically
@ -20,6 +21,9 @@ func testACC(t *testing.T) {
t.Log("oss backend tests require setting TF_ACC or TF_OSS_TEST") t.Log("oss backend tests require setting TF_ACC or TF_OSS_TEST")
t.Skip() t.Skip()
} }
if skip {
t.Fatal("oss backend tests require setting ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID")
}
if os.Getenv("ALICLOUD_REGION") == "" { if os.Getenv("ALICLOUD_REGION") == "" {
os.Setenv("ALICLOUD_REGION", "cn-beijing") os.Setenv("ALICLOUD_REGION", "cn-beijing")
} }

View File

@ -19,7 +19,16 @@ func TestDirFromModule_registry(t *testing.T) {
} }
fixtureDir := filepath.Clean("testdata/empty") fixtureDir := filepath.Clean("testdata/empty")
dir, done := tempChdir(t, fixtureDir) tmpDir, done := tempChdir(t, fixtureDir)
// the module installer runs filepath.EvalSymlinks() on the destination
// directory before copying files, and the resultant directory is what is
// returned by the install hooks. Without this, tests could fail on machines
// where the default temp dir was a symlink.
dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil {
t.Error(err)
}
modsDir := filepath.Join(dir, ".terraform/modules") modsDir := filepath.Join(dir, ".terraform/modules")
defer done() defer done()

View File

@ -232,7 +232,16 @@ func TestLoaderInstallModules_registry(t *testing.T) {
} }
fixtureDir := filepath.Clean("testdata/registry-modules") fixtureDir := filepath.Clean("testdata/registry-modules")
dir, done := tempChdir(t, fixtureDir) tmpDir, done := tempChdir(t, fixtureDir)
// the module installer runs filepath.EvalSymlinks() on the destination
// directory before copying files, and the resultant directory is what is
// returned by the install hooks. Without this, tests could fail on machines
// where the default temp dir was a symlink.
dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil {
t.Error(err)
}
defer done() defer done()
hooks := &testInstallHooks{} hooks := &testInstallHooks{}
@ -359,7 +368,15 @@ func TestLoaderInstallModules_goGetter(t *testing.T) {
} }
fixtureDir := filepath.Clean("testdata/go-getter-modules") fixtureDir := filepath.Clean("testdata/go-getter-modules")
dir, done := tempChdir(t, fixtureDir) tmpDir, done := tempChdir(t, fixtureDir)
// the module installer runs filepath.EvalSymlinks() on the destination
// directory before copying files, and the resultant directory is what is
// returned by the install hooks. Without this, tests could fail on machines
// where the default temp dir was a symlink.
dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil {
t.Error(err)
}
defer done() defer done()
hooks := &testInstallHooks{} hooks := &testInstallHooks{}

View File

@ -31,10 +31,10 @@ func TestPackage_empty(t *testing.T) {
t.Errorf("unexpected stderr output:\n%s", stderr) t.Errorf("unexpected stderr output:\n%s", stderr)
} }
if !strings.Contains(stdout, "Fetching Terraform 0.10.1 core package...") { if !strings.Contains(stdout, "Fetching Terraform 0.12.0 core package...") {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, "Creating terraform_0.10.1-bundle") { if !strings.Contains(stdout, "Creating terraform_0.12.0-bundle") {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, "All done!") { if !strings.Contains(stdout, "All done!") {
@ -65,36 +65,37 @@ func TestPackage_manyProviders(t *testing.T) {
t.Errorf("unexpected stderr output:\n%s", stderr) t.Errorf("unexpected stderr output:\n%s", stderr)
} }
if !strings.Contains(stdout, "Checking for available provider plugins on ") {
t.Errorf("success message is missing from output:\n%s", stdout)
}
// Here we have to check each provider separately // Here we have to check each provider separately
// because it's internally held in a map (i.e. not guaranteed order) // because it's internally held in a map (i.e. not guaranteed order)
if !strings.Contains(stdout, `- Resolving "aws" provider (~> 0.1)... if !strings.Contains(stdout, `- Resolving "aws" provider (~> 2.26.0)...
- Downloading plugin for provider "aws" (0.1.4)...`) { - Checking for provider plugin on https://releases.hashicorp.com...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.26.0...`) {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, `- Resolving "kubernetes" provider (0.1.0)... if !strings.Contains(stdout, `- Resolving "kubernetes" provider (1.8.0)...
- Downloading plugin for provider "kubernetes" (0.1.0)... - Checking for provider plugin on https://releases.hashicorp.com...
- Resolving "kubernetes" provider (0.1.1)... - Downloading plugin for provider "kubernetes" (hashicorp/kubernetes) 1.8.0...
- Downloading plugin for provider "kubernetes" (0.1.1)... - Resolving "kubernetes" provider (1.8.1)...
- Resolving "kubernetes" provider (0.1.2)... - Checking for provider plugin on https://releases.hashicorp.com...
- Downloading plugin for provider "kubernetes" (0.1.2)...`) { - Downloading plugin for provider "kubernetes" (hashicorp/kubernetes) 1.8.1...
- Resolving "kubernetes" provider (1.9.0)...
- Checking for provider plugin on https://releases.hashicorp.com...
- Downloading plugin for provider "kubernetes" (hashicorp/kubernetes) 1.9.0...`) {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, `- Resolving "null" provider (0.1.0)... if !strings.Contains(stdout, `- Resolving "null" provider (2.1.0)...
- Downloading plugin for provider "null" (0.1.0)...`) { - Checking for provider plugin on https://releases.hashicorp.com...
- Downloading plugin for provider "null" (hashicorp/null) 2.1.0...`) {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, "Fetching Terraform 0.10.1 core package...") { if !strings.Contains(stdout, "Fetching Terraform 0.12.0 core package...") {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, "Creating terraform_0.10.1-bundle") { if !strings.Contains(stdout, "Creating terraform_0.12.0-bundle") {
t.Errorf("success message is missing from output:\n%s", stdout) t.Errorf("success message is missing from output:\n%s", stdout)
} }
if !strings.Contains(stdout, "All done!") { if !strings.Contains(stdout, "All done!") {

View File

@ -1,3 +1,3 @@
terraform { terraform {
version = "0.10.1" version = "0.12.0"
} }

View File

@ -1,9 +1,9 @@
terraform { terraform {
version = "0.10.1" version = "0.12.0"
} }
providers { providers {
aws = ["~> 0.1"] aws = ["~> 2.26.0"]
kubernetes = ["0.1.0", "0.1.1", "0.1.2"] kubernetes = ["1.8.0", "1.8.1", "1.9.0"]
null = ["0.1.0"] null = ["2.1.0"]
} }