commit | 9eae7ad9634b400434bf560a6e08a3acd86de934 | [log] [tgz] |
---|---|---|
author | David Ostrovsky <david@ostrovsky.org> | Sat Jul 14 14:30:46 2018 +0200 |
committer | David Ostrovsky <david@ostrovsky.org> | Fri Dec 07 23:18:18 2018 +0100 |
tree | 3f8bc1b89ec598b0af34cf87137d972854d61f3d | |
parent | 85013bb630b9d9766acfff14bde635b4932c5a33 [diff] |
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 [1] https://github.com/testcontainers/testcontainers-java/blob/master\ /modules/kafka/src/main/java/org/testcontainers/containers/KafkaContainer.java Change-Id: Ia61868acc50d47b742126208fd078076dc2c2a94
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 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
Assuming a running Kafka broker on the same Gerrit host, add the following settings to gerrit.config:
[plugin "kafka-events"] bootstrapServers = localhost:9092