Skip to content

Commit

Permalink
DBZ-7557 Include Redis and RocketMQ logs into test log
Browse files Browse the repository at this point in the history
  • Loading branch information
vjuranek authored and jpechane committed Feb 27, 2024
1 parent b410379 commit 4978fe8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;

import io.debezium.server.TestConfigSource;
import io.debezium.util.Testing;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class RedisTestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager {
private static final Logger LOGGER = LoggerFactory.getLogger(RedisTestResourceLifecycleManager.class);

static final String READY_MESSAGE = "Ready to accept connections";
public static final int REDIS_PORT = 6379;
Expand All @@ -36,6 +40,7 @@ private static synchronized void start(boolean ignored) {
@Override
public Map<String, String> start() {
start(true);
container.followOutput(new Slf4jLogConsumer(LOGGER));
Testing.Files.delete(TestConfigSource.OFFSET_STORE_PATH);
Testing.Files.createTestingFile(TestConfigSource.OFFSET_STORE_PATH);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;

import com.github.dockerjava.api.command.InspectContainerResponse;
Expand All @@ -20,6 +23,7 @@
* rocketmq container
*/
public class RocketMqContainer extends GenericContainer<RocketMqContainer> {
private static final Logger LOGGER = LoggerFactory.getLogger(RocketMqContainer.class);

private static final String ROCKETMQ_VERSION = ContainerImageVersions.getStableVersion("apache/rocketmq", ContainerImageVersions.NUMBERS_ONLY_VERSION_REGEX_PATTERN);
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("apache/rocketmq:" + ROCKETMQ_VERSION);
Expand All @@ -43,6 +47,7 @@ protected void configure() {
@Override

protected void containerIsStarted(InspectContainerResponse containerInfo) {
followOutput(new Slf4jLogConsumer(LOGGER));
List<String> updateBrokerConfigCommands = new ArrayList<>();
updateBrokerConfigCommands.add(updateBrokerConfig("brokerIP1", getHost()));
updateBrokerConfigCommands.add(updateBrokerConfig("listenPort", getMappedPort(BROKER_PORT)));
Expand Down

0 comments on commit 4978fe8

Please sign in to comment.