-
Notifications
You must be signed in to change notification settings - Fork 11
398 lines (343 loc) · 14.6 KB
/
e2e-test.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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
name: E2E Test
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
- labeled
workflow_dispatch:
inputs:
gcr-registry:
required: false
type: string
intents-operator-tag:
required: false
type: string
credentials-operator-tag:
required: false
type: string
workflow_call:
inputs:
github_ref:
required: false
type: string
gcr-registry:
required: false
type: string
intents-operator-tag:
required: false
type: string
credentials-operator-tag:
required: false
type: string
secrets:
AZURE_CREDENTIALS:
required: true
B64_GCLOUD_SERVICE_ACCOUNT_JSON:
required: false
jobs:
test-chart-deployment:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Start minikube
uses: medyagh/setup-minikube@master
with:
start-args: "--network-plugin=cni --cni=calico"
- name: Wait for Calico startup
run: |-
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-node --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Deploy Otterize
run: |-
helm dep up ./otterize-kubernetes
# schema validation using kubectl dry run
OPERATOR_FLAGS=""
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
OPERATOR_FLAGS="$OPERATOR_FLAGS --set-string intentsOperator.operator.repository=${{ inputs.gcr-registry }} --set-string intentsOperator.operator.image=intents-operator --set-string intentsOperator.operator.tag=${{ inputs.intents-operator-tag }} --set-string intentsOperator.operator.pullPolicy=Never"
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
OPERATOR_FLAGS="$OPERATOR_FLAGS --set-string credentialsOperator.operator.repository=${{ inputs.gcr-registry }} --set-string credentialsOperator.operator.image=credentials-operator --set-string credentialsOperator.operator.tag=${{ inputs.credentials-operator-tag }} --set-string credentialsOperator.operator.pullPolicy=Never"
fi
TELEMETRY_FLAG="--set global.telemetry.enabled=false"
kubectl create namespace otterize-system # required for dry-run
helm template otterize ./otterize-kubernetes -n otterize-system $OPERATOR_FLAGS $TELEMETRY_FLAG | kubectl apply --dry-run=server -f -
kubectl delete namespace otterize-system # clean up
# installation
helm install otterize ./otterize-kubernetes -n otterize-system --wait --create-namespace $OPERATOR_FLAGS $TELEMETRY_FLAG
test-postgresql-integration:
permissions:
id-token: write
contents: read
checks: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
cache-dependency-path: tests/go.sum
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Run E2E tests - PostgreSQL integrations
run: |
cd tests
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
export INTENTS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export INTENTS_OPERATOR_TAG=${{ inputs.intents-operator-tag }}
export INTENTS_OPERATOR_IMAGE=intents-operator
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
export CREDENTIALS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export CREDENTIALS_OPERATOR_TAG=${{ inputs.credentials-operator-tag }}
export CREDENTIALS_OPERATOR_IMAGE=credentials-operator
fi
go test -v -json ./databases/postgresql/... | tee /tmp/gotest.log | gotestfmt
- name: Archive test results
uses: actions/upload-artifact@v4
with:
name: test-logs-postgresql
path: /tmp/gotest.log
if-no-files-found: error
if: always()
- name: Generate JUnit report
run: go-junit-report -parser gojson -in /tmp/gotest.log -out /tmp/test_report.xml
if: always()
- name: Test Report
uses: dorny/test-reporter@v1
with:
name: Test report - PostgreSQL integrations
path: /tmp/test_report.xml
reporter: java-junit
fail-on-error: false
badge-title: 'PostgreSQL tests'
if: always() && github.event.pull_request.user.login != 'dependabot[bot]'
test-mysql-integration:
permissions:
id-token: write
contents: read
checks: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
cache-dependency-path: tests/go.sum
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Run E2E tests - MySQL integrations
run: |
cd tests
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
export INTENTS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export INTENTS_OPERATOR_TAG=${{ inputs.intents-operator-tag }}
export INTENTS_OPERATOR_IMAGE=intents-operator
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
export CREDENTIALS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export CREDENTIALS_OPERATOR_TAG=${{ inputs.credentials-operator-tag }}
export CREDENTIALS_OPERATOR_IMAGE=credentials-operator
fi
go test -v -json ./databases/mysql/... | tee /tmp/gotest.log | gotestfmt
- name: Archive test results
uses: actions/upload-artifact@v4
with:
name: test-logs-mysql
path: /tmp/gotest.log
if-no-files-found: error
if: always()
- name: Generate JUnit report
run: go-junit-report -parser gojson -in /tmp/gotest.log -out /tmp/test_report.xml
if: always()
- name: Test Report
uses: dorny/test-reporter@v1
with:
name: Test report - MySQL integrations
path: /tmp/test_report.xml
reporter: java-junit
fail-on-error: false
badge-title: 'MySQL tests'
if: always() && github.event.pull_request.user.login != 'dependabot[bot]'
test-azure-integration:
if: contains(github.event.pull_request.labels.*.name, 'run-azure-e2e-tests') || (github.event_name == 'push' && github.repository == 'otterize/helm-charts' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
concurrency:
group: azure-e2e-tests # do not allow concurrent runs of this job
cancel-in-progress: false
steps:
- name: Fail on custom registry
if: "${{ inputs.gcr-registry != '' }}"
run: |
echo "This job does not support custom docker registry"
exit 1
- name: Checkout repository
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Log in with Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure CLI script
uses: azure/CLI@v2
with:
inlineScript: |
az account show
- name: Set AKS context
uses: azure/aks-set-context@v4
with:
resource-group: 'otterizeGitHubActionsResourceGroup'
cluster-name: 'otterizeAzureIAME2EAKSCluster'
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
cache-dependency-path: tests/go.sum
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Cleanup test namespaces
run: |
kubectl delete namespace otterize-tutorial-azure-iam --ignore-not-found=true --wait
kubectl delete namespace otterize-system --ignore-not-found=true --wait
- name: Run E2E tests - Azure integrations
run: |
cd tests
go test -v -json ./azureiam/... | tee /tmp/gotest.log | gotestfmt
- name: Archive test results
uses: actions/upload-artifact@v4
with:
name: test-logs-azure
path: /tmp/gotest.log
if-no-files-found: error
if: always()
- name: Generate JUnit report
run: go-junit-report -parser gojson -in /tmp/gotest.log -out /tmp/test_report.xml
if: always()
- name: Test Report
uses: dorny/test-reporter@v1
with:
name: Test report - Azure integrations
path: /tmp/test_report.xml
reporter: java-junit
fail-on-error: false
badge-title: 'Azure tests'
if: always() && github.event.pull_request.user.login != 'dependabot[bot]'
e2e-test:
needs:
- test-chart-deployment
- test-postgresql-integration
- test-mysql-integration
runs-on: ubuntu-latest
steps:
- run: |-
echo Success! This step is only here to depend on the tests.