testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.
https://testcontainers-python.readthedocs.io/en/latest/
Apache License 2.0
1.57k stars 283 forks source link

Feature: Implement Azure Event Hubs #713

Open megamaster4 opened 1 week ago

megamaster4 commented 1 week ago

What are you trying to do? Since the 11th of June, it is possible to emulate azure eventhubs. The intention of this enhancement is to implement an Azure Event Hubs test container to facilitate local development and testing of applications that interact with Azure Event Hubs. This allows developers to simulate the behavior of Azure Event Hubs without needing access to the actual cloud service, thereby improving development efficiency and reducing costs.

Why should it be done this way? Benefits of a feature as such, are comparable to the other testcontainer modules;

  1. Cost Efficiency
    • Developers can test their applications locally without incurring costs associated with using the actual Azure Event Hubs service.
  2. Isolation & Consistancy
    • It allows for isolated and consistent testing environments
  3. Offline development
    • Enables development and testing in environments without internet access

Beside the benefits, it is not that trivial to set it up with the generic containers as it needs some dependencies like a checkpoint storage in the form of an Azurite container.

Other references: See:

megamaster4 commented 1 week ago

Additional Information I tried implementing a similar structure as in the Selenium container, which also depends on a secondary container. This is necessary for Azure Event Hubs since it uses a storage account (Azurite) as checkpoint storage. However, when running the containers, I'm encountering the following error message:

azure.eventhub.exceptions.ConnectError: Failed to initiate the connection due to exception: [WinError 1225] The remote computer refused the network connection
Error condition: ErrorCondition.SocketError

I attempted to run the Docker Compose file directly with docker-compose, and it worked fine. The only difference I notice with my Testcontainer variant is the usage of internal IPs. When running docker-compose, it uses the same internal IP addresses as the exposed ones. I believe that the emulator still needs these internal IPs to be the same.

Request for Assistance Does anyone have suggestions on how to resolve this issue? Any guidance would be greatly appreciated. Thanks in advance!