Skip to content

Commit

Permalink
Debugging for failed kafka containers
Browse files Browse the repository at this point in the history
Adds detailed output and hopefully fixes this error:
#1186
  • Loading branch information
fedinskiy committed Jul 3, 2024
1 parent a1154bf commit 92a95e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.quarkus.test.bootstrap.ManagedResource;
import io.quarkus.test.bootstrap.Protocol;
import io.quarkus.test.bootstrap.ServiceContext;
import io.quarkus.test.logging.Log;
import io.quarkus.test.logging.LoggingHandler;
import io.quarkus.test.logging.TestContainersLoggingHandler;
import io.quarkus.test.services.URILike;
Expand Down Expand Up @@ -119,7 +120,7 @@ private void doStart() {
innerContainer.start();
} catch (Exception ex) {
stop();

loggingHandler.logs().forEach(Log::info);
throw ex;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.github.dockerjava.api.command.InspectContainerResponse;

import io.quarkus.test.logging.Log;
import io.quarkus.test.services.containers.model.KafkaVendor;
import io.strimzi.test.container.StrimziKafkaContainer;

Expand All @@ -32,9 +33,11 @@ public void useCustomServerProperties() {

@Override
protected void containerIsStarting(InspectContainerResponse containerInfo, boolean reused) {
Log.info("Starting container using custom server properties");
if (useCustomServerProperties) {
List<String> script = new ArrayList<>();
script.add("#!/bin/bash");
script.add("set -euv");
int kafkaExposedPort = this.getMappedPort(KafkaVendor.STRIMZI.getPort());
script.add("sed 's/" + KAFKA_MAPPED_PORT + "/" + kafkaExposedPort + "/g' "
+ "config/kraft/server.properties > /tmp/effective_server.properties");
Expand All @@ -46,6 +49,7 @@ protected void containerIsStarting(InspectContainerResponse containerInfo, boole
script.add("bin/kafka-server-start.sh /tmp/effective_server.properties");
this.copyFileToContainer(Transferable.of(String.join("\n", script), ALLOW_EXEC), TESTCONTAINERS_SCRIPT);
} else {
Log.info("Starting container using standard server properties");
// we do not process credentials here, since SASL always used together with custom properties
// see StrimziKafkaContainerManagedResource#getServerProperties
super.containerIsStarting(containerInfo, reused);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ items:
data:
start.sh: |-
#!/bin/bash
set -euv
KAFKA_CLUSTER_ID="$(/opt/kafka/bin/kafka-storage.sh random-uuid)"
/opt/kafka/bin/kafka-storage.sh format -t ${KAFKA_CLUSTER_ID} -c config/kraft/server.properties
/opt/kafka/bin/kafka-server-start.sh config/kraft/server.properties --override listeners=PLAINTEXT://0.0.0.0:${KAFKA_PORT},CONTROLLER://localhost:9093 --override advertised.listeners=PLAINTEXT://${SERVICE_NAME}:${KAFKA_PORT}
Expand Down

0 comments on commit 92a95e8

Please sign in to comment.