Fix Kafka container-test when running on CI Do not assume that the Kafka container-based tests are run with a local Docker server: get the actual bootstrap server details from the container itself. On the Gerrit-CI the Docker servers can be remote and therefore the bootstrap server won't be available on localhost. Change-Id: I607d320666627dd89352f81592e056e670b227d8
diff --git a/src/test/java/com/googlesource/gerrit/plugins/kafka/api/KafkaBrokerApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/kafka/api/KafkaBrokerApiTest.java index 9078d05..eafa191 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/kafka/api/KafkaBrokerApiTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/kafka/api/KafkaBrokerApiTest.java
@@ -141,7 +141,7 @@ public static void beforeClass() throws Exception { kafka = new TestKafkaContainer(); kafka.start(); - System.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9093"); + System.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); Injector baseInjector = Guice.createInjector(new TestModule()); WorkQueue testWorkQueue = baseInjector.getInstance(WorkQueue.class);