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

Link to this function

connection_parameters(container)

View Source

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: "/"
]
Link to this function

connection_url(container)

View Source

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

Link to this function

default_image_with_tag()

View Source

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.

Link to this function

with_check_image(config, check_image)

View Source

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"]

Link to this function

with_force_reuse(config)

View Source
Link to this function

with_image(config, image)

View Source

Overrides the default image use for the RabbitMQ container.

Examples

iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_image("rabbitmq:xyz") iex> config.image "rabbitmq:xyz"

Link to this function

with_password(config, password)

View Source

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

Link to this function

with_reuse(config, reuse)

View Source

Set the reuse flag to reuse the container if it is already running.

Link to this function

with_username(config, username)

View Source

Overrides the default user used for the RabbitMQ container.

Examples

iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_username("rabbitmq") iex> config.username "rabbitmq"

Link to this function

with_virtual_host(config, virtual_host)

View Source

Overrides the default virtual host used for the RabbitMQ container.

Examples

iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_virtual_host("/") iex> config.password "/"

Link to this function

with_wait_timeout(config, wait_timeout)

View Source

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