Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix postgres datasource devservice not working with rancher-desktop on mac arm #39682

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import org.jboss.logging.Logger;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import org.testcontainers.utility.DockerImageName;

import io.quarkus.datasource.common.runtime.DataSourceUtil;
Expand Down Expand Up @@ -99,16 +100,21 @@ public QuarkusPostgreSQLContainer(Optional<String> imageName, OptionalInt fixedE
super(DockerImageName
.parse(imageName.orElseGet(() -> ConfigureUtil.getDefaultImageNameFor("postgresql")))
.asCompatibleSubstituteFor(DockerImageName.parse(PostgreSQLContainer.IMAGE)));

this.fixedExposedPort = fixedExposedPort;
this.useSharedNetwork = useSharedNetwork;

// Workaround for https://github.com/testcontainers/testcontainers-java/issues/4799.
// The motivation of this custom wait strategy is that Testcontainers fails to start a Postgresql database when it
// has been already initialized.
// This custom wait strategy will work fine regardless of the state of the Postgresql database.
// More information in the issue ticket in Testcontainers.
this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx("(" + READY_REGEX + ")?(" + SKIPPING_INITIALIZATION_REGEX + ")?")
.withTimes(2)

// Added Wait.forListeningPort() for https://github.com/quarkusio/quarkus/issues/25682
// as suggested by https://github.com/testcontainers/testcontainers-java/pull/6309
this.waitStrategy = new WaitAllStrategy()
.withStrategy(Wait.forLogMessage("(" + READY_REGEX + ")?(" + SKIPPING_INITIALIZATION_REGEX + ")?", 2))
.withStrategy(Wait.forListeningPort())
.withStartupTimeout(Duration.of(60L, ChronoUnit.SECONDS));
}

Expand Down
Loading