-
Notifications
You must be signed in to change notification settings - Fork 95
365 lines (358 loc) · 18.5 KB
/
integration-test.yml
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
name: start and run cucumber and go integration tests
on:
workflow_dispatch:
pull_request_target:
types: [labeled]
concurrency:
group: integration-test-${{ github.event.number || github.run_id }}
cancel-in-progress: true
env:
GH_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
jobs:
build_adapter:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/adapter-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_common_controller:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/common-controller-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_enforcer:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/enforcer-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_router:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/router-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_ratelimiter:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/ratelimiter-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_config:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/config-deployer-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_idpds:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/idp-domain-service-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build_idpui:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
uses: ./.github/workflows/idp-ui-release.yml
with:
aks_deployment: true
secrets:
APK_BOT_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
APK_BOT_USER: ${{ secrets.APK_BOT_USER }}
APK_BOT_EMAIL: ${{ secrets.APK_BOT_EMAIL }}
DOCKER_ORGANIZATION: ${{ secrets.AZURE_ACR_NAME }}.azurecr.io
AZURE_ACR_NAME: ${{ secrets.AZURE_ACR_NAME }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
runs_go_integration_tests_on_pull_request:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
needs: [build_adapter, build_common_controller, build_enforcer, build_router, build_config,build_idpds,build_idpui,build_ratelimiter]
runs-on: ubuntu-latest
steps:
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create AKS Cluster and set context
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks create --resource-group "${{ secrets.AZURE_RESOURCE_GROUP }}" --name "go-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}" --enable-cluster-autoscaler --min-count 1 --max-count 3 --location "southeastasia" --generate-ssh-keys
- uses: azure/aks-set-context@v3
with:
resource-group: '${{ secrets.AZURE_RESOURCE_GROUP }}'
cluster-name: 'go-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}'
- name: Create Namespace apk-integration-test
shell: sh
run: |
kubectl create namespace apk-integration-test
kubectl get ns
- name: Create Image pull secret.
shell: sh
run: |
kubectl create secret docker-registry azure-registry --docker-server=${{ secrets.AZURE_ACR_NAME }}.azurecr.io --docker-username=${{ secrets.AZURE_ACR_USER }} --docker-password=${{ secrets.AZURE_ACR_PASSWORD }} --docker-email=${{ secrets.APK_BOT_EMAIL }} -n apk-integration-test
- name: Checkout apk-repo.
uses: actions/checkout@v3
with:
fetch-depth: "0"
path: apk-repo
token: ${{ secrets.APK_BOT_TOKEN }}
- name: Set release username and email
shell: sh
run: |
git config --global user.name ${{ secrets.APK_BOT_USER }}
git config --global user.email ${{ secrets.APK_BOT_EMAIL }}
- name: checkout pull request and merge.
shell: sh
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
run: |
cd apk-repo
gh pr checkout ${{ github.event.number }} -b pr-${{ github.event.number }}
git checkout pr-${{ github.event.number }}
git merge origin/main
- name: Helm release deploy
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/helm-charts
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm dependency build
helm install apk-test-setup -n apk-integration-test . --debug --wait --timeout 15m0s \
--set wso2.subscription.imagePullSecrets=azure-registry \
--set wso2.apk.dp.configdeployer.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-config-deployer-service:${{ github.sha }} \
--set wso2.apk.dp.configdeployer.deployment.readinessProbe.failureThreshold=10 \
--set wso2.apk.dp.adapter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-adapter:${{ github.sha }} \
--set wso2.apk.dp.commonController.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-common-controller:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-enforcer:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.router.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-router:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.readinessProbe.failureThreshold=10 \
--set wso2.apk.dp.gatewayRuntime.deployment.router.readinessProbe.failureThreshold=10 \
--set idp.idpds.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-domain-service:${{ github.sha }} \
--set idp.idpui.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-ui:${{ github.sha }} \
--set wso2.apk.dp.ratelimiter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-ratelimiter:${{ github.sha }} \
--set wso2.apk.dp.gateway.httpListener.enabled=true \
--set wso2.apk.dp.gatewayRuntime.deployment.router.configs.enableIntelligentRouting=true
kubectl get pods -n apk-integration-test
kubectl get svc -n apk-integration-test
- name: Archieve Logs
shell: sh
run: |
cd apk-repo
mkdir -p apk-repo/test/integration/podlogs
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=adapter -f > apk-repo/test/integration/podlogs/adapter.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=commoncontroller -f > apk-repo/test/integration/podlogs/common-controller.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=gateway -c enforcer -f > apk-repo/test/integration/podlogs/enforcer.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=gateway -c router -f > apk-repo/test/integration/podlogs/router.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=configdeployer-ds -f> apk-repo/test/integration/podlogs/config-deployer.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=idp-ds -f > apk-repo/test/integration/podlogs/idpds.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=idp-ui -f> apk-repo/test/integration/podlogs/idpui.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=ratelimiter -f> apk-repo/test/integration/podlogs/ratelimiter.log &
ls -l apk-repo/test/integration/podlogs
- name: Run test cases
shell: sh
run: |
cd apk-repo/test/integration
sh ./scripts/setup-hosts.sh
go test -v integration_test.go
- name: Helm release undeploy
if: always()
shell: sh
run: |
cd apk-repo/helm-charts
kubectl describe pods -n apk-integration-test
kubectl get pods -n apk-integration-test
kubectl get svc -n apk-integration-test
helm uninstall apk-test-setup -n apk-integration-test
- name: Delete AKS cluster
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks delete --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --name go-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }} --yes
- name: Logout from azure
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az logout
- name: Publish Test Report
if: always()
uses: malinthaprasan/action-surefire-report@v1
with:
report_paths: 'apk-repo/test/postman-tests/build/*.xml'
fail_on_test_failures: true
- name: Archieve Logs
if: always()
uses: actions/upload-artifact@v2
with:
name: apk-integration-test-go-logs
path: 'apk-repo/test/integration/podlogs/*.log'
runs_cucumber_integration_tests_on_pull_request:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
needs: [build_adapter, build_common_controller, build_enforcer, build_router, build_config,build_idpds,build_idpui,build_ratelimiter]
runs-on: ubuntu-latest
steps:
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create AKS Cluster and set context
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks create --resource-group "${{ secrets.AZURE_RESOURCE_GROUP }}" --name "integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}" --enable-cluster-autoscaler --min-count 1 --max-count 3 --location "southeastasia" --generate-ssh-keys
- uses: azure/aks-set-context@v3
with:
resource-group: '${{ secrets.AZURE_RESOURCE_GROUP }}'
cluster-name: 'integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}'
- name: Create Namespace apk-integration-test
shell: sh
run: |
kubectl create namespace apk-integration-test
kubectl get ns
- name: Create Image pull secret.
shell: sh
run: |
kubectl create secret docker-registry azure-registry --docker-server=${{ secrets.AZURE_ACR_NAME }}.azurecr.io --docker-username=${{ secrets.AZURE_ACR_USER }} --docker-password=${{ secrets.AZURE_ACR_PASSWORD }} --docker-email=${{ secrets.APK_BOT_EMAIL }} -n apk-integration-test
- name: Checkout apk-repo.
uses: actions/checkout@v3
with:
fetch-depth: "0"
path: apk-repo
token: ${{ secrets.APK_BOT_TOKEN }}
- name: Set release username and email
shell: sh
run: |
git config --global user.name ${{ secrets.APK_BOT_USER }}
git config --global user.email ${{ secrets.APK_BOT_EMAIL }}
- name: checkout pull request and merge.
shell: sh
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
run: |
cd apk-repo
gh pr checkout ${{ github.event.number }} -b pr-${{ github.event.number }}
git checkout pr-${{ github.event.number }}
git merge origin/main
- name: Helm release deploy
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/helm-charts
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm dependency build
helm install apk-test-setup -n apk-integration-test . --debug --wait --timeout 15m0s \
--set wso2.subscription.imagePullSecrets=azure-registry \
--set wso2.apk.dp.configdeployer.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-config-deployer-service:${{ github.sha }} \
--set wso2.apk.dp.configdeployer.deployment.readinessProbe.failureThreshold=10 \
--set wso2.apk.dp.adapter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-adapter:${{ github.sha }} \
--set wso2.apk.dp.commonController.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-common-controller:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-enforcer:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.router.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-router:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.readinessProbe.failureThreshold=10 \
--set wso2.apk.dp.gatewayRuntime.deployment.router.readinessProbe.failureThreshold=10 \
--set idp.idpds.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-domain-service:${{ github.sha }} \
--set idp.idpui.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-idp-ui:${{ github.sha }} \
--set wso2.apk.dp.ratelimiter.deployment.image=${{ secrets.AZURE_ACR_NAME }}.azurecr.io/apk-ratelimiter:${{ github.sha }} \
--set wso2.apk.dp.gatewayRuntime.deployment.router.configs.enableIntelligentRouting=true
kubectl get pods -n apk-integration-test
kubectl get svc -n apk-integration-test
- name: Archieve Logs
shell: sh
run: |
cd apk-repo
mkdir -p apk-repo/test/integration/podlogs
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=adapter -f > apk-repo/test/integration/podlogs/adapter.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=commoncontroller -f > apk-repo/test/integration/podlogs/common-controller.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=gateway -c enforcer -f > apk-repo/test/integration/podlogs/enforcer.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=gateway -c router -f > apk-repo/test/integration/podlogs/router.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=configdeployer-ds -f> apk-repo/test/integration/podlogs/config-deployer.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=idp-ds -f > apk-repo/test/integration/podlogs/idpds.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=idp-ui -f> apk-repo/test/integration/podlogs/idpui.log &
kubectl logs -n apk-integration-test -l app.kubernetes.io/app=ratelimiter -f> apk-repo/test/integration/podlogs/ratelimiter.log &
ls -l apk-repo/test/integration/podlogs
- name: Run test cases
shell: sh
run: |
cd apk-repo/test/cucumber-tests
sh ./scripts/setup-hosts.sh
./gradlew runTests
- name: Helm release undeploy
if: always()
shell: sh
run: |
cd apk-repo/helm-charts
kubectl describe pods -n apk-integration-test
kubectl get pods -n apk-integration-test
kubectl get svc -n apk-integration-test
helm uninstall apk-test-setup -n apk-integration-test
- name: Delete AKS cluster
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks delete --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --name integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }} --yes
- name: Logout from azure
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az logout
- name: Publish Test Report
if: always()
uses: malinthaprasan/action-surefire-report@v1
with:
report_paths: 'apk-repo/test/cucumber-tests/build/test-output/junitreports/*.xml'
fail_on_test_failures: true
- name: Archieve Logs
if: always()
uses: actions/upload-artifact@v2
with:
name: apk-integration-test-cucmber-logs
path: apk-repo/test/integration/podlogs/*.log