Skip to content

Commit e58984f

Browse files
authored
fix: reduce test concurrency (#125)
Signed-off-by: matttrach <matt.trachier@suse.com>
1 parent c304cd6 commit e58984f

8 files changed

Lines changed: 45 additions & 32 deletions

File tree

.envrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ if ! which "$0" | grep -q nix; then
3131
export NIX_PROFILE="$profile"
3232

3333
print 'Updating Nix Cache...'
34-
nf flake update
34+
if ! nf flake update; then
35+
print 'Failed to update Nix flake, continuing with existing cache...'
36+
git checkout flake.lock
37+
fi
3538

36-
echo 'Installing Nix Profile...'
39+
print 'Installing Nix Profile...'
3740
nf profile install . --profile "$profile"
3841
nf profile list --profile "$profile"
3942

.github/workflows/release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ jobs:
161161
needs:
162162
- release
163163
- test_TestOneBasic
164+
- test_TestProdBasic
164165
if: needs.release.outputs.release_pr
165166
runs-on: ubuntu-latest
166167
steps:
@@ -250,6 +251,7 @@ jobs:
250251
- test_TestOneBasic
251252
- test_TestProdBasic
252253
- test_TestThreeBasic
254+
- test_TestDownstreamBasic
253255
if: needs.release.outputs.release_pr
254256
runs-on: ubuntu-latest
255257
steps:

test/tests/downstream/basic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestDownstreamBasic(t *testing.T) {
9797
"KUBECONFIG": testDir + "/kubeconfig",
9898
"KUBE_CONFIG_PATH": testDir,
9999
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
100-
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
100+
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
101101
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
102102
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
103103
},

test/tests/downstream/splitrole_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestDownstreamSplitrole(t *testing.T) {
9999
"KUBECONFIG": testDir + "/kubeconfig",
100100
"KUBE_CONFIG_PATH": testDir,
101101
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
102-
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
102+
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
103103
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
104104
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
105105
},

test/tests/one/basic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestOneBasic(t *testing.T) {
8989
"TF_DATA_DIR": testDir,
9090
"TF_IN_AUTOMATION": "1",
9191
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
92-
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
92+
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
9393
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
9494
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
9595
},

test/tests/prod/basic_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestProdBasic(t *testing.T) {
1919
accessKey := util.GetAwsAccessKey()
2020
secretKey := util.GetAwsSecretKey()
2121
sessionToken := util.GetAwsSessionToken()
22-
directory := "prod"
22+
directory := "prod"
2323
owner := "terraform-ci@suse.com"
2424
util.SetAcmeServer()
2525

@@ -89,15 +89,15 @@ func TestProdBasic(t *testing.T) {
8989
"aws_secret_access_key": secretKey,
9090
"aws_session_token": sessionToken,
9191
"aws_region": region,
92-
},
92+
},
9393
// Environment variables to set when running Terraform
9494
EnvVars: map[string]string{
95-
"AWS_DEFAULT_REGION": region,
95+
"AWS_DEFAULT_REGION": region,
9696
"AWS_REGION": region,
9797
"TF_DATA_DIR": testDir,
9898
"TF_IN_AUTOMATION": "1",
9999
"TF_CLI_ARGS_plan": "-no-color -state=" + testDir + "/tfstate",
100-
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate",
100+
"TF_CLI_ARGS_apply": "-no-color -state=" + testDir + "/tfstate -parallelism=5",
101101
"TF_CLI_ARGS_destroy": "-no-color -state=" + testDir + "/tfstate",
102102
"TF_CLI_ARGS_output": "-no-color -state=" + testDir + "/tfstate",
103103
},

test/tests/three/basic_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ func TestThreeBasic(t *testing.T) {
9292
},
9393
// Environment variables to set when running Terraform
9494
EnvVars: map[string]string{
95-
"AWS_DEFAULT_REGION": region,
96-
"AWS_REGION": region,
97-
"TF_DATA_DIR": testDir,
98-
"TF_IN_AUTOMATION": "1",
99-
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
95+
"AWS_DEFAULT_REGION": region,
96+
"AWS_REGION": region,
97+
"TF_DATA_DIR": testDir,
98+
"TF_IN_AUTOMATION": "1",
99+
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
100+
"TF_CLI_ARGS_plan": "-no-color", // using remote state from storage backend
101+
"TF_CLI_ARGS_apply": "-no-color -parallelism=5",
102+
"TF_CLI_ARGS_destroy": "-no-color",
103+
"TF_CLI_ARGS_output": "-no-color",
100104
},
101105
RetryableTerraformErrors: util.GetRetryableTerraformErrors(),
102106
NoColor: true,

test/tests/three/state_test.go

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ func TestThreeState(t *testing.T) {
1818
t.Parallel()
1919
util.SetAcmeServer()
2020

21-
id := util.GetId()
22-
region := util.GetRegion()
23-
directory := "three"
24-
owner := "terraform-ci@suse.com"
21+
id := util.GetId()
22+
region := util.GetRegion()
23+
directory := "three"
24+
owner := "terraform-ci@suse.com"
2525
repoRoot, err := filepath.Abs(g.GetRepoRoot(t))
2626
if err != nil {
2727
t.Fatalf("Error getting git root directory: %v", err)
2828
}
2929
exampleDir := repoRoot + "/examples/" + directory
30-
testDir := repoRoot + "/test/tests/data/" + id
30+
testDir := repoRoot + "/test/tests/data/" + id
3131

3232
err = util.CreateTestDirectories(t, id)
3333
if err != nil {
@@ -92,11 +92,15 @@ func TestThreeState(t *testing.T) {
9292
},
9393
// Environment variables to set when running Terraform
9494
EnvVars: map[string]string{
95-
"AWS_DEFAULT_REGION": region,
96-
"AWS_REGION": region,
97-
"TF_DATA_DIR": testDir,
98-
"TF_IN_AUTOMATION": "1",
99-
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
95+
"AWS_DEFAULT_REGION": region,
96+
"AWS_REGION": region,
97+
"TF_DATA_DIR": testDir,
98+
"TF_IN_AUTOMATION": "1",
99+
"TF_CLI_ARGS_init": "-backend-config=\"bucket=" + strings.ToLower(id) + "\"",
100+
"TF_CLI_ARGS_plan": "-no-color", // using remote state from storage backend
101+
"TF_CLI_ARGS_apply": "-no-color -parallelism=5",
102+
"TF_CLI_ARGS_destroy": "-no-color",
103+
"TF_CLI_ARGS_output": "-no-color",
100104
},
101105
RetryableTerraformErrors: util.GetRetryableTerraformErrors(),
102106
NoColor: true,
@@ -116,7 +120,7 @@ func TestThreeState(t *testing.T) {
116120
util.CheckReady(t, testDir+"/kubeconfig")
117121
util.CheckRunning(t, testDir+"/kubeconfig")
118122

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

128-
// Running the apply again should re-create everything from state in S3
129-
// This should only recreate the files, the resources should be untouched
132+
// Running the apply again should re-create everything from state in S3
133+
// This should only recreate the files, the resources should be untouched
130134
err = os.WriteFile(testDir+"/id_rsa", []byte(keyPair.KeyPair.PrivateKey), 0600)
131135
if err != nil {
132136
t.Log("Test failed, tearing down...")
133137
util.GetErrorLogs(t, testDir+"/kubeconfig")
134138
util.Teardown(t, testDir, exampleDir, newTfOptions, keyPair, sshAgent)
135139
t.Fatalf("Error creating cluster: %s", err)
136-
}
137-
_, err = terraform.InitAndApplyE(t, terraformOptions)
140+
}
141+
_, err = terraform.InitAndApplyE(t, terraformOptions)
138142
if err != nil {
139143
t.Log("Test failed, tearing down...")
140144
util.GetErrorLogs(t, testDir+"/kubeconfig")
@@ -144,8 +148,8 @@ func TestThreeState(t *testing.T) {
144148
util.CheckReady(t, testDir+"/kubeconfig")
145149
util.CheckRunning(t, testDir+"/kubeconfig")
146150

147-
// Running the apply again should not change anything
148-
_, err = terraform.InitAndApplyE(t, terraformOptions)
151+
// Running the apply again should not change anything
152+
_, err = terraform.InitAndApplyE(t, terraformOptions)
149153
if err != nil {
150154
t.Log("Test failed, tearing down...")
151155
util.GetErrorLogs(t, testDir+"/kubeconfig")
@@ -155,7 +159,7 @@ func TestThreeState(t *testing.T) {
155159
util.CheckReady(t, testDir+"/kubeconfig")
156160
util.CheckRunning(t, testDir+"/kubeconfig")
157161

158-
if t.Failed() {
162+
if t.Failed() {
159163
t.Log("Test failed...")
160164
} else {
161165
t.Log("Test passed...")

0 commit comments

Comments
 (0)