See also AGENTS.md for a high-level codebase overview and conventions.
Most tests require a locally running RabbitMQ node. The easiest way to get one is via Docker.
Install cargo-nextest if you don't have it:
cargo install cargo-nextestdocker run -d --name rabbitmq \
-p 15672:15672 \
-p 5672:5672 \
rabbitmq:4.1-managementWait for the node to boot:
sleep 15Run the setup script using the Docker exec variant of rabbitmqctl:
RUST_HTTP_API_CLIENT_RABBITMQCTL=DOCKER:rabbitmq bin/ci/before_build.shThis enables the required plugins (management, shovel, federation, stream), creates test users,
sets up the rust/http/api/client vhost, sets the cluster name, and enables all feature flags.
Wait for the changes to apply:
sleep 10NEXTEST_RETRIES=3 cargo nextest run --all-featuresNEXTEST_RETRIES=3 retries each failing test up to 3 times. This is recommended because some
tests depend on management plugin stats that can lag slightly behind the actual broker state.
docker stop rabbitmq && docker rm rabbitmqKey nextest filterset predicates:
test(pattern): matches test names using a substring (e.g.test(list_nodes))binary(pattern): matches the test binary name (e.g.binary(integration),binary(unit),binary(proptests))package(name): matches by package (e.g.package(rabbitmq_http_client))test(=exact_name): an exact test name matchtest(/regex/): liketest(pattern)but uses regular expression matching- Set operations:
expr1 + expr2(union),expr1 - expr2(difference),not expr(negation)
For example, use cargo nextest run --all-features -E 'binary(=test_module_name)' to run
all tests in a specific module.
cargo nextest run --all-features -E 'binary(~async)'cargo nextest run --all-features -E 'binary(~blocking)'cargo nextest run --all-features -E 'binary(~unit)'Use the binary(=name) predicate with the test module name:
cargo nextest run --all-features -E 'binary(=unit_endpoint_validation_tests)'Use the test(=name) predicate for an exact match:
cargo nextest run --all-features -E 'test(=test_list_all_vhost_limits)'Or use test(~substring) for a substring match:
cargo nextest run --all-features -E 'test(~list_vhost)'cargo nextest run --all-features -E 'test(~prop_)'See the nextest filtersets documentation for more filter expression predicates and operators.
TLS-enabled tests require a set of certificate and private key pairs, plus
a preconfigured RabbitMQ node. As such, they are excluded from standard cargo nextest runs.
To run these tests, generate certificates using tls-gen:
cd /path/to/tls-gen/basic && make CN=localhost && make alias-leaf-artifactsThen configure RabbitMQ management plugin to use TLS.
Next, export the TLS_CERTS_DIR environment variable:
export TLS_CERTS_DIR=/path/to/tls-gen/basic/resultFinally, run the tests in question only:
cargo nextest run --all-features --run-ignored=only -E 'binary(=async_tls_tests)'
cargo nextest run --all-features --run-ignored=only -E 'binary(=blocking_tls_tests)'