View Source Testcontainers.RabbitMQContainer (testcontainers v1.11.6)
Provides functionality for creating and managing RabbitMQ container configurations.
NOTE: The default starting command is chmod 400 /var/lib/rabbitmq/.erlang.cookie; rabbitmq-server
.
chmod 400 /var/lib/rabbitmq/.erlang.cookie
is necessary for the waiting strategy, which calls the command rabbitmq-diagnostics check_running
; otherwise CLI tools cannot communicate with the RabbitMQ node.
Summary
Functions
Returns the connection parameters to connect to RabbitMQ from the host machine.
Generates the connection URL for accessing the RabbitMQ service running within the container.
Retrieves the default Docker image for the RabbitMQ container
Retrieves the default Docker image including tag for the RabbitMQ container
Retrieves the default exposed port for the RabbitMQ container
Creates a new RabbitMQContainer
struct with default configurations.
Returns the port on the host machine where the RabbitMQ container is listening.
Set the regular expression to check the image validity.
Overrides the default command used for the RabbitMQ container.
Overrides the default image use for the RabbitMQ container.
Overrides the default password used for the RabbitMQ container.
Overrides the default port used for the RabbitMQ container.
Set the reuse flag to reuse the container if it is already running.
Overrides the default user used for the RabbitMQ container.
Overrides the default virtual host used for the RabbitMQ container.
Overrides the default wait timeout used for the RabbitMQ container.
Functions
Returns the connection parameters to connect to RabbitMQ from the host machine.
Parameters
container
: The active RabbitMQ container instance in the form of a %Container{} struct.
Examples
iex> RabbitMQContainer.connection_parameters(container)
[
host: "localhost",
port: 32768,
username: "guest",
password: "guest",
vhost: "/"
]
Generates the connection URL for accessing the RabbitMQ service running within the container.
This URI is based on the AMQP 0-9-1, and has the following scheme: amqp://username:password@host:port/vhost
Parameters
container
: The active RabbitMQ container instance in the form of a %Container{} struct.
Examples
iex> RabbitMQContainer.connection_url(container)
"amqp://guest:guest@localhost:32768"
iex> RabbitMQContainer.connection_url(container_with_vhost)
"amqp://guest:guest@localhost:32768/vhost"
Retrieves the default Docker image for the RabbitMQ container
Retrieves the default Docker image including tag for the RabbitMQ container
Retrieves the default exposed port for the RabbitMQ container
Creates a new RabbitMQContainer
struct with default configurations.
Returns the port on the host machine where the RabbitMQ container is listening.
Set the regular expression to check the image validity.
Overrides the default command used for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_cmd(["sh", "-c", "rabbitmq-server"]) iex> config.cmd ["sh", "-c", "rabbitmq-server"]
Overrides the default image use for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_image("rabbitmq:xyz") iex> config.image "rabbitmq:xyz"
Overrides the default password used for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_password("rabbitmq") iex> config.password "rabbitmq"
Overrides the default port used for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_port(1111) iex> config.port 1111
Set the reuse flag to reuse the container if it is already running.
Overrides the default user used for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_username("rabbitmq") iex> config.username "rabbitmq"
Overrides the default virtual host used for the RabbitMQ container.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_virtual_host("/") iex> config.password "/"
Overrides the default wait timeout used for the RabbitMQ container.
Note: this timeout will be used for each individual wait strategy.
Examples
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_wait_timeout(60000) iex> config.wait_timeout 60000