Adding initial apk agent integration tests #42
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:admin@apim-wso2am-cp-1-service.apk.svc.cluster.local: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 |