Skip to main content

Running repository tests

From the repository root, use the .NET SDK selected by global.json to run the test classes that cover your change. For example, to run the message envelope tests:

dotnet test -c Release --project tests/Relayer.Tests --treenode-filter '/*/*/MessageEnvelopeTests/*'

Set --project to the project that owns the tests and replace MessageEnvelopeTests with the affected class name. Omit the filter to run the whole project only when the change affects it broadly, such as a change to a shared fixture or base class.

The message envelope tests run in memory. Start Docker when the selected tests use a container, such as a broker, emulator or database.

Tests run in parallel with no concurrency limiter. Broker containers are shared for the whole test run instead of started per test. SharedBrokers starts each one on first use, so a filtered run starts only what it needs, and removes them when the run ends:

BrokerShared instanceWhat each test owns
RabbitMQone broker, and a second with the delayed-message plugina virtual host, through RabbitMqTopologyTests.Broker.StartAsync
Service Busone Floci Azure emulator with an Artemis brokerqueues, topics and subscriptions it creates through the administration client
Flocione container for SQS and SNSuniquely named queues and topics

SQS and SNS tests use floci/floci:nightly. The shared container and dedicated conformance containers always pull the image at startup so cached images do not hide nightly updates. These tests require registry access and track Floci's unreleased changes.

A test that changes the whole broker, such as stopping it to simulate an outage, asks for a dedicated one with dedicated: true. Each dedicated Service Bus fixture has its own Docker network and Floci resource namespace. Floci Azure 0.18.0 uses the Linux Docker socket to manage its Artemis sidecar. The sidecar runs on an isolated internal bridge. Toxiproxy provides stable loopback endpoints while the emulator restarts. Run these tests on the Docker host with Docker Engine 28 or later. If the daemon uses a non-default Unix socket, set TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE to its absolute path on the Docker host. Floci uses that socket to attach Artemis to the network Testcontainers creates.

When you add a broker test, use the shared instance and name everything the test creates uniquely, for example with TestContext.Current!.Isolation. Do not add [ParallelLimiter] or [NotInParallel] to make a test pass.

PostgreSQL outbox suite​

tests/Relayer.Outbox.PostgreSql.Tests starts one PostgreSQL container per test run, on the first test that needs it. PostgreSqlFixture creates a database on that server for each test and drops it afterwards, so the suite runs at full parallelism without a limiter. A test that queries server-wide views such as pg_stat_activity or pg_replication_slots must scope the query to its own database, application name or replication slot; name server-wide objects with TestContext.Current!.Isolation.

The suite opens a new connection for most commands. On macOS, Docker Desktop forwards about 8,000 new connections per 30 seconds across the whole machine before it starts closing them, and one run of this suite uses about a third of that. Repeating the whole suite several times back to back can therefore fail with Exception while reading from stream on every test. Run the tests that cover your change instead, or wait 30 seconds between full runs. Linux hosts and CI are not affected.

Service Bus startup diagnostics​

Service Bus fixture startup failures print a diagnostic report before cleanup and attach it to the original exception's Data["ServiceBusStartupDiagnostics"]. The report inspects both Toxiproxy and the Floci Azure emulator, including Docker's exit code, OOMKilled flag, status, error and timestamps, then reads their stdout/stderr. Each inspect/log request has an independent five-second budget even when the provisioning deadline has expired. Missing containers or failed diagnostic requests are reported without replacing the startup exception.

Exit 137 commonly indicates SIGKILL, but a process can also return that code itself; it does not by itself establish an OOM kill. oomKilled=True records Docker's OOM observation. For Artemis startup failures, check the Floci logs for the Docker error from creating or starting the sidecar. Diagnostics record available evidence rather than retrying startup or changing resource limits. The controlled diagnostic tests can be run with:

dotnet test -c Release --project tests/Relayer.Tests --treenode-filter '/*/*/ServiceBusStartupDiagnosticsTests/*'