This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Adding test cases
Before you begin
This document assumes that you have completed the instructions in the following guides.
Test cases are available in the chart source repository under a directory named “tests”. This step by step guide demonstrates how you can add test cases to your WSO2 API Microgateway pipeline
Create a fork of the sample chart source repository.
Create a clone of the forked chart source repository using the following command.
$ git clone https://github.com/<ORGANIZATION_NAME>/cicd-sample-chart-mgw.git
Replace the <ORGANIZATION_NAME> tag with the name of your GitHub organization.In the sample chart repository, observe the sample test script provided in cicd-sample-chart- mgw/tests and open test.sh
This script in the test.sh file checks if the server has successfully started by performing health checks on Microgateway endpoints. If the desired response, of any of the provided endpoints, are not met, the script throws a non-zero exit code causing the test to fail.Uncomment the health check endpoints provided in the sample test script.
declare -a healthcheckEndpoints=( "https://wso2micro-gw-service.wso2mgw-staging.svc.cluster.local:9095/petstore/v1/pet/findByStatus?status=available" # "Endpoint 2" # "Endpoint 3" )
Change the chart repository in the sample values file used in the Getting Started Guide to use a custom chart.
applications: - name: wso2mgw email: <EMAIL> testScript: path: tests command: test.sh chart: customChart: false name: microgateway version: 3.0.1-1 repo: 'https://github.com/<ORGANIZATION_NAME>/cicd-sample-chart-mgw
Upgrade the Helm chart with the command below, providing the modified sample values file.
$ helm upgrade <RELEASE_NAME> wso2/kubernetes-pipeline -f values-mgw.yaml
This may take up to 10 minutes.Restart the Jenkins pod by deleting the existing pod. This will cause the cluster to spawn a new pod for Jenkins.
$ POD_NAME=`kubectl get pods --selector=app=jenkins -n <NAMESPACE> -o json -o jsonpath='{ .items[0].metadata.name }'`
$ kubectl delete pod $POD_NAME -n <NAMESPACE>
Replace <NAMESPACE> with the namespace in your cluster.
Commit and push the changes in your forked chart source repository.
$ git add . $ git commit -m “Add health check test cases” $ git push origin master
Testing the added Testcase:
If there are any manual judgments pending on an existing environment halt it, and watch the deployment of the setup with test cases being deployed in the Spinnaker dashboard.
Once the deployment has been made to the Dev environment, continue the manual judgment into Staging.
If the tests are successful, you will be prompted to continue the deployment into production.
If the staging deployment prompts for a manual judgement for deployment into production,
your tests have successfully passed!