backend/remote-state: etcdv3, oss, and manta acc tests should fail

faster

The acceptance tests for etcdv3, oss and manta were not validating
required env variablea, chosing to assume that if one was running
acceptance tests they had already configured the credentials.

It was not always clear if this was a bug in the tests or the provider,
so I opted to make the tests fail faster when required attributes were
unset (or "").
This commit is contained in:
Kristin Laemmert 2019-09-26 11:30:52 -04:00
parent 5300f85a79
commit 68dfc3046d
6 changed files with 30 additions and 4 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

@ -131,9 +131,6 @@ func (b *Backend) configure(ctx context.Context) error {
if data.Get("key_id").(string) == "" { if data.Get("key_id").(string) == "" {
validationError = multierror.Append(validationError, errors.New("`Key ID` must be configured for the Triton provider")) validationError = multierror.Append(validationError, errors.New("`Key ID` must be configured for the Triton provider"))
} }
if data.Get("key_id").(string) == "" {
validationError = multierror.Append(validationError, errors.New("`Key ID` must be configured for the Triton provider"))
}
if b.path == "" { if b.path == "" {
validationError = multierror.Append(validationError, errors.New("`Path` must be configured for the Triton provider")) validationError = multierror.Append(validationError, errors.New("`Path` must be configured for the Triton provider"))
} }

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

@ -20,6 +20,11 @@ func TestDirFromModule_registry(t *testing.T) {
fixtureDir := filepath.Clean("testdata/empty") fixtureDir := filepath.Clean("testdata/empty")
tmpDir, 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) dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil { if err != nil {
t.Error(err) t.Error(err)

View File

@ -233,6 +233,10 @@ func TestLoaderInstallModules_registry(t *testing.T) {
fixtureDir := filepath.Clean("testdata/registry-modules") fixtureDir := filepath.Clean("testdata/registry-modules")
tmpDir, 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) dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -365,6 +369,10 @@ func TestLoaderInstallModules_goGetter(t *testing.T) {
fixtureDir := filepath.Clean("testdata/go-getter-modules") fixtureDir := filepath.Clean("testdata/go-getter-modules")
tmpDir, 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) dir, err := filepath.EvalSymlinks(tmpDir)
if err != nil { if err != nil {
t.Error(err) t.Error(err)