Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
f881c2d7
Commit
f881c2d7
authored
3 years ago
by
Chris Arcand
Browse files
Options
Download
Email Patches
Plain Diff
cloud: Skip E2E tests without an exact version
parent
e364ef29
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
internal/cloud/e2e/apply_auto_approve_test.go
+7
-8
internal/cloud/e2e/apply_auto_approve_test.go
internal/cloud/e2e/backend_apply_before_init_test.go
+2
-0
internal/cloud/e2e/backend_apply_before_init_test.go
internal/cloud/e2e/helper_test.go
+6
-2
internal/cloud/e2e/helper_test.go
internal/cloud/e2e/main_test.go
+7
-1
internal/cloud/e2e/main_test.go
internal/cloud/e2e/migrate_state_multi_to_tfc_test.go
+4
-0
internal/cloud/e2e/migrate_state_multi_to_tfc_test.go
internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go
+10
-0
...nal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go
internal/cloud/e2e/migrate_state_single_to_tfc_test.go
+2
-0
internal/cloud/e2e/migrate_state_single_to_tfc_test.go
internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go
+15
-19
internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go
internal/cloud/e2e/run_variables_test.go
+2
-0
internal/cloud/e2e/run_variables_test.go
with
55 additions
and
30 deletions
+55
-30
internal/cloud/e2e/apply_auto_approve_test.go
+
7
-
8
View file @
f881c2d7
...
...
@@ -13,14 +13,13 @@ import (
expect
"github.com/Netflix/go-expect"
tfe
"github.com/hashicorp/go-tfe"
"github.com/hashicorp/terraform/internal/e2e"
tfversion
"github.com/hashicorp/terraform/version"
)
func
Test_terraform_apply_autoApprove
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
tfVersion
:=
"1.1.0-tfc-integration"
if
!
hasTerraformVersion
(
t
,
tfVersion
)
{
t
.
Skip
(
"Skipping test because TFC does not have current terraform version."
)
}
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
@@ -33,7 +32,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
wsName
:=
"app"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
wsName
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
AutoApply
:
tfe
.
Bool
(
false
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
...
...
@@ -73,7 +72,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
wsName
:=
"app"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
wsName
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
AutoApply
:
tfe
.
Bool
(
true
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
...
...
@@ -113,7 +112,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
wsName
:=
"app"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
wsName
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
AutoApply
:
tfe
.
Bool
(
false
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
...
...
@@ -151,7 +150,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
wsName
:=
"app"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
wsName
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
AutoApply
:
tfe
.
Bool
(
true
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/backend_apply_before_init_test.go
+
2
-
0
View file @
f881c2d7
...
...
@@ -14,6 +14,8 @@ import (
)
func
Test_backend_apply_before_init
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
}{
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/helper_test.go
+
6
-
2
View file @
f881c2d7
...
...
@@ -12,6 +12,7 @@ import (
tfe
"github.com/hashicorp/go-tfe"
"github.com/hashicorp/go-uuid"
tfversion
"github.com/hashicorp/terraform/version"
)
const
(
...
...
@@ -193,7 +194,8 @@ func writeMainTF(t *testing.T, block string, dir string) {
}
// Ensure that TFC/E has a particular terraform version.
func
hasTerraformVersion
(
t
*
testing
.
T
,
version
string
)
bool
{
func
skipWithoutRemoteTerraformVersion
(
t
*
testing
.
T
)
{
version
:=
tfversion
.
String
()
opts
:=
tfe
.
AdminTerraformVersionsListOptions
{
ListOptions
:
tfe
.
ListOptions
{
PageNumber
:
1
,
...
...
@@ -226,5 +228,7 @@ findTfVersion:
opts
.
PageNumber
=
tfVersionList
.
NextPage
}
return
hasVersion
if
!
hasVersion
{
t
.
Skip
(
fmt
.
Sprintf
(
"Skipping test because TFC/E does not have current Terraform version to test with (%s)"
,
version
))
}
}
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/main_test.go
+
7
-
1
View file @
f881c2d7
...
...
@@ -13,6 +13,7 @@ import (
"testing"
tfe
"github.com/hashicorp/go-tfe"
tfversion
"github.com/hashicorp/terraform/version"
)
var
terraformBin
string
...
...
@@ -97,7 +98,12 @@ func setupBinary() func() {
log
.
Fatal
(
err
)
}
cmd
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
tmpTerraformBinaryDir
)
cmd
:=
exec
.
Command
(
"go"
,
"build"
,
"-o"
,
tmpTerraformBinaryDir
,
"-ldflags"
,
fmt
.
Sprintf
(
"-X
\"
github.com/hashicorp/terraform/version.Prerelease=%s
\"
"
,
tfversion
.
Prerelease
),
)
err
=
cmd
.
Run
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/migrate_state_multi_to_tfc_test.go
+
4
-
0
View file @
f881c2d7
...
...
@@ -15,6 +15,8 @@ import (
)
func
Test_migrate_multi_to_tfc_cloud_name_strategy
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
...
...
@@ -242,6 +244,8 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
}
func
Test_migrate_multi_to_tfc_cloud_tags_strategy
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go
+
10
-
0
View file @
f881c2d7
...
...
@@ -15,6 +15,8 @@ import (
)
func
Test_migrate_remote_backend_name_to_tfc_name
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
@@ -197,6 +199,8 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
}
func
Test_migrate_remote_backend_name_to_tfc_name_different_org
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
@@ -334,6 +338,8 @@ func Test_migrate_remote_backend_name_to_tfc_name_different_org(t *testing.T) {
}
func
Test_migrate_remote_backend_name_to_tfc_tags
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
@@ -477,6 +483,8 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
}
func
Test_migrate_remote_backend_prefix_to_tfc_name
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
@@ -695,6 +703,8 @@ func Test_migrate_remote_backend_prefix_to_tfc_name(t *testing.T) {
}
func
Test_migrate_remote_backend_prefix_to_tfc_tags
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
operations
[]
operationSets
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/migrate_state_single_to_tfc_test.go
+
2
-
0
View file @
f881c2d7
...
...
@@ -15,6 +15,8 @@ import (
)
func
Test_migrate_single_to_tfc
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
cases
:=
map
[
string
]
struct
{
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go
+
15
-
19
View file @
f881c2d7
...
...
@@ -13,14 +13,12 @@ import (
expect
"github.com/Netflix/go-expect"
tfe
"github.com/hashicorp/go-tfe"
"github.com/hashicorp/terraform/internal/e2e"
tfversion
"github.com/hashicorp/terraform/version"
)
func
Test_migrate_tfc_to_tfc_single_workspace
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
tfVersion
:=
"1.1.0-alpha-20211027-dev-e51508be"
if
!
hasTerraformVersion
(
t
,
tfVersion
)
{
t
.
Skip
(
"Skipping test because TFC does not have current terraform version."
)
}
cases
:=
map
[
string
]
struct
{
setup
func
(
t
*
testing
.
T
)
(
string
,
func
())
...
...
@@ -42,7 +40,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
// terraform version of this current branch.
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"prod"
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -69,7 +67,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
wsName
:=
"dev"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
wsName
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -110,7 +108,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
wsName
:=
"prod"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"prod"
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -174,7 +172,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
wsName
:=
"prod"
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"prod"
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
wsName
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -200,7 +198,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
// version that does not support `cloud`.
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"new-workspace"
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendTags
(
orgName
,
tag
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -214,7 +212,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
postInputOutput
:
[]
string
{
// this is a temporary measure till we resolve some of the
// version mismatching.
fmt
.
Sprintf
(
`Remote workspace Terraform version "%s" does not match local Terraform version`
,
tf
V
ersion
)},
fmt
.
Sprintf
(
`Remote workspace Terraform version "%s" does not match local Terraform version`
,
tf
v
ersion
.
String
()
)},
},
},
},
...
...
@@ -308,11 +306,9 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
}
func
Test_migrate_tfc_to_tfc_multiple_workspace
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
ctx
:=
context
.
Background
()
tfVersion
:=
"1.1.0-alpha-20211027-dev-e51508be"
if
!
hasTerraformVersion
(
t
,
tfVersion
)
{
t
.
Skip
(
"Skipping test because TFC does not have current terraform version."
)
}
cases
:=
map
[
string
]
struct
{
setup
func
(
t
*
testing
.
T
)
(
string
,
func
())
...
...
@@ -331,12 +327,12 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"app-prod"
),
Tags
:
[]
*
tfe
.
Tag
{{
Name
:
tag
}},
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"app-staging"
),
Tags
:
[]
*
tfe
.
Tag
{{
Name
:
tag
}},
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendTags
(
orgName
,
tag
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -378,7 +374,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
// using the right version for post init operations.
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
name
),
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendName
(
orgName
,
name
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
@@ -425,12 +421,12 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"app-prod"
),
Tags
:
[]
*
tfe
.
Tag
{{
Name
:
tag
}},
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
_
=
createWorkspace
(
t
,
orgName
,
tfe
.
WorkspaceCreateOptions
{
Name
:
tfe
.
String
(
"app-staging"
),
Tags
:
[]
*
tfe
.
Tag
{{
Name
:
tag
}},
TerraformVersion
:
tfe
.
String
(
tf
V
ersion
),
TerraformVersion
:
tfe
.
String
(
tf
v
ersion
.
String
()
),
})
tfBlock
:=
terraformConfigCloudBackendTags
(
orgName
,
tag
)
writeMainTF
(
t
,
tfBlock
,
dir
)
...
...
This diff is collapsed.
Click to expand it.
internal/cloud/e2e/run_variables_test.go
+
2
-
0
View file @
f881c2d7
...
...
@@ -46,6 +46,8 @@ output "test_env" {
}
func
Test_cloud_run_variables
(
t
*
testing
.
T
)
{
skipWithoutRemoteTerraformVersion
(
t
)
cases
:=
testCases
{
"run variables from CLI arg"
:
{
operations
:
[]
operationSets
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help