LiveLoad (LiveLoad v0.0.1-rc.17)

Copy Markdown View Source

A load testing framework for simulating real, distributed, live load on your application.

DISCLAIMER

The LiveLoad repo is currently private as I am building out the functionality and validating that it works as expected.

If you come across this package and are installing it for some reason - just know that it's not public yet because I haven't actually tested it at all. There might not even be any code in here yet - I literally just started the project and set up my CI/CD pipelines (it's a default thing I do when I start a project, I'm weird like that). I will make it public (and update this description to remove this disclaimer) as I build and test it out. Or - if it doesn't work out, I'll simply delete it.

Installation

LiveLoad is available on Hex.

To install, add it to you dependencies in your project's mix.exs.

def deps do
  [
    {:live_load, ">= 0.0.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/live_load.

Summary

Types

Defines the LiveLoad.Browser.Connection implementation to use for this run.

Configures the run to be distributed.

Initialization options for running a LiveLoad.Scenario.

Defines the OTP application to load test.

Defines the duration of the entire load test for a specific scenario.

Defines the timeout for a single iteration of a scenario.

Run a single scenario module.

Run a list of scenario modules.

Configures the number of user processes to use for the run.

Functions

Run all of the LiveLoad.Scenario modules in this project.

Types

browser_connection_adapter_opt()

@type browser_connection_adapter_opt() ::
  {:browser_connection_adapter, LiveLoad.Browser.Connection.t()}

Defines the LiveLoad.Browser.Connection implementation to use for this run.

Defaults to LiveLoad.Browser.Connection.Playwright.

distributed_run_opt()

@type distributed_run_opt() :: {:distributed?, boolean()}

Configures the run to be distributed.

When set to true, LiveLoad will use FLAME to build an ad-hoc pool of nodes based on the given FLAME.Pool configuration and evenly distribute the users across these nodes during the run.

Defaults to false.

option()

Initialization options for running a LiveLoad.Scenario.

These are split between options for the overall run configuration (distributed_run_opt/0, users_count_opt/0), options for the runner itself (browser_connection_adapter_opt/0, scenario_iteration_timeout_opt/0, scenario_duration_opt/0) and any other options that should be passed in as configuration to the scenario LiveLoad.Scenario.config/1 callback.

otp_app_opt()

@type otp_app_opt() :: {:otp_app, atom()}

Defines the OTP application to load test.

This option is used in order to automatically discover LiveLoad.Scenario modules implemented in the given application. Similarly to Ecto Migrations, LiveLoad will scan the given OTP application, find all LiveLoad.Scenario modules, and then run these scenarios for a load test.

This option is required unless a scenario_opt/0 or a scenarios_opt/0 is given, in which case only the given scenario modules will be run.

This option takes the lowest priority.

scenario_duration_opt()

@type scenario_duration_opt() :: {:scenario_duration, timeout()}

Defines the duration of the entire load test for a specific scenario.

When running a load test, the scenario's LiveLoad.Scenario.run/3 callback will be run in a loop multiple times until this value is reached. Once reached, the runner will transition to a terminating state and wait for the latest iteration of the scenario to complete, and then report its completion.

Defaults to 10 minutes.

Note: while the type here is set to timeout/0, the :infinity value is invalid and an error will be returned if it is passed.

scenario_iteration_timeout_opt()

@type scenario_iteration_timeout_opt() :: {:iteration_timeout, timeout()}

Defines the timeout for a single iteration of a scenario.

If this timeout is reached and the scenario has not completed, it will be killed and the user's status will reported as a failure. No other iterations will take place for that user.

Defaults to 2 minutes.

Note: while the type here is set to timeout/0, the :infinity value is invalid and an error will be returned if it is passed.

scenario_opt()

@type scenario_opt() :: {:scenario, LiveLoad.Scenario.t()}

Run a single scenario module.

This option is mutually exclusive with scenarios_opt/0 and otp_app_opt/0, each of which configure which scenarios should be run.

This option takes the highest priority.

scenarios_opt()

@type scenarios_opt() :: {:scenarios, [LiveLoad.Scenario.t()]}

Run a list of scenario modules.

This option is mutually exclusive with scenario_opt/0 and otp_app_opt/0, each of which configure which scenarios should be run.

This option takes the second highest priority.

users_count_opt()

@type users_count_opt() :: {:users, pos_integer()}

Configures the number of user processes to use for the run.

Defaults to a single user.

Functions

run(opts \\ [])

@spec run(opts :: [option()]) :: %{
  required(LiveLoad.Scenario.t()) => LiveLoad.Result.t() | {:error, term()}
}

Run all of the LiveLoad.Scenario modules in this project.

Scenarios are automatically discovered. They are run using FLAME and :amoc.

TODO: Give actual documentation here!