Skip to content

Commit

Permalink
Clean duplicate in regex for log message wait strategy (#7304)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed May 23, 2024
1 parent 635d5d4 commit 6658a2c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public CosmosDBEmulatorContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
withExposedPorts(PORT);
waitingFor(Wait.forLogMessage("(?s).*Started\\r\\n$", 1));
waitingFor(Wait.forLogMessage(".*Started\\r\\n$", 1));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.apache.commons.lang3.StringUtils;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.ComparableVersion;
import org.testcontainers.utility.DockerImageName;

Expand Down Expand Up @@ -135,7 +135,7 @@ public ElasticsearchContainer(final DockerImageName dockerImageName) {
// matches 7.x JSON logging with whitespace between message field and content
// matches 6.x text logging with node name in brackets and just a 'started' message till the end of the line
String regex = ".*(\"message\":\\s?\"started[\\s?|\"].*|] started\n$)";
setWaitStrategy(new LogMessageWaitStrategy().withRegEx(regex));
setWaitStrategy(Wait.forLogMessage(regex, 1));
if (isAtLeastMajorVersion8) {
withPassword(ELASTICSEARCH_DEFAULT_PASSWORD);
withCertPath(DEFAULT_CERT_PATH);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ public BigtableEmulatorContainer(final DockerImageName dockerImageName) {
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLOUD_SDK_IMAGE_NAME);

withExposedPorts(PORT);
setWaitStrategy(new LogMessageWaitStrategy().withRegEx("(?s).*running.*$"));
setWaitStrategy(Wait.forLogMessage(".*running.*$", 1));
withCommand("/bin/sh", "-c", CMD);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ public FirestoreEmulatorContainer(final DockerImageName dockerImageName) {
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLOUD_SDK_IMAGE_NAME);

withExposedPorts(PORT);
setWaitStrategy(new LogMessageWaitStrategy().withRegEx("(?s).*running.*$"));
setWaitStrategy(Wait.forLogMessage(".*running.*$", 1));
withCommand("/bin/sh", "-c", CMD);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ public PubSubEmulatorContainer(final DockerImageName dockerImageName) {
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLOUD_SDK_IMAGE_NAME);

withExposedPorts(8085);
setWaitStrategy(new LogMessageWaitStrategy().withRegEx("(?s).*started.*$"));
setWaitStrategy(Wait.forLogMessage(".*started.*$", 1));
withCommand("/bin/sh", "-c", CMD);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
Expand All @@ -27,7 +27,7 @@ public SpannerEmulatorContainer(final DockerImageName dockerImageName) {
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);

withExposedPorts(GRPC_PORT, HTTP_PORT);
setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*Cloud Spanner emulator running\\..*"));
setWaitStrategy(Wait.forLogMessage(".*Cloud Spanner emulator running\\..*", 1));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.slf4j.event.Level;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.GenericContainer;
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 org.testcontainers.utility.MountableFile;
Expand Down Expand Up @@ -82,7 +82,7 @@ public HiveMQContainer(final @NotNull DockerImageName dockerImageName) {

addExposedPort(MQTT_PORT);

waitStrategy.withStrategy(new LogMessageWaitStrategy().withRegEx("(.*)Started HiveMQ in(.*)"));
waitStrategy.withStrategy(Wait.forLogMessage("(.*)Started HiveMQ in(.*)", 1));
waitingFor(waitStrategy);

withLogConsumer(outputFrame -> {
Expand Down Expand Up @@ -160,7 +160,7 @@ protected void containerIsStarted(final @NotNull InspectContainerResponse contai
*/
public @NotNull HiveMQContainer waitForExtension(final @NotNull String extensionName) {
final String regEX = "(.*)Extension \"" + extensionName + "\" version (.*) started successfully(.*)";
waitStrategy.withStrategy(new LogMessageWaitStrategy().withRegEx(regEX));
waitStrategy.withStrategy(Wait.forLogMessage(regEX, 1));
return self();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.apache.commons.io.IOUtils;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -47,7 +47,7 @@ public K3sContainer(DockerImageName dockerImageName) {
setTmpFsMapping(tmpFsMapping);

setCommand("server", "--disable=traefik", "--tls-san=" + this.getHost());
setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*Node controller sync successful.*"));
setWaitStrategy(Wait.forLogMessage(".*Node controller sync successful.*", 1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.ComparableVersion;
import org.testcontainers.utility.DockerImageName;

Expand Down Expand Up @@ -79,7 +79,7 @@ public OrientDBContainer(final DockerImageName dockerImageName) {
serverPassword = DEFAULT_SERVER_PASSWORD;
databaseName = DEFAULT_DATABASE_NAME;

waitStrategy = new LogMessageWaitStrategy().withRegEx(".*OrientDB Studio available.*");
waitStrategy = Wait.forLogMessage(".*OrientDB Studio available.*", 1);

addExposedPorts(DEFAULT_BINARY_PORT, DEFAULT_HTTP_PORT);
}
Expand Down

0 comments on commit 6658a2c

Please sign in to comment.