Skip to content

Commit 13a3d4c

Browse files
authored
ci: use separate CI jobs for e2e tests (#706)
1 parent 609bf67 commit 13a3d4c

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

.github/workflows/tests.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,32 @@ jobs:
156156
- name: integrations tests pased
157157
run: echo all integrations tests passed
158158

159+
setup-e2e-tests:
160+
runs-on: ubuntu-latest
161+
outputs:
162+
test_names: ${{ steps.set_test_names.outputs.test_names }}
163+
steps:
164+
165+
- uses: actions/checkout@v3
166+
167+
- id: set_test_names
168+
name: Set test names
169+
working-directory: test/e2e/
170+
# grep magic described in https://unix.stackexchange.com/a/13472
171+
# sed to add the extra $ is because some of our test names overlap. we need it so the -run regex only matches one test
172+
run: |
173+
echo "test_names=$(grep -shoP "(?<=^func )(Test[a-zA-z_0-9]+)(?=\(t \*testing.T\) {)" * | sed -e "s/$/\$/"| jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
174+
175+
- name: Print test names
176+
run: echo "Test names ${{ steps.set_test_names.outputs.test_names }}"
177+
159178
e2e-tests:
179+
needs:
180+
- setup-e2e-tests
181+
strategy:
182+
fail-fast: false
183+
matrix:
184+
test: ${{ fromJSON(needs.setup-e2e-tests.outputs.test_names) }}
160185
environment: gcloud
161186
runs-on: ubuntu-latest
162187
steps:
@@ -189,8 +214,17 @@ jobs:
189214
if: steps.detect_if_should_run.outputs.result == 'true'
190215
run: make test.e2e
191216
env:
217+
TEST_RUN: ${{ matrix.test }}
192218
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193219
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
194220
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
195221
GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }}
196222
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
223+
224+
e2e-tests-passed:
225+
needs: e2e-tests
226+
if: always() && !contains(needs.*.result, 'failure')
227+
runs-on: ubuntu-latest
228+
steps:
229+
- name: e2e tests pased
230+
run: echo all e2e tests passed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ test.integration:
5555

5656
.PHONY: test.e2e
5757
test.e2e:
58-
@GOFLAGS="-tags=e2e_tests" go test -timeout 45m -race -v ./test/e2e/...
58+
@GOFLAGS="-tags=e2e_tests" go test \
59+
-timeout 45m \
60+
-run $(TEST_RUN) \
61+
-race \
62+
-v \
63+
./test/e2e/...

test/e2e/gke_cluster_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ var (
3535
gkeLocation = os.Getenv(gke.GKELocationVar)
3636
)
3737

38-
func TestGKECluster(t *testing.T) {
39-
t.Run("create subnet", func(t *testing.T) {
40-
testGKECluster(t, true)
41-
})
38+
func TestGKECluster_create_subnet(t *testing.T) {
39+
testGKECluster(t, true)
40+
}
4241

43-
t.Run("use default subnet", func(t *testing.T) {
44-
testGKECluster(t, false)
45-
})
42+
func TestGKECluster_default_subnet(t *testing.T) {
43+
testGKECluster(t, false)
4644
}
4745

4846
func testGKECluster(t *testing.T, createSubnet bool) {
@@ -64,7 +62,7 @@ func testGKECluster(t *testing.T, createSubnet bool) {
6462
t.Logf("configuring the GKE cluster PROJECT=(%s) LOCATION=(%s)", gkeProject, gkeLocation)
6563
builder := gke.NewBuilder([]byte(gkeCreds), gkeProject, gkeLocation)
6664
builder.WithClusterMinorVersion(1, 23)
67-
builder.WithWaitForTeardown(true)
65+
builder.WithWaitForTeardown(false)
6866
builder.WithCreateSubnet(createSubnet)
6967
builder.WithLabels(map[string]string{"test-cluster": "true"})
7068

0 commit comments

Comments
 (0)