Using Azure Event Hubs Emulator as a Test Container

This sample project demonstrates how to utilize the Azure Event Hubs emulator as a test container for local development and integration testing.

The Event Hubs emulator does not have a Testcontainers module and depends on the Azure Storage emulator (Azurite).

There are two ways to initialize the Event Hub Emulator as a test container:

1️⃣ Code Compose: Setting up containers programmatically with the GenericContainer class.
2️⃣ Docker Compose: Using a Docker Compose file for container orchestration.

For more details, visit the GitHub repository: https://github.com/mirkoiv/event-hubs-emulator-as-testcontainer

Building Event Hubs emulator as Test Container

Event Hubs emulator does not have a Testcontainers module (yet), and additionally the emulator requires Azure Storage emulator (azurite).

There are two ways to initialize the Event Hub Emulator as a test container:

1️⃣ code compose – Composing through code using the GenericContainer class – AbstractEventHubContainerCodeCompose
2️⃣ docker compose – Using a Docker Compose file and ComposeContainer class – AbstractEventHubContainerDockerCompose

Key Differences Between the Two Approaches

In the first case, tests or applications interact directly with the ports exposed by the generic emulator and storage test containers. In the second case, an additional ambassador container is created, serving as a proxy to the generic emulator and storage containers.

Code Compose:

eventhubs emulator - code compose

Docker Compose:

eventhubs emulator - docker compose