Debugging Load Tests

Keep your test scripts modular by separating test logic, data, and configuration. This makes debugging easier and allows for better test maintenance.

If your LoadForge test fails, it may be due to errors in your Locustfile. These could be simple Python syntax errors or issues with how the test is defined.

1. Use the Test Debugger

LoadForge provides a built-in test debugger that runs your test and attempts to send requests through it. This is the easiest way to diagnose common issues.

👉 Head over to the Test Debugger to get started.

If your test isn’t running, the debugger will highlight syntax errors, request failures, or misconfigurations in real time.

2. Test Locally

Before running a test in LoadForge, you can validate your Locustfile locally to catch syntax errors.

Check for Syntax Errors

To ensure your test script is correctly formatted, save it as a Python file (example.py) and run:

python -m py_compile example.py

This will catch basic Python syntax errors before you attempt a full test.

Run a Local Locust Test

To execute your test locally, first install Locust and dependencies:

sudo apt-get -y install unzip python3-pip libxml2-dev libxslt1-dev python3-dev

sudo pip3 install --prefer-binary locust pyquery uuid gevent websocket \
 Flask gevent-websocket greenlet itsdangerous Jinja2 linecache2 \
 MarkupSafe mock msgpack pyzmq==22.3.0 requests six traceback2 \
 unittest2 websocket-client Werkzeug jsonpath-ng PyMySQL \
 sqlalchemy pg8000 xmltodict pandas oauthlib==3.2.0 splinter \
 requests-oauthlib websockets websocket-client beautifulsoup4 \
 web3 eth-account locust-plugins locust-plugins[appinsights] \
 opencensus==0.7.12 opencensus-ext-azure==1.0.6 Faker

Then, run your test using Locust:

locust -f example.py --host https://YOUR_HOST_HERE -u 10 -r 10 \
    --run-time 1m --headless

This executes a 1-minute test with 10 sample users, helping you identify issues before deploying to LoadForge.

If your test runs locally but fails in LoadForge, check for network restrictions, authentication issues, or host validation problems.

3. Additional Debugging Tips

Use ChatGPT for Debugging

LoadForge test scripts follow a Locust-based format, which ChatGPT understands well. If you’re stuck, try:

  • Copy-pasting your Locustfile into ChatGPT and asking it to check for errors.
  • Describing your issue and asking for debugging advice.
  • Requesting optimizations to improve script performance.

ChatGPT can help debug syntax errors, request failures, and suggest improvements to your load test.

Enable Logging in Locust

If you’re unsure what’s failing, enable verbose logging by modifying your script:

import logging
logging.basicConfig(level=logging.DEBUG)

This will output detailed logs during the test execution, showing request failures and bottlenecks.

Check LoadForge Errors & Logs

If your test fails in LoadForge, check:

  • Run Results Page for error messages.
  • Response time metrics to see if timeouts are occurring.
  • Error logs for HTTP status codes (e.g., 401 Unauthorized, 500 Internal Server Error).

4. Request Support

If you still need help, contact LoadForge support:

The LoadForge team is happy to assist with Locustfile issues, test configuration, and debugging complex scenarios.

If you’re unsure what’s wrong, share your test script and error logs with LoadForge support for faster troubleshooting.

By following these debugging steps, you can quickly diagnose and fix issues, ensuring smooth and reliable load tests in LoadForge!