View Source Chaperon.LoadTest (chaperon v0.3.1)

Implementation & helper module for defining load tests. A load test defines a list of scenarios and their config to run them with.

example

Example

defmodule LoadTest.Staging do
  use Chaperon.LoadTest

  # You can define a default config that is used by default.
  # Any additional config passed at runtime will be merged into this.
  # If default_config/0 is not defined, it defaults to %{}.
  def default_config, do: %{
    scenario_timeout: 15_000,
    base_url: "http://staging.mydomain.com"
  }

  def scenarios, do: [
    # session name is "my_session_name"
    {MyScenarioModule, "my_session_name", %{
      delay: 2 |> seconds,
      my_config_key: "my_config_val"
    }},

    # will get an assigned session name based on module name and UUID
    {MyScenarioModule, %{
      delay: 10 |> seconds,
      my_config_key: "my_config_val"
    }},

    # same as above but spawned 10 times (across the cluster):
    {{10, MyScenarioModule}, "my_session_name", %{
      random_delay: 5 |> seconds,
      my_config_key: "my_config_val"
    }},

    # run Scenario A, followed by Scenario B as a new scenario
    {[A, B], %{
      # ...
    }},

    # same as above, but spawned 10 times
    {{10, [A, B]}, %{
      # ...
    }}
  ]
end

Link to this section Summary

Link to this section Types

@type lt_conf() ::
  module()
  | %{name: String.t(), scenarios: [Chaperon.Scenario.t()], config: map()}
@type t() :: %Chaperon.LoadTest{
  config: map(),
  name: atom(),
  scenarios: [Chaperon.Scenario.t()]
}

Link to this section Functions

Link to this function

await_workers(tasks_with_config)

View Source
@spec default_config(lt_conf()) :: any()
@spec merge_sessions(Chaperon.LoadTest.Results.t()) :: Chaperon.Session.t()

Merges metrics & results of all Chaperon.Sessions in a list.

@spec name(lt_conf()) :: String.t()
@spec prepare_merge(Chaperon.Session.t()) :: Chaperon.Session.t()

Prepares session to be merged.

This wraps all metrics and results with the session's name to be able to differentiate later on for which session they were recorded.

Link to this function

run(lt_mod, extra_config \\ %{})

View Source
@spec run(lt_conf(), map()) :: Chaperon.LoadTest.Results.t()
Link to this function

start_worker(scenarios, config)

View Source