microcks / microcks-testcontainers-java

Java lib for Testcontainers that enables embedding Microcks into your JUnit tests with lightweight, throwaway instance thanks to containers.
https://microcks.io
Apache License 2.0
18 stars 3 forks source link

Allow adding container dependencies for Async minion container from ensemblse #30

Closed lbroudoux closed 5 months ago

lbroudoux commented 5 months ago

Reason/Context

When using the Async mocking feature, the Async minion container must connect to an external broker. If this broker is within another Testcontainer, it may not be started and ready when Async minion tries connecting. Most of the time, this is not a problem as the scheduling will try to reconnect a few seconds later.

However, in some situations - like Kafka, for example - we may face DNS resolution/caching strategies that prevent resolving the host if not present at first resolution.

Description

We need a way to configure dependencies on startup. This is possible on GenericContainer instances but not directly on a MicrocksContainersEnsemble as it just implements Startable.

It is still possible to do this in a second time by using:

ensemble.getAsyncMinionContainer().dependsOn(kafkaContainer);

but it may not be easy to use if you're using the fluent .with().with().with() API style 😉

Implementation ideas

We need a withAsyncDependsOn() method at the ensemble level to do the trick.