Skip to content

Commit

Permalink
#65 /opt/kafka/config/ not writable - Appears fixed by da1bfb4
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed Aug 21, 2024
1 parent a321ae8 commit 38dde27
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package io.eventuate.messaging.kafka.testcontainers;


import com.github.dockerjava.api.command.InspectContainerResponse;
import io.eventuate.common.testcontainers.PropertyProvidingContainer;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.kafka.KafkaContainer;

import java.io.IOException;
import java.util.function.BiConsumer;
import java.util.function.Supplier;

public class EventuateKafkaNativeContainer extends KafkaContainer implements PropertyProvidingContainer {

private String firstNetworkAlias;

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

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

}

@Override
Expand All @@ -45,34 +39,4 @@ public void registerProperties(BiConsumer<String, Supplier<Object>> registry) {
registry.accept("eventuatelocal.kafka.bootstrap.servers", this::getBootstrapServers);
}

@Override
protected void containerIsStarting(InspectContainerResponse containerInfo) {
execInContainerAndPrint("ls", "-ltd", "/opt/kafka/config/");
execInContainerAndPrint("id");
execInContainerAndPrint("touch", "/opt/kafka/config/foo");

String writeableTest = "[[ -w /opt/kafka/config/ ]] && echo yes";
execInContainerAndPrint("sh", "-c", writeableTest);
execInContainerAndPrint("bash", "-c", writeableTest);

String writeableTest2 = "test -w /opt/kafka/config/ && echo yes";
execInContainerAndPrint("sh", "-c", writeableTest2);
execInContainerAndPrint("bash", "-c", writeableTest2);

super.containerIsStarting(containerInfo);
}

private void execInContainerAndPrint(String... args) {
try {
ExecResult result = execInContainer(args);
String command = String.join(" ", args) + " : ";
System.out.println("======== Command " + command + " -> ");
System.out.println("ExitCode=" + result.getExitCode());
System.out.println("Stdout=" + result.getStdout());
System.out.println("Stderr=" + result.getStderr());
} catch (UnsupportedOperationException | InterruptedException | IOException e) {
throw new RuntimeException(e);
}
}

}

0 comments on commit 38dde27

Please sign in to comment.