chaperon v0.1.3 Chaperon.LoadTest View Source

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

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

Link to this type t() View Source
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

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

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
run(module, map) :: Chaperon.LoadTest.Results.t
Link to this function start_worker(scenarios, config) View Source