Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ if ! which "$0" | grep -q nix; then
export NIX_PROFILE="$profile"

print 'Updating Nix Cache...'
nf flake update
if ! nf flake update; then
print 'Failed to update Nix flake, continuing with existing cache...'
git checkout flake.lock
fi

echo 'Installing Nix Profile...'
print 'Installing Nix Profile...'
nf profile install . --profile "$profile"
nf profile list --profile "$profile"

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ jobs:
needs:
- release
- test_TestOneBasic
- test_TestProdBasic
if: needs.release.outputs.release_pr
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -250,6 +251,7 @@ jobs:
- test_TestOneBasic
- test_TestProdBasic
- test_TestThreeBasic
- test_TestDownstreamBasic
if: needs.release.outputs.release_pr
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion test/tests/downstream/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestDownstreamBasic(t *testing.T) {
"KUBECONFIG": testDir + "/kubeconfig",
"KUBE_CONFIG_PATH": testDir,
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
},
Expand Down
2 changes: 1 addition & 1 deletion test/tests/downstream/splitrole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestDownstreamSplitrole(t *testing.T) {
"KUBECONFIG": testDir + "/kubeconfig",
"KUBE_CONFIG_PATH": testDir,
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
},
Expand Down
2 changes: 1 addition & 1 deletion test/tests/one/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestOneBasic(t *testing.T) {
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
},
Expand Down
8 changes: 4 additions & 4 deletions test/tests/prod/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestProdBasic(t *testing.T) {
accessKey := util.GetAwsAccessKey()
secretKey := util.GetAwsSecretKey()
sessionToken := util.GetAwsSessionToken()
directory := "prod"
directory := "prod"
owner := "[email protected]"
util.SetAcmeServer()

Expand Down Expand Up @@ -89,15 +89,15 @@ func TestProdBasic(t *testing.T) {
"aws_secret_access_key": secretKey,
"aws_session_token": sessionToken,
"aws_region": region,
},
},
// Environment variables to set when running Terraform
EnvVars: map[string]string{
"AWS_DEFAULT_REGION": region,
"AWS_DEFAULT_REGION": region,
"AWS_REGION": region,
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
},
Expand Down
14 changes: 9 additions & 5 deletions test/tests/three/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ func TestThreeBasic(t *testing.T) {
},
// Environment variables to set when running Terraform
EnvVars: map[string]string{
"AWS_DEFAULT_REGION": region,
"AWS_REGION": region,
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
"AWS_DEFAULT_REGION": region,
"AWS_REGION": region,
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
"TF_CLI_ARGS_plan": "-no-color", // using remote state from storage backend
"TF_CLI_ARGS_apply": "-no-color -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color",
"TF_CLI_ARGS_output": "-no-color",
},
RetryableTerraformErrors: util.GetRetryableTerraformErrors(),
NoColor: true,
Expand Down
40 changes: 22 additions & 18 deletions test/tests/three/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ func TestThreeState(t *testing.T) {
t.Parallel()
util.SetAcmeServer()

id := util.GetId()
region := util.GetRegion()
directory := "three"
owner := "[email protected]"
id := util.GetId()
region := util.GetRegion()
directory := "three"
owner := "[email protected]"
repoRoot, err := filepath.Abs(g.GetRepoRoot(t))
if err != nil {
t.Fatalf("Error getting git root directory: %v", err)
}
exampleDir := repoRoot + "/examples/" + directory
testDir := repoRoot + "/test/tests/data/" + id
testDir := repoRoot + "/test/tests/data/" + id

err = util.CreateTestDirectories(t, id)
if err != nil {
Expand Down Expand Up @@ -92,11 +92,15 @@ func TestThreeState(t *testing.T) {
},
// Environment variables to set when running Terraform
EnvVars: map[string]string{
"AWS_DEFAULT_REGION": region,
"AWS_REGION": region,
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
"AWS_DEFAULT_REGION": region,
"AWS_REGION": region,
"TF_DATA_DIR": testDir,
"TF_IN_AUTOMATION": "1",
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
"TF_CLI_ARGS_plan": "-no-color", // using remote state from storage backend
"TF_CLI_ARGS_apply": "-no-color -parallelism=5",
"TF_CLI_ARGS_destroy": "-no-color",
"TF_CLI_ARGS_output": "-no-color",
},
RetryableTerraformErrors: util.GetRetryableTerraformErrors(),
NoColor: true,
Expand All @@ -116,7 +120,7 @@ func TestThreeState(t *testing.T) {
util.CheckReady(t, testDir+"/kubeconfig")
util.CheckRunning(t, testDir+"/kubeconfig")

os.RemoveAll(testDir)
os.RemoveAll(testDir)
err = util.CreateTestDirectories(t, id)
if err != nil {
t.Log("Test failed, tearing down...")
Expand All @@ -125,16 +129,16 @@ func TestThreeState(t *testing.T) {
t.Fatalf("Error creating cluster: %s", err)
}

// Running the apply again should re-create everything from state in S3
// This should only recreate the files, the resources should be untouched
// Running the apply again should re-create everything from state in S3
// This should only recreate the files, the resources should be untouched
err = os.WriteFile(testDir+"/id_rsa", []byte(keyPair.KeyPair.PrivateKey), 0600)
if err != nil {
t.Log("Test failed, tearing down...")
util.GetErrorLogs(t, testDir+"/kubeconfig")
util.Teardown(t, testDir, exampleDir, newTfOptions, keyPair, sshAgent)
t.Fatalf("Error creating cluster: %s", err)
}
_, err = terraform.InitAndApplyE(t, terraformOptions)
}
_, err = terraform.InitAndApplyE(t, terraformOptions)
if err != nil {
t.Log("Test failed, tearing down...")
util.GetErrorLogs(t, testDir+"/kubeconfig")
Expand All @@ -144,8 +148,8 @@ func TestThreeState(t *testing.T) {
util.CheckReady(t, testDir+"/kubeconfig")
util.CheckRunning(t, testDir+"/kubeconfig")

// Running the apply again should not change anything
_, err = terraform.InitAndApplyE(t, terraformOptions)
// Running the apply again should not change anything
_, err = terraform.InitAndApplyE(t, terraformOptions)
if err != nil {
t.Log("Test failed, tearing down...")
util.GetErrorLogs(t, testDir+"/kubeconfig")
Expand All @@ -155,7 +159,7 @@ func TestThreeState(t *testing.T) {
util.CheckReady(t, testDir+"/kubeconfig")
util.CheckRunning(t, testDir+"/kubeconfig")

if t.Failed() {
if t.Failed() {
t.Log("Test failed...")
} else {
t.Log("Test passed...")
Expand Down