Skip to content

Commit

Permalink
#65 Debug /opt/kafka/config/ not writable
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed Aug 20, 2024
1 parent 1fc2554 commit 72a526c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ public class EventuateKafkaNativeContainer extends KafkaContainer implements Pro

private String firstNetworkAlias;

private static final String STARTER_SCRIPT = "/tmp/testcontainers_start.sh";

public EventuateKafkaNativeContainer() {
super("apache/kafka-native");
withCommand("sh", "-c", "whoami && while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT);

}

@Override
Expand Down Expand Up @@ -50,6 +54,8 @@ protected void containerIsStarting(InspectContainerResponse containerInfo) {
printExecResult(result, "whoami");
result = execInContainer("touch", "/opt/kafka/config/foo");
printExecResult(result, "touch /opt/kafka/config/foo");
result = execInContainer("sh", "-c", "[[ -w /opt/kafka/config/ ]] && echo yes");
printExecResult(result, "sh -c '[[ -w /opt/kafka/config/ ]] && echo yes'");
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import io.eventuate.messaging.kafka.spring.consumer.MessageConsumerKafkaConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.testcontainers.containers.output.Slf4jLogConsumer;

import java.util.Collections;
import java.util.UUID;
Expand All @@ -22,11 +25,15 @@
@RunWith(SpringJUnit4ClassRunner.class)
public class EventuateKafkaNativeClusterTest {

private final static Logger logger = LoggerFactory.getLogger(EventuateKafkaNativeClusterTest.class);

private static final EventuateKafkaNativeCluster kafkaCluster =
new EventuateKafkaNativeCluster("network-" + uuid());

@DynamicPropertySource
static void registerContainerProperties(DynamicPropertyRegistry registry) {
kafkaCluster.kafka.withLogConsumer(new Slf4jLogConsumer(logger).withPrefix("kafka:"));

PropertyProvidingContainer.startAndProvideProperties(registry, kafkaCluster.kafka);
}

Expand Down

0 comments on commit 72a526c

Please sign in to comment.