-
Notifications
You must be signed in to change notification settings - Fork 95
141 lines (137 loc) · 6.08 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
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_DS3_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: |
cd apk-repo/test/apim-apk-agent-test/apim-cp-helm-chart
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm dependency build
helm install apim -n apk . --debug --wait --timeout 5m0s \
--set wso2.deployment.image.registry=docker.io \
--set wso2.deployment.image.respository=rakhitharr/wso2am \
--set wso2.deployment.image.digest=sha256:6f647d64753462736bb1bc22b6fe675413278a02623a9c12609b3bc4d1f4a0ef
kubectl get pods -n apk
kubectl get svc -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 dependency build
helm install apk-test-setup -n apk . --debug --wait --timeout 15m0s \
--set wso2.apk.dp.commonController.deployment.controlplane.enabled=true \
--set wso2.apk.dp.commonController.deployment.controlplane.host="apim-apk-agent-service.apk.svc.cluster.local" \
--set wso2.apk.dp.commonController.deployment.controlplane.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-test-setup-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
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-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
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 pods -l app.kubernetes.io/name=apim-apk-agent | awk '{print $1}' | xargs -I{} kubectl logs {} -n apk
helm uninstall apk-test-setup -n apk
cd ../test/apim-apk-agent-test/apim-cp-helm-chart
helm uninstall apim -n apk
cd ../agent-helm-chart
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
if: always()
uses: malinthaprasan/action-surefire-report@v1
with:
report_paths: 'apk-agent-repo/test/postman-tests/build/*.xml'
fail_on_test_failures: true