I'm developing some component tests using Testcontainers. I can synchronize the tests on service readiness. However, once the service is ready, I need to prepare the fixture and run the tests until the fixture is fully loaded.
The container under test writes a log that I could use to understand when the fixture is fully loaded. However, I cannot find a method to synchronize on that log.
Does the Testcontainers library offer any utility for this?
If you are using a GenericContainer object type you can simply do something like this:
WaitingConsumer consumer = new WaitingConsumer();
container.followOutput(consumer, STDOUT);
consumer.waitUntil(frame ->
frame.getUtf8String().contains("STARTED"), 30, TimeUnit.SECONDS);
Else you can process the entire log with:
container.getLogs();
Hope this was helpful!