All docs This doc
Skip to end of metadata
Go to start of metadata

Before you begin

This document assumes that you have completed the instructions in the following guides.

  1. Quick Start Guilde

  2. Deploying your first environment

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

  1. Create a fork of the sample chart source repository.

  2. 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.
  3. 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.
  4. 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"
    
    )
  5. 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
  6. 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.
  7. 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.


  8. 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:

  1. 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.

  2. Once the deployment has been made to the Dev environment, continue the manual judgment into Staging.

  3. 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!


What's Next :

This guide demonstrates how you can add your own test cases.

Before you begin

This document assumes that you have completed the Quick Start Guide.

  1. Testcases are available in the artifacts source repository under a directory named “tests”.
  2. Create a fork of the sample test repository. 

  3. Go to AWS Cloudformation page.

  4. Select the Jenkins Stack. Click Update.

  5. Select Use current template and Click Next.

  6. Change the Artifacts Repository (git) to your forked repository URL in step 1.

  7. Create a clone of the forked repository. You can use the below command in command line.

    $ git clone https://github.com/<your-github-name>/aws-cicd-apim-sample.git

    Sample artifact repository will be cloned into your current working directory.

  8. In the sample artifacts repository, observe the sample test script by navigating to /tests/wso2am/src/test/java/org/wso2/ApimTest.java

    This test is added to a Maven test suite. The apimTest.java file checks if the server has successfully started by performing a health check on APIM endpoint.

  9. Write your own test case.

  10. Include  your own test inside /tests/wso2am/src/test/java/org/wso2/folder.

  11. Add the test case to Maven test suite. Maven test suite can be found attests/wso2am/src/test/resources/ folder.
    Edit testng.xml by adding the name of your test class.


      <classes> 
        <class name= “org.wso2.<your test class name>”/>
    </classes>


  12. Commit and push the changes to master branch in your repository.

What's Next :


  • No labels