diff --git a/eventuate-messaging-kafka-testcontainers/src/main/java/io/eventuate/messaging/kafka/testcontainers/EventuateKafkaNativeContainer.java b/eventuate-messaging-kafka-testcontainers/src/main/java/io/eventuate/messaging/kafka/testcontainers/EventuateKafkaNativeContainer.java index 9d3cdd2..c9d2cfd 100644 --- a/eventuate-messaging-kafka-testcontainers/src/main/java/io/eventuate/messaging/kafka/testcontainers/EventuateKafkaNativeContainer.java +++ b/eventuate-messaging-kafka-testcontainers/src/main/java/io/eventuate/messaging/kafka/testcontainers/EventuateKafkaNativeContainer.java @@ -47,24 +47,28 @@ public void registerProperties(BiConsumer> registry) { @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); + + super.containerIsStarting(containerInfo); + } + + private void execInContainerAndPrint(String... args) { try { - ExecResult result = execInContainer("ls", "-ltd", "/opt/kafka/config/"); - printExecResult(result, "ls -ltd /opt/kafka/config/: "); - result = execInContainer("id"); - printExecResult(result, "id"); - 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) { + 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); } - super.containerIsStarting(containerInfo); } - private static void printExecResult(ExecResult result, String command) { - System.out.println(command + result.getExitCode()); - System.out.println(command + result.getStdout()); - System.out.println(command + result.getStderr()); - } }