ratl.ai
Try Now ↗
  • Welcome
  • Getting Started
    • Quickstart
    • Understanding Testing Modes
  • MANAGE ACCOUNT
    • Organizations and Workspaces
    • Managing API Keys
  • FEATURES
    • Overview
    • Understanding Dashboard: A Complete Guide
    • Talking to Agents: A Comprehensive Guide for Interactions
    • API Functional Tests: A Comprehensive Solution for Automated Testing
    • Load and Performance Testing: A Comprehensive Solution for High Traffic Simulation
    • API Integration E2E Tests: A Comprehensive Solution for Automated Integration Testing
    • Web Automation: AI-Powered Visual Testing Solution
    • Schedules: Automate and Manage Test Execution Timing
    • Run History: Tracking and Managing Your Test Executions
  • INTEGRATIONS
    • Overview
    • CI/CD Integration: Automate Testing in Your Development Pipelines
    • Slack Integration: Real-Time Test Updates and Collaboration
    • Azure DevOps (ADO) Integration: Streamline Bug Tracking
    • Jira Integration: Simplify Bug Tracking and Test Management
    • Kubernetes Integration: Deploy Ratl Load Injectors On-Premises
  • CREDITS
    • Credit Management Overview
  • PUBLIC APIs
    • API Documentation
Powered by GitBook
On this page
  • Prerequisites
  • Jenkins Integration
  • Azure DevOps (ADO) Pipelines Integration
  • GitHub Actions Integration
  • GitLab CI/CD Integration
  1. INTEGRATIONS

CI/CD Integration: Automate Testing in Your Development Pipelines

PreviousOverviewNextSlack Integration: Real-Time Test Updates and Collaboration

Last updated 1 month ago

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 :

    • 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

pipeline {
    agent any

    stages {
        stage('Start API Test') {
            steps {
                script {
                    sh '''
                    curl -X POST "https://api.studio.ratl.ai/public/api/v1/api/start" \
                    -H "api-key: <YOUR_API_KEY>" \
                    -G --data-urlencode "suite_id=<SUITE_ID>"
                    '''
                }
            }
        }

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

E2E Tests

pipeline {
    agent any

    stages {
        stage('Start E2E Test') {
            steps {
                script {
                    sh '''
                    curl -X POST "https://api.studio.ratl.ai/public/api/v1/e2e/start" \
                    -H "api-key: <YOUR_API_KEY>" \
                    -G --data-urlencode "flow_id=<FLOW_ID>"
                    '''
                }
            }
        }

        stage('Get E2E Test Report') {
            steps {
                script {
                    sh '''
                    curl -X POST "https://api.studio.ratl.ai/public/api/v1/e2e/report" \
                    -H "api-key: <YOUR_API_KEY>" \
                    -G --data-urlencode "flow_id=<FLOW_ID>"
                    '''
                }
            }
        }
    }
}

Web Automation

pipeline {
    agent any

    stages {
        stage('Start Web Automation') {
            steps {
                script {
                    sh '''
                    curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
                    -H "api-key: <YOUR_API_KEY>)" \
                    -G --data-urlencode "webshot_id=<WEBSHOT_ID>"
                    '''
                }
            }
        }

        stage('Get Web Automation Versions') {
            steps {
                script {
                    sh '''
                    curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
                    -H "api-key: <YOUR_API_KEY>"
                    '''
                }
            }
        }
    }
}

Azure DevOps (ADO) Pipelines Integration

Load Tests

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      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>"}'
    displayName: 'Start Load Test'

  - script: |
      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
    displayName: 'Check Load Test Status'

  - script: |
      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>"
    displayName: 'Get Load Test Report'

API Tests

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
      -H "api-key: $(YOUR_API_KEY)" \
      -G --data-urlencode "suite_id=<SUITE_ID>"
    displayName: 'Start API Test'

  - script: |
      mkdir -p $(Build.ArtifactStagingDirectory)/reports
      curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
      -H "api-key: $(YOUR_API_KEY)" \
      -G --data-urlencode "suite_id=<SUITE_ID>"
      -o $(Build.ArtifactStagingDirectory)/reports/report.pdf
    displayName: 'Get API Test Report'

  - task: PublishBuildArtifacts@1
    inputs:
      pathToPublish: '$(Build.ArtifactStagingDirectory)/reports'
      artifactName: 'PDFReport'
      publishLocation: 'Container'

E2E Tests

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
      -H "api-key: $(YOUR_API_KEY)" \
      -G --data-urlencode "flow_id=<FLOW_ID>"
    displayName: 'Start E2E Test'

  - script: |
      curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
      -H "api-key: $(YOUR_API_KEY)" \
      -G --data-urlencode "flow_id=<FLOW_ID>"
    displayName: 'Get E2E Test Report'

Web Automation

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
      -H "api-key: $(YOUR_API_KEY)" \
      -G --data-urlencode "webshot_id=<WEBSHOT_ID>"
    displayName: 'Start Web Automation'

  - script: |
      curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
      -H "api-key: $(YOUR_API_KEY)"
    displayName: 'Get Web Automation Report'

GitHub Actions Integration

Load Tests

name: Load Test

on:
  workflow_dispatch:

jobs:
  load-test:
    runs-on: ubuntu-latest

    steps:
      - name: Start Load Test
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -H "Content-Type: application/json" \
          -d '{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}'
      
      - name: Check Load Test Status
        run: |
          STATUS="running"
          while [ "$STATUS" == "running" ]; do
              STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
              -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
              -G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status)
              echo "Current status: $STATUS"
              sleep 10
          done

      - name: Get Load Test Report
        run: |
          curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "simulation_id=<SIMULATION_ID>"

API Tests

name: API Test

on:
  workflow_dispatch:

jobs:
  api-test:
    runs-on: ubuntu-latest

    steps:
      - name: Start API Test
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "suite_id=<SUITE_ID>"
      
      - name: Get API Test Report
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "suite_id=<SUITE_ID>"

E2E Tests

name: E2E Test

on:
  workflow_dispatch:

jobs:
  e2e-test:
    runs-on: ubuntu-latest

    steps:
      - name: Start E2E Test
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "flow_id=<FLOW_ID>"
      
      - name: Get E2E Test Report
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "flow_id=<FLOW_ID>"

Web Automation

name: Web Automation Test

on:
  workflow_dispatch:

jobs:
  webAutomation-test:
    runs-on: ubuntu-latest

 steps:
      - name: Start Web Automation Review
        run: |
          curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}" \
          -G --data-urlencode "webshot_id=<WEBSHOT_ID>"
      
      - name: Get Web Automation Versions
        run: |
          curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
          -H "api-key: ${{ secrets.YOUR_API_KEY }}"

GitLab CI/CD Integration

Load Tests

stages:
  - load_test_run
  - load_test_report

variables:
  YOUR_API_KEY: $YOUR_API_KEY

load_test_run:
  stage: load_test_run
  script:
    - 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>"}'
    - 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

load_test_report:
  stage: load_test_report
  script:
    - 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

stages:
  - api_test_run
  - api_test_report

variables:
  YOUR_API_KEY: $YOUR_API_KEY

api_test_run:
  stage: api_test_run
  script:
    - curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
      -H "api-key: $YOUR_API_KEY" \
      -G --data-urlencode "suite_id=<SUITE_ID>"

api_test_report:
  stage: api_test_report
  script:
    - curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
      -H "api-key: $YOUR_API_KEY" \
      -G --data-urlencode "suite_id=<SUITE_ID>"

E2E Tests

stages:
  - e2e_test_run
  - e2e_test_report

variables:
  YOUR_API_KEY: $YOUR_API_KEY

e2e_test_run:
  stage: e2e_test_run
  script:
    - curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
      -H "api-key: $YOUR_API_KEY" \
      -G --data-urlencode "flow_id=<FLOW_ID>"

e2e_test_report:
  stage: e2e_test_report
  script:
    - curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
      -H "api-key: $YOUR_API_KEY" \
      -G --data-urlencode "flow_id=<FLOW_ID>"

Web Automation

stages:
  - webshot_test_run
  - webshot_test_report

variables:
  YOUR_API_KEY: $YOUR_API_KEY

webshot_test_run:
  stage: webshot_test_run
  script:
    - curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
      -H "api-key: $YOUR_API_KEY" \
      -G --data-urlencode "webshot_id=<WEBSHOT_ID>"

webshot_test_report:
  stage: webshot_test_report
  script:
    - curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
      -H "api-key: $YOUR_API_KEY"

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.

(refer the guide here)