Skip to content

Commit b5ddfc1

Browse files
ci(e2e): split with-API tests into parallel compute/dbaas jobs
1 parent 9599109 commit b5ddfc1

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version-file: 'go.mod'
17+
go-version-file: "go.mod"
1818

1919
- name: Build binary
2020
run: make build
@@ -25,24 +25,30 @@ jobs:
2525
go test -v
2626
2727
test-e2e-with-api:
28-
name: Run E2E (Testscript) Tests / With API
28+
name: Run E2E (Testscript) Tests / With API / ${{ matrix.suite }}
2929
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
suite: [compute, dbaas]
3034
steps:
3135
- uses: actions/checkout@v4
3236

3337
- name: Set up Go
3438
uses: actions/setup-go@v5
3539
with:
36-
go-version-file: 'go.mod'
40+
go-version-file: "go.mod"
3741

3842
- name: Build binary
3943
run: make build
4044

41-
- name: Run E2E (Testscript) Tests / With API
45+
- name: Run E2E (Testscript) Tests / With API / ${{ matrix.suite }}
4246
env:
4347
EXOSCALE_API_KEY: ${{ secrets.EXOSCALE_API_KEY }}
4448
EXOSCALE_API_SECRET: ${{ secrets.EXOSCALE_API_SECRET }}
4549
EXOSCALE_ZONE: ch-gva-2
4650
run: |
4751
cd tests/e2e
48-
go test -v -tags=api -timeout 30m -run TestScriptsAPI 2>&1
52+
suite=${{ matrix.suite }}
53+
func="TestScriptsAPI${suite^}"
54+
go test -v -tags=api -timeout 30m -run "$func" 2>&1

tests/e2e/testscript_api_test.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ type APITestSuite struct {
2222
RunID string
2323
}
2424

25-
// TestScriptsAPI runs testscript scenarios that require real API access.
26-
// Run with: go test -v -tags=api -timeout 30m
25+
// TestScriptsAPICompute runs API e2e scenarios under scenarios/with-api/compute/.
26+
// Run with: go test -v -tags=api -timeout 30m -run TestScriptsAPICompute
27+
func TestScriptsAPICompute(t *testing.T) {
28+
runAPITestSuite(t, "scenarios/with-api/compute")
29+
}
30+
31+
// TestScriptsAPIDBaaS runs API e2e scenarios under scenarios/with-api/dbaas/.
32+
// Run with: go test -v -tags=api -timeout 30m -run TestScriptsAPIDBaaS
33+
func TestScriptsAPIDBaaS(t *testing.T) {
34+
runAPITestSuite(t, "scenarios/with-api/dbaas")
35+
}
36+
37+
// runAPITestSuite is the shared runner for per-suite API test functions.
38+
// dir is the directory of .txtar scenarios to run (relative to the e2e package).
2739
//
2840
// Required environment variables:
2941
//
3042
// EXOSCALE_API_KEY - Exoscale API key
3143
// EXOSCALE_API_SECRET - Exoscale API secret
3244
// EXOSCALE_ZONE - Zone to run tests in (default: ch-gva-2)
33-
func TestScriptsAPI(t *testing.T) {
45+
func runAPITestSuite(t *testing.T, dir string) {
46+
t.Helper()
3447
if os.Getenv("EXOSCALE_API_KEY") == "" || os.Getenv("EXOSCALE_API_SECRET") == "" {
3548
t.Skip("Skipping API tests: EXOSCALE_API_KEY and EXOSCALE_API_SECRET must be set")
3649
}
@@ -48,13 +61,12 @@ func TestScriptsAPI(t *testing.T) {
4861
RunID: runID,
4962
}
5063

51-
// Run all scenarios under scenarios/with-api/
52-
files, err := findTestScripts("scenarios/with-api")
64+
files, err := findTestScripts(dir)
5365
if err != nil {
5466
t.Fatal(err)
5567
}
5668
if len(files) == 0 {
57-
t.Log("No API test scenarios found in scenarios/with-api/")
69+
t.Logf("No API test scenarios found in %s/", dir)
5870
return
5971
}
6072

0 commit comments

Comments
 (0)