Skip to content

Overview

scorbettUM edited this page Feb 26, 2022 · 1 revision

Hedra

Hedra is a load-testing framework and the successor to Autolocust. Unlike Autolocust, Hedra utilizes native asynchronous Python. This offers a multitude of benefits, including more actions-per-second (requests-per-second), multithreading, improved framework stability, and easier integration with third-party tooling like GRPC. Hedra also includes a completely re-written distributed architecture for improved fault-tolerance and scalaibility.


Overview

Hedra offers two main means of writing tests - as Python code and as a JSON request map. Hedra also allows test session config via code, JSON config file, or submitted JSON request to a running job server instance. This allows developers to configure and run tests using most any method they like, with as-code tests allowing the most test flexibility (at the cost of overhead as test code complexity grows), JSON request map tests offering the greatest speed.

Engines

Hedra now offers the following engines (integrations for testing target instances):

  • HTTP

  • HTTP2

  • Fast-HTTP (up to 50% faster)

  • Fast-HTTP2

  • Playwright UI

  • GRPC

  • GraphQL

  • Websocket

for load testing.

Personas

Hedra also now offers the following personas:

  • Default (randomly selected, unsorted)

  • Sequenced (sorted selection)

  • Multi-Sequence (randomly selected ordered sequences)

  • Multi-User Sequence (randomly selects from multiple user sequences).

  • Interval (waits a number of seconds between batches, specified as either a static interval or randomly determined interval within a specified range)

  • Ramped (increases batch size by the specified gradient percentage over the total time specified)

  • Ramped Interval (increases batch timeout/duration by the specified gradient percentage over the total time specified)

  • Weighted (randomly selects the next action based on that action’s weight with respect to the weight/distribution of all other actions' weights)

Pipelines

Finaly, Hedra introduces a third important concept - pipelines. Pipelines represent organized sequences of test stages, with each stage offering unique functionality to assist in running tests. Stages are fixed in order, but can be opted in/out of as needed (unless required). Hedra supports the following stages:

  • Setup (required) - The first stage Hedra runs in a pipeline, the Setup stage is where Hedra will parse actions, setup personas, configure Engine session information, and setup reporting options.

  • Warmup (optional) - The second Stage Hedra offers, the Warmup stage allows you to run a (maximum 60 second) short test duration prior to running the main test. This is ideal for ensuring both target instances and the instance upon which Hedra is running are “scaled up”, avoiding initial slowness due to cold starts.

Note - timing metrics are captured during a warmup stage but are only displayed for user benefit and are not used in calculation of actual test results.

  • Optimization (optional) - The third stage Hedra offers, the Optimization stage allows you to utilize global optimization algorithms to find the best batch size and batch time parameters for the specified test within the specified number of optimization iterations. The best batch size/time values identified are then passed to the subsequent Execution stage.

Warning - Optimization is not time-constrained, so specifying a larger number of iterations or searching over a wide range of batch sizes/times may take an excessive amount of time. For this reason, we do not recommend running the optimization stage for ephemeral or time-sensitive tests.

  • Execution (required) - The fourth stage Hedra runs in a pipeline, the Execution stage is where Hedra executes the specified test, recording timings and storing responses for later parsing during the Results stage.

  • Results (required) - The final stage Hedra runs in a pipeline, the Results stage is where Hedra calculates results from timings and responses collected during the Execution stage.

For distributed execution, note that each worker will independently calculate results for actions it executed during the Results stage. Once the results for that worker’s actions have been calculated, they will be submitted to leader(s), which will then combine and calculate final results from all workers.


Distributed Functionality Additions

Hedra’s distributed functionality, while still in development, allows you to run multiple leaders (with multiple-leader election). Previously, Hedra could only execute distributed tests utilizing a single leader and would exit upon test completion. This functionality has now been incorporated into ephemeral leaders and ephemeral workers, and is ideal for short-duration test runs executed via CI/CD pipelines.

Likewise, in an effort to reduce CI/CD build time, Hedra now offers a fully-specified job environment, where leaders and workers will run continuously and accept jobs as-submitted to a running REST API job server instance. When running in this configuration, Hedra may execute multiple jobs using differing persona, engines, and even pipeline stages. This allows users to easily execute multiple test types at once, target different services, etc.


Tests as Python Code

Hedra also allows you to write and execute tests as Python code. Via Hedra’s new Testing suite, developers can write performance tests as maintainable OOP Python, allowing for testing significantly more complex scenarios than JSON request maps. Currently, this feature is recommended for local use only and has been noted as reducing framework execution speed by 10-20% percent (depending on whether the developer choose to use the Testing library’s convenience methods, built-in sessions, etc.).


Reporting Makes a Return

Many performance testing frameworks make exporting or storing test results a chore. Hedra offers a comprehensive suite of integrations to report results via Reporters. Supported integrations include:

  • Cassandra

  • Datadog

  • Google Cloud Storage

  • JSON File

  • Kafka

  • MongoDB

  • Postgres

  • Prometheus

  • Redis

  • Snowflake

  • Statserve

  • Statstream


Interactive CLI Documentation

Hedra is a complex and sophisticated tool that offers a massive amount of functionality. Although traditional documentation is valuable, users often need only to quickly look up a feature or two when writing tests. To facilitate easier access to documentation without breaking development workflow, Hedra now includes comprehensive, built-in interactive documentation that users can access and view via CLI command queries.

This documentation is organized around topics and sub-topics. A specified topic/sub-topic information not only contains detailed information on what the feature is, but also:

Related and/or required CLI args to use the feature and detailed descriptions of how said arguments/options configure the given feature.

Code examples of how to implement a feature (particular for the Testing library).

Best practices and tips on how to make the most of the feature.

Related topics, allowing developers or users to learn how the feature works in relation to other parts of the Hedra framework.