CI/CD Integration: Automate Testing in Your Development Pipelines

These instructions detail how to integrate Ratl into your CI/CD pipeline using public APIs across Jenkins, GitHub Actions, Azure DevOps (ADO) Pipelines, and GitLab. Each setup guide below provides steps for starting load, API, e2e, and web automation tests, fetching reports, and checking test statuses.

Prerequisites

  1. API Key (refer the guide here):

    • Go to Organisation > API Keys.

    • Click Create API Key.

    • Copy the generated API key for use in the CI/CD pipeline.

  2. IDs:

    • Simply navigate to the listing page of the specific tests, where you can copy the required IDs directly.

Jenkins Integration

Load Tests

pipeline {
    agent any

    stages {
        stage('Start Load Test') {
            steps {
                script {
                    sh 'curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
                    -H "api-key: <YOUR_API_KEY>" \
                    -H "Content-Type: application/json" \
                    -d \'{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}\''
                }
            }
        }

        stage('Check Load Test Status') {
            steps {
                script {
                    sh '''
                    STATUS="running"
                    while [ "$STATUS" == "running" ]; do
                        STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
                        -H "api-key: <YOUR_API_KEY>" \
                        -G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status)
                        echo "Current status: $STATUS"
                        sleep 10
                    done
                    '''
                }
            }
        }

        stage('Get Load Test Report') {
            steps {
                script {
                    sh 'curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
                    -H "api-key: <YOUR_API_KEY>" \
                    -G --data-urlencode "simulation_id=<SIMULATION_ID>"'
                }
            }
        }
    }
}

API Tests

E2E Tests

Web Automation

Azure DevOps (ADO) Pipelines Integration

Load Tests

API Tests

E2E Tests

Web Automation

GitHub Actions Integration

Load Tests

API Tests

E2E Tests

Web Automation

GitLab CI/CD Integration

Load Tests

API Tests

E2E Tests

Web Automation

Instructions

  • Insert API Key: Replace <YOUR_API_KEY> with your actual API key in all scripts.

  • Simulation ID and Project ID: For load tests, replace <SIMULATION_ID> and <WORKSPACE_ID> with the appropriate values.

  • Suite ID: For API tests, replace <SUITE_ID> with the appropriate value.

  • Flow ID: For E2E tests, replace <FLOW_ID> with the appropriate value.

  • Status Check: For load tests, the script checks the status every 10 seconds and proceeds once the status is no longer "running".

  • Execution:

    • Load Tests: Run the pipeline to start the load test, check its status, and fetch the report.

    • API Tests: Run the pipeline to start the API test and fetch its report.

    • E2E Tests: Run the pipeline to start the E2E test and fetch its report.

    • Web Automation Tests: Run the pipeline to start the web automation tests.

Note: These scripts use jq to parse JSON responses, so ensure jq is installed on the agents. Adjust the sleep duration as needed based on your test's expected duration.

Last updated