Runbox.Runtime.Stage.Sandbox (runbox v7.0.1)

Sandbox is helper for executing runs without started Altworx application.

Sandbox can be used for scenarios unit testing and also for interactive development of scenarios. When used for unit testing, it can be used directly or via Runbox.Runtime.Stage.Sandbox.TestRunner.

For interactive development of scenarios, run iex --erl "-runbox mode slave" -S mix from command line in your scenarios application root directory and then use Sandbox fuctions to execute your runs (of course use recompile before run execution if you changed scenario code).

Link to this section Summary

Functions

Starts new run for scenario_id and waits until all input messages are processed.

Link to this section Types

Link to this type

topic_name()

@type topic_name() :: String.t()
@type topics() :: %{required(topic_name()) => [Toolbox.Message.t()]}

Link to this section Functions

Link to this function

execute_run(topics, scenario_id, opts \\ [])

@spec execute_run(topics(), String.t(), [module()] | nil) ::
  {:ok, [Runbox.Scenario.OutputAction.t()]} | {:error, term()}

Starts new run for scenario_id and waits until all input messages are processed.

Returns all output actions generated by run execution. Input messages for each runtime topic used by scenario should be defined in topics argument. Undefined topics are considered empty. Messages in each topic must be in ascending order by timestamp.

There are few options that can be specified.

  • :start_from - specify the start from value for the run. The value is used to filter out messages (as in a real run, input topics only use messages with timestamp >= start_from) and the value is provided to template's init callback.
  • :modules - list of modules containing scenarios (manifests, templates). If list of modules is specified execute_run does not search scenario in :scenarios application release, but in given modules. It opens possibility to write ad-hoc scenarios with only dependency on Runbox application, for example use it in Livebook. To see example of such livebook just run livebook server --home . in runbox root directory, go to generated livebook server link in browser and finally open sandbox-scenario-demo.livemd document. Running docker or altworx is not needed, only runbox app (and its deps) is required!