-
Notifications
You must be signed in to change notification settings - Fork 95
239 lines (233 loc) · 10.7 KB
/
agent-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
name: start and run agent cucumber integration tests
on:
workflow_dispatch:
pull_request_target:
types: [labeled]
concurrency:
group: agent-integration-test-${{ github.event.number || github.run_id }}
cancel-in-progress: true
env:
GH_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
jobs:
runs_agent_cucumber_integration_tests_on_pull_request:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
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 "agent-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}" --enable-cluster-autoscaler --min-count 1 --max-count 3 --location "southeastasia" --node-vm-size Standard_DS4_v2 --generate-ssh-keys
- uses: azure/aks-set-context@v3
with:
resource-group: '${{ secrets.AZURE_RESOURCE_GROUP }}'
cluster-name: 'agent-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}'
- name: Create Namespace apk
shell: sh
run: |
kubectl create namespace apk
kubectl get ns
- 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 APIM CP
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
helm repo add wso2apim https://github.com/wso2/helm-apim/releases/download/cp-4.3.0
helm repo update
helm install apim wso2apim/wso2am-cp --version 4.3.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim/cp/values.yaml -n apk --debug --wait --timeout 5m0s
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.0/deploy/static/provider/cloud/deploy.yaml
kubectl get pods -n apk
kubectl get svc -n apk
kubectl get ing -n apk
- name: Helm release deploy APK DP
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 -n apk . --debug --wait --timeout 15m0s \
--set wso2.apk.cp.enabledSubscription=true \
--set wso2.apk.cp.host="apim-apk-agent-service.apk.svc.cluster.local" \
--set wso2.apk.cp.skipSSLVerification=true \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.JWKSClient.skipSSLVerification=false \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.JWKSClient.hostnameVerifier="AllowAll"
kubectl get pods -n apk
kubectl get svc -n apk
- name: Helm release deploy APIM APK Agent
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-test/agent-helm-chart
helm dependency build
helm install apim-apk-agent -n apk . --debug --wait --timeout 2m0s \
--set controlPlane.serviceURL=https://apim-wso2am-cp-1-service.apk.svc.cluster.local:9443/ \
--set controlPlane.eventListeningEndpoints="amqp://admin:[email protected]:5672?retries='10'&connectdelay='30'" \
--set dataPlane.k8ResourceEndpoint=https://apk-wso2-apk-config-ds-service.apk.svc.cluster.local:9443/api/configurator/apis/generate-k8s-resources
kubectl get pods -n apk
kubectl get svc -n apk
- name: Run test cases(CP to DP Flow)
shell: sh
run: |
cd apk-repo/test/cucumber-tests
sh ./scripts/agent-setup-hosts.sh
./gradlew runCpToDpTests
- name: Helm release undeploy
if: always()
shell: sh
run: |
cd apk-repo/helm-charts
kubectl describe pods -n apk
kubectl get pods -n apk
kubectl get svc -n apk
kubectl get apis -n apk
kubectl get applications -n apk
kubectl get subscriptions -n apk
kubectl get tokenissuers -n apk
kubectl get httproutes -n apk
kubectl get ing -n apk
kubectl get pods -l app.kubernetes.io/name=apim-apk-agent | awk '{print $1}' | xargs -I{} kubectl logs {} -n apk
helm uninstall apk -n apk
helm uninstall apim -n apk
helm uninstall apim-apk-agent -n apk
kubectl delete namespace apk
- name: Publish Test Report(CP to DP Flow)
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: Create Namespace apk
shell: sh
run: |
kubectl create namespace apk
kubectl get ns
- 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 APIM CP
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
helm repo add wso2apim https://github.com/wso2/helm-apim/releases/download/cp-4.3.0
helm repo update
helm install apim wso2apim/wso2am-cp --version 4.3.0 -f https://raw.githubusercontent.com/wso2/apk/main/helm-charts/samples/apim/cp/apk-cp/values.yaml -n apk --debug --wait --timeout 5m0s
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.0/deploy/static/provider/cloud/deploy.yaml
kubectl get pods -n apk
kubectl get svc -n apk
kubectl get ing -n apk
- name: Helm release deploy APK DP(DP to CP Flow)
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 -n apk . \
--set wso2.apk.cp.enabledSubscription=true \
--set wso2.apk.cp.enableApiPropagation=true \
--set wso2.apk.cp.host="apim-apk-agent-service.apk.svc.cluster.local" \
--set wso2.apk.cp.skipSSLVerification=true \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.mandateSubscriptionValidation=true \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.mandateInternalKeyValidation=true \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.JWKSClient.skipSSLVerification=false \
--set wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.JWKSClient.hostnameVerifier="AllowAll"
kubectl get pods -n apk
kubectl get svc -n apk
- name: Helm release deploy APIM APK Agent(DP to CP Flow)
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-test/agent-helm-chart
helm dependency build
helm install apim-apk-agent -n apk . --debug --wait --timeout 2m0s \
--set controlPlane.serviceURL=https://apim-wso2am-cp-1-service.apk.svc.cluster.local:9443/ \
--set controlPlane.eventListeningEndpoints="amqp://admin:[email protected]:5672?retries='10'&connectdelay='30'" \
--set dataPlane.k8ResourceEndpoint=https://apk-wso2-apk-config-ds-service.apk.svc.cluster.local:9443/api/configurator/apis/generate-k8s-resources
--set agent.mode=DPtoCP
kubectl get pods -n apk
kubectl get svc -n apk
- name: Run test cases(DP to CP Flow)
shell: sh
run: |
cd apk-repo/test/cucumber-tests
sh ./scripts/agent-setup-hosts.sh
./gradlew runDpToCpTests
- name: Helm release undeploy
if: always()
shell: sh
run: |
cd apk-repo/helm-charts
kubectl describe pods -n apk
kubectl get pods -n apk
kubectl get svc -n apk
kubectl get apis -n apk
kubectl get applications -n apk
kubectl get subscriptions -n apk
kubectl get tokenissuers -n apk
kubectl get httproutes -n apk
kubectl get ing -n apk
kubectl get pods -l app.kubernetes.io/name=apim-apk-agent | awk '{print $1}' | xargs -I{} kubectl logs {} -n apk
helm uninstall apk -n apk
helm uninstall apim -n apk
helm uninstall apim-apk-agent -n apk
- 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 agent-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(DP to CP Flow)
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