LiveLoad.Browser.Connection defines a behaviour for how to connect to browsers with LiveLoad.
By default, an implementation for a Playwright instance (LiveLoad.Browser.Connection.Playwright)
is included in LiveLoad and can be looked at as reference implementation for implementing other browsers.
Summary
Callbacks
A hook called after the supervision tree for the browser is initialized in LiveLoad.Browser.start_link/2.
A hook called after the supervision tree for the browser is stopped in LiveLoad.Browser.stop/3
A hook called before the supervision tree for the browser is initialized in LiveLoad.Browser.start_link/2
A hook called before the supervision tree for the browser is stopped in LiveLoad.Browser.stop/3
Different browser implementations may have different memory requirements, depending on how they are implemented.
The LiveLoad.Cluster initialization procedure uses this callback in order to calculate the optimal amount of nodes
to use for running a LiveLoad.Scenario based on the number of users for the test and the resources available on each
cluster node.
Different browser implementations may have different memory requirements, depending on how they are implemented.
The LiveLoad.Cluster initialization procedure uses this callback in order to calculate the optimal amount of nodes
to use for running a LiveLoad.Scenario based on the number of users for the test and the resources available on each
cluster node.
Any connection can broadcast telemetry events that correspond to load test metrics which LiveLoad tracks during a scenario.
Since connections are generally modeled around Ports, the telemetry sent by those ports may be asynchronous in nature,
meaning that stopping a context does not necessarily mean that all metrics have completed sending and been consumed.
To avoid race conditions and dropping metrics, this callback can be implemented by a connection's metrics collection mechanism
to ensure that all metrics have been sent and drained.
Types
@type option() :: LiveLoad.Browser.Connection.Playwright.connection_option() | {atom(), term()}
@type opts() :: [option()]
@type t() :: module()
Any module implementing the LiveLoad.Browser.Connection behaviour.
Callbacks
@callback after_start(browser :: LiveLoad.Browser.t()) :: LiveLoad.Browser.t()
A hook called after the supervision tree for the browser is initialized in LiveLoad.Browser.start_link/2.
@callback after_stop(browser :: LiveLoad.Browser.t()) :: :ok
A hook called after the supervision tree for the browser is stopped in LiveLoad.Browser.stop/3
@callback before_start(browser :: LiveLoad.Browser.t()) :: LiveLoad.Browser.t()
A hook called before the supervision tree for the browser is initialized in LiveLoad.Browser.start_link/2
@callback before_stop(browser :: LiveLoad.Browser.t()) :: LiveLoad.Browser.t()
A hook called before the supervision tree for the browser is stopped in LiveLoad.Browser.stop/3
@callback browser_memory_usage_bytes() :: pos_integer()
Different browser implementations may have different memory requirements, depending on how they are implemented.
The LiveLoad.Cluster initialization procedure uses this callback in order to calculate the optimal amount of nodes
to use for running a LiveLoad.Scenario based on the number of users for the test and the resources available on each
cluster node.
@callback child_spec(opts :: opts()) :: Supervisor.child_spec()
@callback context_memory_usage_bytes() :: pos_integer()
Different browser implementations may have different memory requirements, depending on how they are implemented.
The LiveLoad.Cluster initialization procedure uses this callback in order to calculate the optimal amount of nodes
to use for running a LiveLoad.Scenario based on the number of users for the test and the resources available on each
cluster node.
@callback drain_metrics(browser :: LiveLoad.Browser.t()) :: :ok
Any connection can broadcast telemetry events that correspond to load test metrics which LiveLoad tracks during a scenario.
Since connections are generally modeled around Ports, the telemetry sent by those ports may be asynchronous in nature,
meaning that stopping a context does not necessarily mean that all metrics have completed sending and been consumed.
To avoid race conditions and dropping metrics, this callback can be implemented by a connection's metrics collection mechanism
to ensure that all metrics have been sent and drained.
A reference implementation can be found in the LiveLoad.Browser.Connection.Playwright implementation of the connection behaviour.
@callback inner_html(context :: LiveLoad.Browser.Context.t(), selector :: String.t()) :: {:ok, {LiveLoad.Browser.Context.t(), String.t()}} | {:error, term()}
@callback new_context(browser :: LiveLoad.Browser.t()) :: {:ok, LiveLoad.Browser.Context.t()} | {:error, term()}
@callback page_content(context :: LiveLoad.Browser.Context.t()) :: {:ok, {LiveLoad.Browser.Context.t(), String.t()}} | {:error, term()}
@callback stop_context(context :: LiveLoad.Browser.Context.t()) :: :ok | {:error, term()}
@callback wait_for_selector( context :: LiveLoad.Browser.Context.t(), selector :: String.t() ) :: {:ok, LiveLoad.Browser.Context.t()} | {:error, term()}