chaperon v0.3.1 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
Functions
Merges metrics & results of all Chaperon.Session
s in a list.
Prepares session
to be merged.
Link to this section Types
Link to this type
lt_conf()
View Sourcelt_conf() :: module() | %{name: String.t(), scenarios: [Chaperon.Scenario.t()], config: map()}
Link to this type
t()
View Sourcet() :: %Chaperon.LoadTest{ config: map(), name: atom(), scenarios: [Chaperon.Scenario.t()] }
Link to this section Functions
Link to this function
merge_sessions(results)
View Sourcemerge_sessions(Chaperon.LoadTest.Results.t()) :: Chaperon.Session.t()
Merges metrics & results of all Chaperon.Session
s in a list.
Link to this function
prepare_merge(session)
View Sourceprepare_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 Sourcerun(lt_conf(), map()) :: Chaperon.LoadTest.Results.t()