mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
remove build tags for cloud e2e
This commit is contained in:
parent
5ef82ddd2f
commit
57a4b51e87
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
To run them, use:
|
To run them, use:
|
||||||
```
|
```
|
||||||
TF_ACC=1 go test -tags=e2e ./internal/cloud/e2e/... -ldflags "-X \"github.com/hashicorp/terraform/version.Prerelease=<PRE-RELEASE>\""
|
TFE_TOKEN=<token> TFE_HOSTNAME=<hostname> TF_ACC=1 go test ./internal/cloud/e2e/... -ldflags "-X \"github.com/hashicorp/terraform/version.Prerelease=<PRE-RELEASE>\""
|
||||||
```
|
```
|
||||||
|
|
||||||
Required flags
|
Required flags
|
||||||
* `-tags=e2e` for running e2e tests.
|
|
||||||
* `TF_ACC=1`. This variable is used as part of terraform for tests that make
|
* `TF_ACC=1`. This variable is used as part of terraform for tests that make
|
||||||
external network calls. This is needed to run these tests. Without it, the
|
external network calls. This is needed to run these tests. Without it, the
|
||||||
tests do not run.
|
tests do not run.
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -24,7 +21,6 @@ const (
|
|||||||
type tfCommand struct {
|
type tfCommand struct {
|
||||||
command []string
|
command []string
|
||||||
expectedCmdOutput string
|
expectedCmdOutput string
|
||||||
expectedErr string
|
|
||||||
expectError bool
|
expectError bool
|
||||||
userInput []string
|
userInput []string
|
||||||
postInputOutput []string
|
postInputOutput []string
|
||||||
@ -105,7 +101,7 @@ func randomString(t *testing.T) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func terraformConfigLocalBackend() string {
|
func terraformConfigLocalBackend() string {
|
||||||
return fmt.Sprintf(`
|
return `
|
||||||
terraform {
|
terraform {
|
||||||
backend "local" {
|
backend "local" {
|
||||||
}
|
}
|
||||||
@ -114,7 +110,7 @@ terraform {
|
|||||||
output "val" {
|
output "val" {
|
||||||
value = "${terraform.workspace}"
|
value = "${terraform.workspace}"
|
||||||
}
|
}
|
||||||
`)
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
func terraformConfigRemoteBackendName(org, name string) string {
|
func terraformConfigRemoteBackendName(org, name string) string {
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -27,8 +24,9 @@ var verboseMode bool
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
if !accTest() {
|
hasRequiredEnvVars := accTest() && hasHostname() && hasToken()
|
||||||
// if TF_ACC is not set, we want to skip all these tests.
|
if !hasRequiredEnvVars {
|
||||||
|
// if the above three required variables are not set, then skip all tests.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
teardown := setup()
|
teardown := setup()
|
||||||
@ -44,6 +42,14 @@ func accTest() bool {
|
|||||||
return os.Getenv("TF_ACC") != ""
|
return os.Getenv("TF_ACC") != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasHostname() bool {
|
||||||
|
return os.Getenv("TFE_HOSTNAME") != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasToken() bool {
|
||||||
|
return os.Getenv("TFE_TOKEN") != ""
|
||||||
|
}
|
||||||
|
|
||||||
func setup() func() {
|
func setup() func() {
|
||||||
tfOutput := flag.Bool("tfoutput", false, "This flag produces the terraform output from tests.")
|
tfOutput := flag.Bool("tfoutput", false, "This flag produces the terraform output from tests.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -186,7 +183,6 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
|
|||||||
for _, op := range tc.operations {
|
for _, op := range tc.operations {
|
||||||
op.prep(t, organization.Name, tf.WorkDir())
|
op.prep(t, organization.Name, tf.WorkDir())
|
||||||
for _, tfCmd := range op.commands {
|
for _, tfCmd := range op.commands {
|
||||||
tfCmd.command = append(tfCmd.command)
|
|
||||||
cmd := tf.Cmd(tfCmd.command...)
|
cmd := tf.Cmd(tfCmd.command...)
|
||||||
cmd.Stdin = exp.Tty()
|
cmd.Stdin = exp.Tty()
|
||||||
cmd.Stdout = exp.Tty()
|
cmd.Stdout = exp.Tty()
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -705,15 +702,15 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_multi_workspace(t *
|
|||||||
if len(wsList.Items) != 3 {
|
if len(wsList.Items) != 3 {
|
||||||
t.Fatalf("expected number of workspaces in this org to be 3, but got %d", len(wsList.Items))
|
t.Fatalf("expected number of workspaces in this org to be 3, but got %d", len(wsList.Items))
|
||||||
}
|
}
|
||||||
ws, empty := getWorkspace(wsList.Items, "cloud-workspace")
|
_, empty := getWorkspace(wsList.Items, "cloud-workspace")
|
||||||
if empty {
|
if empty {
|
||||||
t.Fatalf("expected workspaces to include 'cloud-workspace' but didn't.")
|
t.Fatalf("expected workspaces to include 'cloud-workspace' but didn't.")
|
||||||
}
|
}
|
||||||
ws, empty = getWorkspace(wsList.Items, "app-one")
|
_, empty = getWorkspace(wsList.Items, "app-one")
|
||||||
if empty {
|
if empty {
|
||||||
t.Fatalf("expected workspaces to include 'app-one' but didn't.")
|
t.Fatalf("expected workspaces to include 'app-one' but didn't.")
|
||||||
}
|
}
|
||||||
ws, empty = getWorkspace(wsList.Items, "app-two")
|
_, empty = getWorkspace(wsList.Items, "app-two")
|
||||||
if empty {
|
if empty {
|
||||||
t.Fatalf("expected workspaces to include 'app-two' but didn't.")
|
t.Fatalf("expected workspaces to include 'app-two' but didn't.")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
//go:build e2e
|
|
||||||
// +build e2e
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,7 +7,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
expect "github.com/Netflix/go-expect"
|
expect "github.com/Netflix/go-expect"
|
||||||
|
tfe "github.com/hashicorp/go-tfe"
|
||||||
"github.com/hashicorp/terraform/internal/e2e"
|
"github.com/hashicorp/terraform/internal/e2e"
|
||||||
|
tfversion "github.com/hashicorp/terraform/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func terraformConfigRequiredVariable(org, name string) string {
|
func terraformConfigRequiredVariable(org, name string) string {
|
||||||
@ -54,6 +53,10 @@ func Test_cloud_run_variables(t *testing.T) {
|
|||||||
{
|
{
|
||||||
prep: func(t *testing.T, orgName, dir string) {
|
prep: func(t *testing.T, orgName, dir string) {
|
||||||
wsName := "new-workspace"
|
wsName := "new-workspace"
|
||||||
|
_ = createWorkspace(t, orgName, tfe.WorkspaceCreateOptions{
|
||||||
|
Name: tfe.String(wsName),
|
||||||
|
TerraformVersion: tfe.String(tfversion.String()),
|
||||||
|
})
|
||||||
tfBlock := terraformConfigRequiredVariable(orgName, wsName)
|
tfBlock := terraformConfigRequiredVariable(orgName, wsName)
|
||||||
writeMainTF(t, tfBlock, dir)
|
writeMainTF(t, tfBlock, dir)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user