Skip to main content

Traffic generator based on locust and behave.

Project description

Grizzly - /ˈɡɹɪzli/

Framework:

PyPI - License PyPI PyPI - Python Version GitHub Workflow Status

Command Line Interface:

PyPI - License PyPI PyPI - Python Version GitHub Workflow Status

grizzly logo

Grizzly is a framework to be able to easily define load scenarios, and is mainly built on-top of two other frameworks:

Locust: Define user behaviour with Python code, and swarm your system with millions of simultaneous users.

Behave: Uses tests written in a natural language style, backed up by Python code.

Locust are a group of certain species of short-horned grasshoppers in the family Arcididae that have a swarming phase.

The name grizzly was chosen based on the grasshopper Melanoplus punctulatus, also known as grizzly spur-throat grasshopper. This species prefers living in trees over grass, which is a hint to Biometria1, where grizzly originally was created.

1 Biometria is a member owned and central actor within the swedish forestry that performs unbiased measurement of lumber flowing between forest and industry so that all of Swedens forest owners can feel confident selling their lumber.

Documentation

More detailed documentation can be found here and the easiest way to get started is to check out the example.

Description

behave is abused for being able to define locust load test scenarios using gherkin. A feature can contain more than one scenario and all scenarios will run in parallell.

Feature: Rest API endpoint testing
  Background: Common properties for all scenarios
    Given "2" users
    And spawn rate is "2" user per second
    And stop on first failure

  Scenario: Authorize
    Given a user of type "RestApi" sending requests to "https://api.example.com"
    And repeat for "2" iterations
    And wait time inbetween requests is random between "0.1" and "0.3" seconds
    And value for variable "AtomicDate.called" is "now | format='%Y-%m-%dT%H:%M:%S.00Z', timezone=UTC"
    And value for variable "callback_endpoint" is "none"
    Then post request with name "authorize" from endpoint "/api/v1/authorize?called={{ AtomicDate.called }} | content_type=json"
        """
        {
            "username": "test",
            "password": "password123",
            "callback": "/api/v1/user/test"
        }
        """
    Then save response payload "$.callback" in variable "callback_endpoint"

    Then get request with name "user info" from endpoint "{{ callback_endpoint }} | content_type=json"
    When response payload "$.user.name" is not "Test User" stop user

This makes it possible to implement load test scenarios without knowing python or how to use locust.

Features

A number of features that we thought locust was missing out-of-the-box has been implemented in grizzly.

Test data

Support for synchronous handling of test data (variables). This is extra important when running locust distributed and there is a need for each worker and user to have unique test data, that cannot be re-used.

The solution is heavily inspired by Karol Brejnas locust experiments - feeding the locust. A producer is running on the master (or local) node and keeps track of what has been sent to the consumer running on a worker (or local) node. The two communicates over a seperate ZeroMQ session.

When the consumer wants new test data, it sends a message to the server that it is available and for which scenario it is going to run. The producer then responds with unique test data that can be used.

Statistics

Listeners for both InfluxDB and Azure Application Insights are included. The later is more or less appinsights_listener.py, from the good guys at Svenska Spel, but with typing.

They are useful when history of test runs is needed, or when wanting to correlate load tests with other events in the targeted environment.

Load test users

locust comes with a simple user for loading an HTTP(S) endpoint and due to the nature of how the integration between behave and locust works in grizzly, it is not possible to directly use locust.user.users provided users, even for HTTP(S) targets.

  • RestApiUser: send requests to REST API endpoinds, supports authentication with username+password or client secret
  • ServiceBusUser: send to and receive from Azure Service Bus queues and topics
  • MessageQueueUser: send and receive from IBM MQ queues
  • SftpUser: send and receive files from an SFTP-server
  • BlobStorageUser: send files to Azure Blob Storage2

2 A pull request for functionality in the other direction is appreciated!

Request log

All failed requests are logged to a file which includes both header and body, both for request and response.

Installation

pip3 install grizzly-loadtester
pip3 install grizzly-loadtester-cli

Do not forget to try the example which also serves as a boilerplate scenario project, or create a new grizzly project with:

grizzly-cli init my-grizzly-project

Development

The easiest way to start contributing to this project is to have Visual Studio Code (with "Remote - Containers" extension) and docker installed. The project comes with a devcontainer, which encapsulates everything needed for a development environment.

It is also possible to use a python virtual environment where requirements-dev.txt is installed.

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

grizzly-loadtester-2.4.3.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

grizzly_loadtester-2.4.3-py3-none-any.whl (155.3 kB view details)

Uploaded Python 3

File details

Details for the file grizzly-loadtester-2.4.3.tar.gz.

File metadata

  • Download URL: grizzly-loadtester-2.4.3.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.5

File hashes

Hashes for grizzly-loadtester-2.4.3.tar.gz
Algorithm Hash digest
SHA256 12da2fd7c6fe1438ac7100460cd1a54a728842f02b02ad44ee7d4260c2cf69b9
MD5 2b9133451fd35bb0c01fbaa5bc34a431
BLAKE2b-256 c5c1b67995427e8f700a6ffe9c493bc200251d3c9e9be9882b8854f708d67d7b

See more details on using hashes here.

File details

Details for the file grizzly_loadtester-2.4.3-py3-none-any.whl.

File metadata

  • Download URL: grizzly_loadtester-2.4.3-py3-none-any.whl
  • Upload date:
  • Size: 155.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.5

File hashes

Hashes for grizzly_loadtester-2.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c7459d8591115ca27d9dd757ff49c44041e2ce923c66559c2ec5d06fd9e165b2
MD5 095b2c6e64b27fd1ed6c3eaeb88044d8
BLAKE2b-256 cd966756a8aa559d86f05998ff0dec42b6ad7622b72a3a7dcd947d9803e48915

See more details on using hashes here.

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