Skip to content

Commit

Permalink
ci: use separate CI jobs for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Jun 12, 2023
1 parent 609bf67 commit c866cad
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,32 @@ jobs:
- name: integrations tests pased
run: echo all integrations tests passed

setup-e2e-tests:
runs-on: ubuntu-latest
outputs:
test_names: ${{ steps.set_test_names.outputs.test_names }}
steps:

- uses: actions/checkout@v3

- id: set_test_names
name: Set test names
working-directory: test/e2e/
# grep magic described in https://unix.stackexchange.com/a/13472
# sed to add the extra $ is because some of our test names overlap. we need it so the -run regex only matches one test
run: |
echo "test_names=$(grep -shoP "(?<=^func )(Test[a-zA-z_0-9]+)(?=\(t \*testing.T\) {)" * | sed -e "s/$/\$/"| jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
- name: Print test names
run: echo "Test names ${{ steps.set_test_names.outputs.test_names }}"

e2e-tests:
needs:
- setup-e2e-tests
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.setup-e2e-tests.outputs.test_names) }}
environment: gcloud
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -189,8 +214,17 @@ jobs:
if: steps.detect_if_should_run.outputs.result == 'true'
run: make test.e2e
env:
TEST_RUN: ${{ matrix.test }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}

e2e-tests-passed:
needs: e2e-tests
if: always() && !contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
steps:
- name: e2e tests pased
run: echo all e2e tests passed
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ test.integration:

.PHONY: test.e2e
test.e2e:
@GOFLAGS="-tags=e2e_tests" go test -timeout 45m -race -v ./test/e2e/...
@GOFLAGS="-tags=e2e_tests" go test \
-timeout 45m \
-run $(TEST_RUN) \
-race \
-v \
./test/e2e/...
14 changes: 6 additions & 8 deletions test/e2e/gke_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ var (
gkeLocation = os.Getenv(gke.GKELocationVar)
)

func TestGKECluster(t *testing.T) {
t.Run("create subnet", func(t *testing.T) {
testGKECluster(t, true)
})
func TestGKECluster_create_subnet(t *testing.T) {
testGKECluster(t, true)
}

t.Run("use default subnet", func(t *testing.T) {
testGKECluster(t, false)
})
func TestGKECluster_default_subnet(t *testing.T) {
testGKECluster(t, false)
}

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

Expand Down

0 comments on commit c866cad

Please sign in to comment.