Skip to main content

Developer friendly load testing framework

Project description

PyPI PyPI Build Status

har2locust

Creating a locust file from scratch is sometimes hard. Don't you wish you could just generate it automatically from a browser session?

Well, now you can! har2locust converts your browser recordings (HAR files) into locust files.

Here's an example of a generated file.

At its core har2locust uses a jinja2 template to define the output. You can easily change that to customize your output, or you can go even further and use the plugin system to make any kind of changes to the processing/output.

Installation

pip install har2locust

This will also install locust and locust-plugins, because they are needed to run the generated locustfiles.

Usage

  1. Navigate the web with your browser while recording your activity. Then export the recording into a HAR file. Here is an example with Chrome Devs Tools har.gif

  2. Run har2locust myharfile.har > locustfile.py

> har2locust --help
usage: har2locust [-h] [-t TEMPLATE] [--plugins PLUGINS] [--resource-types RESOURCE_TYPES]
                  [--version] [--loglevel LOGLEVEL]
                  input

positional arguments:
  input                 har input file

options:
  -h, --help            show this help message and exit
  -t TEMPLATE, --template TEMPLATE
                        jinja2 template used to generate locustfile. Defaults to locust.jinja2. Will
                        check current directory/relative paths first and har2locust built-ins second
  --plugins PLUGINS     Comma separated list of extra python files to source, containing decorated
                        methods for processing the har file.
  --resource-types RESOURCE_TYPES
                        Commas separated list of resource types to be included in the locustfile.
                        Supported type are `xhr`, `script`, `stylesheet`, `image`, `font`,
                        `document`, `other`. Defaults to xhr,document,other.
  --version, -V         show program's version number and exit
  --loglevel LOGLEVEL, -L LOGLEVEL

Example usage: har2locust myrecording.har > locustfile

Parameters can also be set using environment variables or config files (har2locust.conf
or ~/.har2locust.conf) For details, see https://goo.gl/R74nmi
  1. You can define "plugins" to process your input and add custom output. The built in plugins (e.g. rest.py) are used by default, and also serve as examples for how to make your own.

  2. Those built in plugins also read two files: .urlignore and .headerignore (from your current directory). Populate them with regexes to filter any unwanted requests or headers from your recordings. Some headers are always ignored (cookie, content-length and chrome's "fake" headers) Here are some examples: .urlignore, .headerignore

Notes

har2locust builds upon har2py, modified to generate a locustfile instead of a basic Python file and extended to support plugins.

har2locust is very new, and before 1.0 there may be changes to interfaces without notice. If you encounter an issue, PRs are very welcome.

Also, dont expect that the generated file will always be very useful out of the box. You'll want to add response validations to ensure the quality of your test, and perhaps parametrize dynamic data like usernames.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

har2locust-0.4.1.tar.gz (25.6 MB view details)

Uploaded Source

Built Distribution

har2locust-0.4.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file har2locust-0.4.1.tar.gz.

File metadata

  • Download URL: har2locust-0.4.1.tar.gz
  • Upload date:
  • Size: 25.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for har2locust-0.4.1.tar.gz
Algorithm Hash digest
SHA256 a82dd31855a4a5cd92bdc5e2833a9206e1e23aef950531a415c86dcd926e3d08
MD5 de2cb85c1d1139a8974bf1d2fe379afd
BLAKE2b-256 392fe55fb0a1d55f5be62166c66f0bf4be8efd1c63006800be8bb6520005a138

See more details on using hashes here.

Provenance

File details

Details for the file har2locust-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: har2locust-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for har2locust-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5ce65272a68c61840716a59c6ba4fcb95e8dd8492b7667c7f5827f6fcda8868
MD5 118f882312af7bf8333402e4b507f9a0
BLAKE2b-256 f9b52b894e47e0a3161cef18b8f550bd8fbf7956952bc597c2878543af9d218c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page