Skip to content

Commit

Permalink
Attempt to start the containers three times before failing
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun committed Nov 8, 2024
1 parent 6cf01e6 commit 7ed02d9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/test/java/io/lettuce/core/RedisContainerIntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ public class RedisContainerIntegrationTests {
// Singleton container pattern - start the containers only once
// See https://java.testcontainers.org/test_framework_integration/manual_lifecycle_control/#singleton-containers
static {
int attempts = 0;

// In case you need to debug the container uncomment these lines to redirect the output
CLUSTERED_STACK.withLogConsumer(REDIS_STACK_CLUSTER, (OutputFrame frame) -> LOGGER.debug(frame.getUtf8String()));
CLUSTERED_STACK.withLogConsumer(REDIS_STACK_STANDALONE, (OutputFrame frame) -> LOGGER.debug(frame.getUtf8String()));

CLUSTERED_STACK.waitingFor(REDIS_STACK_CLUSTER,
Wait.forLogMessage(".*Background RDB transfer terminated with success.*", 1));
try {
CLUSTERED_STACK.start();
} catch (Exception e) {
initializationException = e;
}
do {
try {
CLUSTERED_STACK.start();
} catch (Exception e) {
initializationException = e;
}
// Attempt to stabilize the pipeline - sometime the `docker compose up` fails randomly
} while (initializationException != null && attempts++ < 3);
}

@BeforeAll
Expand Down

0 comments on commit 7ed02d9

Please sign in to comment.