Add junit test for kafka events consumer

Use LightweightPluginDaemonTest class infrastructure to boot the
gerrit server and deploy the plugin. This test assumes that the full
version of Kafka server is up and running prior to test execution.

An alternative approach (not done in this change) is to set up
testcontainers library with provided KafkaContainer: [1] and start
dockerized Kafka instance from within the JUnit test's setUp method.

Test Plan:

1. Run Kafka Server:
  $ docker run -p 2181:2181 -p 9092:9092 -d -e ADVERTISED_HOST=127.0.1 -e ADVERTISED_PORT=9092 spotify/kafka
2. Run the test:
  $ bazel test plugins/kafka-events:kafka_events_tests


Change-Id: Ia61868acc50d47b742126208fd078076dc2c2a94
3 files changed
tree: 3f8bc1b89ec598b0af34cf87137d972854d61f3d
  1. BUILD
  4. external_plugin_deps.bzl
  5. src/

Kafka: Gerrit event producer for Apache Kafka

Build Status


This plugins allows to define a distributed stream of events published by Gerrit.

Events can be anything, from the traditional stream events to the Gerrit metrics.

This plugin requires Gerrit 2.13 or laster.


  • linux
  • java-1.8
  • Bazel


Kafka plugin can be build as a regular ‘in-tree’ plugin. That means that is required to clone a Gerrit source tree first and then to have the Kafka plugin source directory into the /plugins path. Additionally, the plugins/external_plugin_deps.bzl file needs to be updated to match the Kafka plugin one.

git clone --recursive
git clone gerrit/plugins/kafka-events
cd gerrit
rm plugins/external_plugin_deps.bzl
ln -s ./kafka-events/external_plugin_deps.bzl plugins/.

To build the kafka-events plugins, issue the command from the Gerrit source path:

bazel build plugins/kafka-events

The output is created in


Minimum Configuration

Assuming a running Kafka broker on the same Gerrit host, add the following settings to gerrit.config:

  [plugin "kafka-events"]
    bootstrapServers = localhost:9092