-
Notifications
You must be signed in to change notification settings - Fork 590
287 lines (258 loc) · 10 KB
/
_e2e_tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: e2e tests
on:
workflow_call:
inputs:
kic-image:
description: KIC image to be tested (e.g. `kong/kubernetes-ingress-controller:v2.9.0`).
type: string
required: true
kong-image:
description: Kong image to be tested (e.g. `kong:3.1.0`).
type: string
required: false
load-local-image:
description: Whether to load the local built image into the Docker daemon (from artifact).
type: boolean
default: false
all-supported-k8s-versions:
description: Run tests against all supported Kubernetes versions. Otherwise, only against the latest one.
type: boolean
default: false
run-gke:
description: Run E2E tests on GKE as well as on Kind.
type: boolean
default: false
run-istio:
description: Run Istio E2E tests.
type: boolean
default: false
jobs:
setup-e2e-tests:
runs-on: ubuntu-latest
outputs:
test_names: ${{ steps.set_test_names.outputs.test_names }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: test_files
name: Get test file names
working-directory: test/e2e/
# go list used to extract the test names from only those test files that
# match the specified tags: here e2e_tests.
# This filters out e.g. istio tests which we run separately.
run: echo "result=$(go list -tags e2e_tests -f '{{ range .TestGoFiles }} {{- . }} {{ end }}' .)" >> $GITHUB_OUTPUT
- name: Print test file names
run: echo "Test file names ${{ steps.test_files.outputs.result }}"
- 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\) {)" ${{ steps.test_files.outputs.result }} | sed -e "s/$/\$/"| jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
- name: Print test names
run: echo "Test names ${{ steps.set_test_names.outputs.test_names }}"
# TODO: extract this as a separate workflow reading the dependencies versions from a file (not only Kind, but also
# GKE, Istio, Kong, etc.)
# https://github.com/Kong/kubernetes-ingress-controller/issues/3349
dependencies-versions:
runs-on: ubuntu-latest
outputs:
kind-versions: ${{ steps.set-kind-versions.outputs.kind-versions }}
steps:
- id: set-kind-versions
name: Set Kind versions
run: |
if [ "${{ inputs.all-supported-k8s-versions }}" == "true" ]; then
echo "kind-versions=[\"1.22.17\", \"1.23.17\", \"1.24.15\", \"1.25.11\", \"1.26.6\", \"1.27.3\"]" >> $GITHUB_OUTPUT
else
echo "kind-versions=[\"1.27.3\"]" >> $GITHUB_OUTPUT
fi
kind:
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
needs:
- setup-e2e-tests
- dependencies-versions
strategy:
fail-fast: false
matrix:
kubernetes-version: ${{ fromJSON(needs.dependencies-versions.outputs.kind-versions) }}
test: ${{ fromJSON(needs.setup-e2e-tests.outputs.test_names) }}
steps:
- name: Download built image artifact
if: inputs.load-local-image
uses: actions/download-artifact@v3
with:
name: kic-image
path: /tmp
- name: Load built image
if: inputs.load-local-image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.20'
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
# We need to pull the Gateway image locally if loading local image was specified.
# This is a "workaround" of the fact that we bind the env variable - responsible for
# indicating whether we'd like to load the images - for both controller
# and gateway. Hence when that's set to true we try to load the Gateway
# image which is available in the external container image registry but not
# locally and that fails.
- name: Pull Gateway image for tests
if: inputs.kong-image != '' && inputs.load-local-image
run: docker pull ${{ inputs.kong-image }}
- name: run ${{ matrix.test }}
run: make test.e2e
env:
E2E_TEST_RUN: ${{ matrix.test }}
KONG_CLUSTER_VERSION: ${{ matrix.kubernetes-version }}
TEST_KONG_CONTROLLER_IMAGE_OVERRIDE: ${{ inputs.kic-image }}
TEST_KONG_LOAD_IMAGES: ${{ inputs.load-local-image }}
TEST_KONG_IMAGE_OVERRIDE: ${{ inputs.kong-image }}
TEST_KONG_KONNECT_ACCESS_TOKEN: ${{ secrets.K8S_TEAM_KONNECT_ACCESS_TOKEN }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
GOTESTSUM_JUNITFILE: "e2e-${{ matrix.test }}${{ matrix.kubernetes-version }}-tests.xml"
- name: upload diagnostics
if: always()
uses: actions/upload-artifact@v3
with:
name: "diagnostics-e2e-tests-${{ matrix.test }}-${{ matrix.kubernetes-version }}"
path: /tmp/ktf-diag*
if-no-files-found: ignore
- name: collect test report
uses: actions/upload-artifact@v3
with:
name: tests-report
path: "*-tests.xml"
gke:
if: inputs.run-gke
environment: "gcloud"
runs-on: ubuntu-latest
needs:
- setup-e2e-tests
- dependencies-versions
strategy:
fail-fast: false
matrix:
kubernetes-version:
- 'v1.26.5'
test: ${{ fromJSON(needs.setup-e2e-tests.outputs.test_names) }}
steps:
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.20'
- uses: Kong/kong-license@master
continue-on-error: true
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
- name: run ${{ matrix.test }}
run: make test.e2e
env:
# NOTE: The limitation of the GKE setup is that we cannot run tests against a local image,
# therefore we need to use the nightly one.
# TODO: Once we have a way to load images into GKE, we can use the local image.
# KTF issue that should enable it: https://github.com/Kong/kubernetes-testing-framework/issues/587
TEST_KONG_CONTROLLER_IMAGE_OVERRIDE: "kong/nightly-ingress-controller:nightly"
TEST_KONG_IMAGE_OVERRIDE: ${{ inputs.kong-image }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
TEST_KONG_KONNECT_ACCESS_TOKEN: ${{ secrets.K8S_TEAM_KONNECT_ACCESS_TOKEN }}
KONG_CLUSTER_VERSION: ${{ matrix.kubernetes-version }}
KONG_TEST_CLUSTER_PROVIDER: gke
E2E_TEST_RUN: ${{ matrix.test }}
GOTESTSUM_JUNITFILE: "e2e-gke-${{ matrix.test }}-${{ matrix.kubernetes-version }}-tests.xml"
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }}
- name: upload diagnostics
if: always()
uses: actions/upload-artifact@v3
with:
name: "diagnostics-e2e-gke-tests-${{ matrix.test }}-${{ matrix.kubernetes-version }}"
path: /tmp/ktf-diag*
if-no-files-found: ignore
- name: collect test report
uses: actions/upload-artifact@v3
with:
name: tests-report
path: "*-tests.xml"
istio:
if: inputs.run-istio
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- kubernetes-version: 'v1.27.3'
istio-version: 'v1.18'
- kubernetes-version: 'v1.26.6'
istio-version: 'v1.17'
- kubernetes-version: 'v1.25.11'
istio-version: 'v1.16'
- kubernetes-version: 'v1.25.11'
istio-version: 'v1.15'
steps:
- name: Download built image artifact
if: inputs.load-local-image
uses: actions/download-artifact@v3
with:
name: kic-image
path: /tmp
- name: Load built image
if: inputs.load-local-image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.20'
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
- name: run Istio tests
run: make test.istio
env:
TEST_KONG_CONTROLLER_IMAGE_OVERRIDE: ${{ inputs.kic-image }}
TEST_KONG_LOAD_IMAGES: ${{ inputs.load-local-image }}
TEST_KONG_IMAGE_OVERRIDE: ${{ inputs.kong-image }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
KONG_CLUSTER_VERSION: ${{ matrix.kubernetes-version }}
ISTIO_VERSION: ${{ matrix.istio-version }}
NCPU: 1 # it was found that github actions (specifically) did not seem to perform well when spawning
# multiple kind clusters within a single job, so only 1 is allowed at a time.
GOTESTSUM_JUNITFILE: "istio-${{ matrix.kubernetes-version }}-${{ matrix.istio-version }}-tests.xml"
- name: upload diagnostics
if: always()
uses: actions/upload-artifact@v3
with:
name: diagnostics-e2e-tests
path: /tmp/ktf-diag*
if-no-files-found: ignore
- name: collect test report
uses: actions/upload-artifact@v3
with:
name: tests-report
path: "*-tests.xml"