Start dockerized kafka server from junit test using testcontainers

Use testcontainers to spawn dockerized Kafka server from within junit
test.

One challenge to solve is to bootstrap initialization properties from the
dockerized kafka server.  There is no way to inject custom values after
the docker instance was started by testcontainers library. To overcome,
set special system property in test environment and check for that
property in production code. If present, inject special properties in
Kafka server's test environment.

Test Plan:

1. Start docker daemon:

  $ sudo service docker start

2. Run tests:

  $ bazel test plugins/kafka-events:kafka_events_tests

Change-Id: Iaca0901410460bbbfa731b4da1625a9600402e08
4 files changed
tree: f90594fd1441c858cad7f33a81b931864443715e
  1. src/
  2. BUILD
  3. external_plugin_deps.bzl
  4. LICENSE
  5. README.md
README.md

Kafka: Gerrit event producer for Apache Kafka

Build Status

Synopsis

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.

Environments

  • linux
  • java-1.8
  • Bazel

Build

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 https://gerrit.googlesource.com/gerrit
git clone https://gerrit.googlesource.com/plugins/kafka-events 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

bazel-genfiles/plugins/kafka-events/kafka-events.jar

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