robotframework-locust

Load tests you write as Robot suites.

A Robot Framework library that builds and runs Locust. Write the load in keywords, watch it in Locust Studio, or bring a k6 script you already have.

Keyword reference

Three ways in

Write it in Robot

Build users, run them headless, check the stats.

*** Settings ***Library    LocustLibrary *** Test Cases ***Shop Under Load    Create Load Test    http://127.0.0.1:8765    ...    allowed_hosts=127.0.0.1    Add Stop Rule    p95 > 2s for 10s    Add User Class    Browser    weight=3    Set Wait Time    0.2s    0.6s    Add Get Request    items    ...    /items.json    ...    expected_text=sku    Add User Class    Checker    weight=1    Set Pacing    1s    Add Get Request    health    ...    /health.txt    Set Load Stages    10s:10    20s:20    ...    5s:0    Run Load Test    max_users=50    Should Meet Response Time    aggregated    ...    p95    500ms    Export Report    shop
robot shop_load.robot

Watch it run

Open a suite in Locust Studio and press Run. The table and charts update every second.

Locust Studio after a 20-user run: the stats table for three requests with no failures, and charts for requests per second, response times and users.
pip install "robotframework-locust[studio]"
locust-studio

Bring your k6 script

Stages, thresholds and plain requests become keywords.

export const options = {  stages: [    { duration: '30s', target: 20 },    { duration: '1m', target: 20 },    { duration: '10s', target: 0 },  ],  thresholds: {    http_req_duration: ['p(95)<500'],    http_req_failed: ['rate<0.01'],  },};
pip install "robotframework-locust[k6]"
rflocust-k6 checkout.js

Your k6 script, as a Robot suite.

rflocust-k6 reads the options with k6 inspect, scans the exported functions for plain HTTP calls, and writes a Robot project. This is its real output for the script on the left.

checkout.js
import http from 'k6/http';import { sleep } from 'k6'; export const options = {  stages: [    { duration: '30s', target: 20 },    { duration: '1m', target: 20 },    { duration: '10s', target: 0 },  ],  thresholds: {    http_req_duration: ['p(95)<500'],    http_req_failed: ['rate<0.01'],  },}; export default function () {  http.get('http://127.0.0.1:8765/items.json');  sleep(1);}
robot/collections/checkout_test_keywords.resource
Test Checkout Load    [Documentation]    Builds the users, runs the load, then checks it.    Build Checkout Users    Run Checkout Load    Check Checkout Load Build Checkout Users    [Documentation]    One user class per k6 scenario, weighted by its peak users.    Create Load Test    ${HOST}    verify_tls=${True}    proxy=${PROXY}    Add User Class    default    weight=20    Set Wait Time    1s    1s    Add Python Task    default    checkout_tasks.default Run Checkout Load    [Documentation]    Runs the converted k6 load profile headless.    Set Load Stages    30s:20    60s:20    10s:0    Run Load Test    max_users=100    Export Report    checkout Check Checkout Load    [Documentation]    The converted k6 thresholds.    Should Meet Response Time    aggregated    p95    500ms    Should Meet Error Rate    1%
k6LocustLibraryReport
ramping-vus stagesSet Load Stagesmapped
constant-vus, shared-iterationsRun Load Test with users, run time and iterationsmapped
http_req_duration p50 to p99.9Should Meet Response Timemapped
http_req_failed rateShould Meet Error Ratemapped
arrival-rate executorsRun Load Test with looping usersapproximate
a call the scanner cannot reada Python task that raises until you port ithand port

The converter never runs k6 run. k6 inspect runs the script's init code as you, so convert only scripts you trust. The full mapping.

Run the suite. Watch it.

Locust Studio opens a suite, runs it under Robot at low priority, and charts it every second.

Locust Studio in the dark Graphite theme, 18 seconds into a run: the stats table fills while the requests and users charts climb.
18 seconds into a 20-user run.

Studio reads the suite with a Robot dry run, so nothing is sent until you press Run. The sidebar lists each user class, its pacing and the stop rules.

When the run ends, the Report tab opens the Robot log and the Locust HTML report. Studio has a dark and a light theme, and runs on Windows and Linux.

The Report tab in the light Paper theme: the request count with no failures, and buttons that open the Robot log and the Locust report.
The Report tab, light theme.

It stops before it hurts anyone.

A user ceiling, a host allowlist, stop rules and a failure breaker keep a run in bounds. Read the limits before you point a run at a host you do not own.