View Source Testcontainers.RabbitMQContainer (testcontainers v1.12.0)

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

connection_parameters(container)

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

connection_url(container)

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"

default_image()

Retrieves the default Docker image for the RabbitMQ container

default_image_with_tag()

Retrieves the default Docker image including tag for the RabbitMQ container

default_port()

Retrieves the default exposed port for the RabbitMQ container

new()

Creates a new RabbitMQContainer struct with default configurations.

port(container)

Returns the port on the host machine where the RabbitMQ container is listening.

with_check_image(config, check_image)

Set the regular expression to check the image validity.

with_cmd(config, cmd)

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

with_force_reuse(config)

with_image(config, image)

Overrides the default image use for the RabbitMQ container.

Examples

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

with_password(config, password)

Overrides the default password used for the RabbitMQ container.

Examples

iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_password("rabbitmq") iex> config.password "rabbitmq"

with_port(config, port)

Overrides the default port used for the RabbitMQ container.

Examples

iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_port(1111) iex> config.port 1111

with_reuse(config, reuse)

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

with_username(config, username)

Overrides the default user used for the RabbitMQ container.

Examples

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

with_virtual_host(config, virtual_host)

Overrides the default virtual host used for the RabbitMQ container.

Examples

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

with_wait_timeout(config, wait_timeout)

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