Provides functionality for creating and managing Toxiproxy container configurations.
Toxiproxy is a framework for simulating network conditions. It's made specifically to work in testing, CI and development environments, supporting deterministic tampering with connections, but with support for randomized chaos and customization.
Summary
Functions
Returns the URI for the Toxiproxy API.
Configures the ToxiproxyEx library to use this container.
Returns the control port number (for the Toxiproxy HTTP API).
Creates a proxy in Toxiproxy that routes traffic from a container port to an upstream service.
Creates a proxy for another container on the same network.
Retrieves the default Docker image for the Toxiproxy container.
Deletes a proxy from Toxiproxy.
Returns the first proxy port number.
Lists all proxies configured in Toxiproxy.
Returns the mapped control port on the host for the running container.
Creates a new ToxiproxyContainer struct with default configurations.
Returns the number of proxy ports reserved.
Resets Toxiproxy, removing all toxics and re-enabling all proxies.
Overrides the default image used for the Toxiproxy container.
Set the reuse flag to reuse the container if it is already running.
Overrides the default wait timeout used for the Toxiproxy container.
Functions
Returns the URI for the Toxiproxy API.
This can be used with ToxiproxyEx:
ToxiproxyContainer.api_url(container)
|> then(&Application.put_env(:toxiproxy_ex, :host, &1))
Configures the ToxiproxyEx library to use this container.
This sets the :toxiproxy_ex application environment to point to
the running container's API endpoint.
Example
{:ok, toxiproxy} = Testcontainers.start_container(ToxiproxyContainer.new())
:ok = ToxiproxyContainer.configure_toxiproxy_ex(toxiproxy)
# Now ToxiproxyEx will use this container
ToxiproxyEx.get!("my_proxy") |> ToxiproxyEx.down!(fn -> ... end)
Returns the control port number (for the Toxiproxy HTTP API).
Creates a proxy in Toxiproxy that routes traffic from a container port to an upstream service.
Parameters
container- The running Toxiproxy containername- A unique name for the proxyupstream- The upstream address in format "host:port" (as seen from Toxiproxy container)opts- Optional keyword list::listen_port- Specific port to listen on (default: auto-allocated from 8666+)
Creates a proxy for another container on the same network.
This is a convenience function that creates a proxy using the target container's hostname and port.
Parameters
toxiproxy- The running Toxiproxy containername- A unique name for the proxytarget_container- The target container to proxy totarget_port- The port on the target containeropts- Optional keyword list (seecreate_proxy/4)
Retrieves the default Docker image for the Toxiproxy container.
Deletes a proxy from Toxiproxy.
Returns the first proxy port number.
Lists all proxies configured in Toxiproxy.
Returns a map of proxy names to their configurations.
Returns the mapped control port on the host for the running container.
Creates a new ToxiproxyContainer struct with default configurations.
Returns the number of proxy ports reserved.
Resets Toxiproxy, removing all toxics and re-enabling all proxies.
Overrides the default image used for the Toxiproxy container.
Set the reuse flag to reuse the container if it is already running.
Overrides the default wait timeout used for the Toxiproxy container.