Merge branch 'stable-3.4'
* stable-3.4:
Update documentation about mandatory properties
Send/receive Event object instead of EventMessage
Use EventGsonProvider from Gerrit core
Bump events-broker version to v3.4.0.1
Add dummy settings for aws credentials
Remove unmaintained attempt to Dockerize the whole multi-site setup
Implements async send interface
Change source instance id type from UUID to String
Change-Id: I02801041a6edd60e5c63cbda294117c09ff56a19
diff --git a/dockerised_local_env/.gitignore b/dockerised_local_env/.gitignore
deleted file mode 100644
index bc7d3f3..0000000
--- a/dockerised_local_env/.gitignore
+++ /dev/null
@@ -1,30 +0,0 @@
-# LC_COLLATE=C sort
-
-/gerrit-1/bin/
-/gerrit-1/data/
-/gerrit-1/db/
-/gerrit-1/etc/
-/gerrit-1/git/
-/gerrit-1/index/
-/gerrit-1/lib/
-/gerrit-1/logs/
-/gerrit-1/plugins/
-/gerrit-1/ssh/known_hosts
-/gerrit-1/tmp/
-
-/gerrit-2/bin/
-/gerrit-2/data/
-/gerrit-2/db/
-/gerrit-2/etc/
-/gerrit-2/git/
-/gerrit-2/index/
-/gerrit-2/lib/
-/gerrit-2/logs/
-/gerrit-2/plugins/
-/gerrit-2/ssh/known_hosts
-/gerrit-2/tmp/
-
-/gerrit-common/shared-dir/
-
-/syslog-sidecar/logs/
-/syslog-sidecar/socket/
diff --git a/dockerised_local_env/Makefile b/dockerised_local_env/Makefile
deleted file mode 100644
index d48a672..0000000
--- a/dockerised_local_env/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-GERRIT_JOB=Gerrit-bazel-stable-2.16
-BUILD_NUM=377
-GERRIT_1_BIN_DIRECTORY=./gerrit-1/bin
-GERRIT_2_BIN_DIRECTORY=./gerrit-2/bin
-GERRIT_1_LIB_DIRECTORY=./gerrit-1/lib
-GERRIT_2_LIB_DIRECTORY=./gerrit-2/lib
-GERRIT_1_ETC_DIRECTORY=./gerrit-1/etc
-GERRIT_2_ETC_DIRECTORY=./gerrit-2/etc
-GERRIT_1_PLUGINS_DIRECTORY=./gerrit-1/plugins
-GERRIT_2_PLUGINS_DIRECTORY=./gerrit-2/plugins
-CORE_PLUGINS=replication
-CI_URL=https://gerrit-ci.gerritforge.com/job
-MYDIR=$(shell basename $(shell pwd))
-WGET=wget -N -q
-
-all: prepare download build
-
-prepare:
- -mkdir -p $(GERRIT_1_PLUGINS_DIRECTORY) $(GERRIT_2_PLUGINS_DIRECTORY) $(GERRIT_1_BIN_DIRECTORY) $(GERRIT_2_BIN_DIRECTORY) $(GERRIT_1_ETC_DIRECTORY) $(GERRIT_2_ETC_DIRECTORY) $(GERRIT_1_LIB_DIRECTORY) $(GERRIT_2_LIB_DIRECTORY)
-
-download: gerrit plugin_websession_flatfile \
- plugin_healthcheck \
- plugin_delete_project \
- plugin_multi_site
-
-
-gerrit: prepare
- $(WGET) $(CI_URL)/$(GERRIT_JOB)/lastSuccessfulBuild/artifact/gerrit/bazel-bin/release.war -P $(GERRIT_1_BIN_DIRECTORY)
- cp $(GERRIT_1_BIN_DIRECTORY)/*.war $(GERRIT_2_BIN_DIRECTORY)
- for plugin in $(CORE_PLUGINS); do $(WGET) $(CI_URL)/$(GERRIT_JOB)/lastSuccessfulBuild/artifact/gerrit/bazel-bin/plugins/$$plugin/$$plugin.jar -P $(GERRIT_1_PLUGINS_DIRECTORY); done
- cp $(GERRIT_1_PLUGINS_DIRECTORY)/*.jar $(GERRIT_2_PLUGINS_DIRECTORY)
-
-plugin_websession_flatfile: prepare
- $(WGET) $(CI_URL)/plugin-websession-flatfile-bazel-master-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/websession-flatfile/websession-flatfile.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
- cp $(GERRIT_1_PLUGINS_DIRECTORY)/websession-flatfile.jar $(GERRIT_2_PLUGINS_DIRECTORY)/websession-flatfile.jar
-
-plugin_multi_site: prepare
- $(WGET) $(CI_URL)/plugin-multi-site-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/multi-site/multi-site.jar -P $(GERRIT_1_LIB_DIRECTORY)
- cp $(GERRIT_1_PLUGINS_DIRECTORY)/replication.jar $(GERRIT_1_LIB_DIRECTORY)
- cp $(GERRIT_1_LIB_DIRECTORY)/*.jar $(GERRIT_2_LIB_DIRECTORY)
-
-plugin_healthcheck: prepare
- $(WGET) $(CI_URL)/plugin-healthcheck-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/healthcheck/healthcheck.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
- cp $(GERRIT_1_PLUGINS_DIRECTORY)/healthcheck.jar $(GERRIT_2_PLUGINS_DIRECTORY)/healthcheck.jar
-
-plugin_delete_project: prepare
- $(WGET) $(CI_URL)/plugin-delete-project-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/delete-project/delete-project.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
- cp $(GERRIT_1_PLUGINS_DIRECTORY)/delete-project.jar $(GERRIT_2_PLUGINS_DIRECTORY)/delete-project.jar
-
-build:
- docker build -t $(MYDIR) ./gerrit-1
- docker build -t $(MYDIR) ./gerrit-2
-
-clean_gerrit: prepare
- -rm -fr gerrit-{1,2}/{db,data,cache,db,git,index,etc,bin,tmp,plugins,lib}/*
- export GERRIT_REPLICATION_INSTANCE=gerrit-2; cat ./gerrit-common/replication.config.template | envsubst '$${GERRIT_REPLICATION_INSTANCE}' > ./gerrit-1/etc/replication.config
- export GERRIT_REPLICATION_INSTANCE=gerrit-1; cat ./gerrit-common/replication.config.template | envsubst '$${GERRIT_REPLICATION_INSTANCE}' > ./gerrit-2/etc/replication.config
- cp ./gerrit-common/*.config ./gerrit-1/etc
- cp ./gerrit-common/*.config ./gerrit-2/etc
- cp ./gerrit-common/git-daemon.sh ./gerrit-1/bin
- cp ./gerrit-common/git-daemon.sh ./gerrit-2/bin
-
-init_gerrit:
- docker-compose down && docker-compose build gerrit-1 && docker-compose build gerrit-2 && docker-compose up -d gerrit-1 && docker-compose up -d gerrit-2
-
-init_all: clean_gerrit download
- docker-compose down && docker-compose build && INIT=1 docker-compose up -d
-restart_gerrit_1:
- cp ./gerrit-common/*.db ./gerrit-1/db
- -docker-compose kill gerrit-1
- sleep 3; INIT=0 docker-compose up -d gerrit-1
-restart_gerrit_2:
- cp ./gerrit-common/*.db ./gerrit-2/db
- -docker-compose kill gerrit-2
- sleep 3; INIT=0 docker-compose up -d gerrit-2
diff --git a/dockerised_local_env/README.md b/dockerised_local_env/README.md
deleted file mode 100644
index 92be0cd..0000000
--- a/dockerised_local_env/README.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# Dockerised test environment
-
-## Prerequisites
-
-* envsubst:
-
-```bash
-brew install gettext
-brew link --force gettext
-```
-
-* wget:
-
-```bash
-brew install wget
-```
-
-## Instructions
-
-The docker compose provided in this directory is meant to orchestrate the spin up
-of a dockerised test environment with the latest stable Gerrit version.
-Run it with:
-
-```bash
-make init_all
-```
-
-The spin up will take a while, check what is going on with:
-
-```bash
-docker-compose logs -f
-```
-
-*NOTE:* If you want to run any ssh command as admin you can use the ssh keys into the *gerrit-{1,2}/ssh* directory.
-
-If you need to restart one of the Gerrit instances to simulate, for example,
-an upgrade, you can do it this way:
-
-```bash
-make restart_gerrit_1 # (or make restart_gerrit_2)
-```
-
-## How to test
-
-Consider the
-[instructions](https://gerrit-review.googlesource.com/Documentation/dev-e2e-tests.html)
-on how to use Gerrit core's Gatling framework, to run non-core test scenarios
-such as this plugin one below:
-
-```bash
-sbt "gatling:testOnly com.googlesource.gerrit.plugins.multisite.scenarios.CloneUsingMultiGerrit1"
-```
-
-This is a scenario that can serve as an example for how to start testing a
-multi-site Gerrit system, here such as this dockerized one. That scenario tries
-to clone a project created on this dockerized multi Gerrit, from gerrit-1 (port
-8081). The scenario therefore expects Gerrit multi-site to have properly
-synchronized the new project from the up node gerrit-2 to gerrit-1. That
-project gets deleted after by the (so aggregate) scenario.
-
-Scenario scala source files and their companion json resource ones are stored
-under the usual src/test directories. That structure follows the scala package
-one from the scenario classes. The core framework expects such a directory
-structure for both the scala and resources (json data) files.
diff --git a/dockerised_local_env/docker-compose.yaml b/dockerised_local_env/docker-compose.yaml
deleted file mode 100644
index b15684d..0000000
--- a/dockerised_local_env/docker-compose.yaml
+++ /dev/null
@@ -1,111 +0,0 @@
-version: '3'
-services:
- gerrit-1:
- build: ./gerrit-1
- networks:
- gerrit-net:
- environment:
- INIT: ${INIT:-1}
- volumes:
- - ./gerrit-1/git:/var/gerrit/git
- - ./gerrit-1/logs:/var/gerrit/logs
- - ./gerrit-1/ssh:/var/gerrit/.ssh
- - ./gerrit-1/index:/var/gerrit/index
- - ./gerrit-1/data:/var/gerrit/data
- - ./gerrit-1/etc:/var/gerrit/etc
- - ./gerrit-1/db:/var/gerrit/db
- - ./gerrit-1/plugins:/var/gerrit/plugins
- - ./gerrit-1/lib:/var/gerrit/lib
- - ./gerrit-1/tmp:/var/gerrit/tmp
- - ./gerrit-common/shared-dir:/var/gerrit/shared-dir
- ports:
- - "39418:29418"
- - "8081:8080"
- depends_on:
- - sshd
- - zookeeper
- - kafka-broker
- container_name: gerrit-1
- gerrit-2:
- build: ./gerrit-2
- networks:
- gerrit-net:
- environment:
- INIT: ${INIT:-1}
- volumes:
- - ./gerrit-2/git:/var/gerrit/git
- - ./gerrit-2/logs:/var/gerrit/logs
- - ./gerrit-2/ssh:/var/gerrit/.ssh
- - ./gerrit-2/index:/var/gerrit/index
- - ./gerrit-2/data:/var/gerrit/data
- - ./gerrit-2/etc:/var/gerrit/etc
- - ./gerrit-2/db:/var/gerrit/db
- - ./gerrit-2/plugins:/var/gerrit/plugins
- - ./gerrit-2/lib:/var/gerrit/lib
- - ./gerrit-2/tmp:/var/gerrit/tmp
- - ./gerrit-common/shared-dir:/var/gerrit/shared-dir
- ports:
- - "49418:29418"
- - "8082:8080"
- depends_on:
- - sshd
- - zookeeper
- - kafka-broker
- container_name: gerrit-2
- sshd:
- build: ./sshd
- networks:
- gerrit-net:
- volumes:
- - ./gerrit-2/git:/var/gerrit-2/git
- - ./gerrit-2/ssh:/root/.ssh
- - ./gerrit-1/git:/var/gerrit-1/git
- container_name: sshd
- zookeeper:
- image: wurstmeister/zookeeper:latest
- networks:
- gerrit-net:
- ports:
- - "2181:2181"
- kafka-broker:
- image: wurstmeister/kafka:2.12-2.1.0
- networks:
- gerrit-net:
- ports:
- - "9092:9092"
- container_name: kafka-broker
- environment:
- KAFKA_ADVERTISED_HOST_NAME: kafka-broker
- KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
- haproxy:
- build: haproxy
- ports:
- - "8080:8080"
- - "29418:29418"
- networks:
- gerrit-net:
- depends_on:
- - syslog-sidecar
- - gerrit-1
- - gerrit-2
- environment:
- - SYSLOG_SIDECAR=syslog-sidecar
- - GERRIT_1=gerrit-1
- - GERRIT_1_SSH=29418
- - GERRIT_1_HTTP=8080
- - GERRIT_2=gerrit-2
- - GERRIT_2_SSH=29418
- - GERRIT_2_HTTP=8080
- - HAPROXY_HTTP_PORT=8080
- - HAPROXY_SSH_PORT=29418
- syslog-sidecar:
- image: balabit/syslog-ng:3.19.1
- volumes:
- - "./syslog-sidecar/logs:/var/log/syslog-ng"
- - "./syslog-sidecar/socket:/var/run/syslog-ng"
- - "./syslog-sidecar/config/:/etc/syslog-ng"
- networks:
- gerrit-net:
-networks:
- gerrit-net:
- driver: bridge
diff --git a/dockerised_local_env/gerrit-1/Dockerfile b/dockerised_local_env/gerrit-1/Dockerfile
deleted file mode 100644
index 0842933..0000000
--- a/dockerised_local_env/gerrit-1/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM openjdk:8-jdk-alpine
-
-RUN adduser -D -h /var/gerrit gerrit && \
- apk update && apk upgrade && \
- apk add --no-cache bash git openssh netcat-openbsd curl ttf-dejavu && \
- apk add --no-cache git-daemon
-
-COPY --chown=gerrit:gerrit bin/release.war /var/gerrit/bin/gerrit.war
-COPY --chown=gerrit:gerrit plugins /var/gerrit/plugins
-COPY --chown=gerrit:gerrit etc /var/gerrit/etc
-
-ADD bin/git-daemon.sh /usr/local/bin/git-daemon.sh
-RUN chmod +x /usr/local/bin/git-daemon.sh
-
-USER gerrit
-
-WORKDIR /var/gerrit
-
-COPY docker-entrypoint.sh /bin
-
-ENTRYPOINT /bin/docker-entrypoint.sh
diff --git a/dockerised_local_env/gerrit-1/docker-entrypoint.sh b/dockerised_local_env/gerrit-1/docker-entrypoint.sh
deleted file mode 100755
index d0eb5f2..0000000
--- a/dockerised_local_env/gerrit-1/docker-entrypoint.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash -ex
-
-echo "Starting git daemon"
-/usr/local/bin/git-daemon.sh &
-
-if [[ $INIT == 1 ]]; then
- echo "Initializing Gerrit..."
- java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit --batch --dev --install-all-plugins --no-auto-start
- java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit --index accounts
- java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit --index groups
-fi
-
-java -jar /var/gerrit/bin/gerrit.war daemon
diff --git a/dockerised_local_env/gerrit-1/ssh/authorized_keys b/dockerised_local_env/gerrit-1/ssh/authorized_keys
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-1/ssh/authorized_keys
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-1/ssh/config b/dockerised_local_env/gerrit-1/ssh/config
deleted file mode 100644
index e76bebf..0000000
--- a/dockerised_local_env/gerrit-1/ssh/config
+++ /dev/null
@@ -1,6 +0,0 @@
-Host *
- User root
- IdentityFile /var/gerrit/.ssh/id_rsa
- PreferredAuthentications publickey
- # Not ideal at all. Just a quick workaround to avoid updating the known_hosts at startup
- StrictHostKeyChecking no
diff --git a/dockerised_local_env/gerrit-1/ssh/id_rsa b/dockerised_local_env/gerrit-1/ssh/id_rsa
deleted file mode 100644
index 6535ddf..0000000
--- a/dockerised_local_env/gerrit-1/ssh/id_rsa
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-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
------END RSA PRIVATE KEY-----
diff --git a/dockerised_local_env/gerrit-1/ssh/id_rsa.pub b/dockerised_local_env/gerrit-1/ssh/id_rsa.pub
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-1/ssh/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-2/Dockerfile b/dockerised_local_env/gerrit-2/Dockerfile
deleted file mode 100644
index d71b6c2..0000000
--- a/dockerised_local_env/gerrit-2/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM openjdk:8-jdk-alpine
-
-RUN adduser -D -h /var/gerrit gerrit && \
- apk update && apk upgrade && \
- apk add --no-cache bash git openssh netcat-openbsd curl ttf-dejavu && \
- apk add --no-cache git-daemon
-
-COPY --chown=gerrit:gerrit bin/release.war /var/gerrit/bin/gerrit.war
-COPY --chown=gerrit:gerrit plugins/* /var/gerrit/plugins/
-COPY --chown=gerrit:gerrit etc /var/gerrit/etc
-
-ADD bin/git-daemon.sh /usr/local/bin/git-daemon.sh
-RUN chmod +x /usr/local/bin/git-daemon.sh
-
-USER gerrit
-
-WORKDIR /var/gerrit
-
-COPY docker-entrypoint.sh /bin
-
-ENTRYPOINT /bin/docker-entrypoint.sh
diff --git a/dockerised_local_env/gerrit-2/docker-entrypoint.sh b/dockerised_local_env/gerrit-2/docker-entrypoint.sh
deleted file mode 100755
index 06f928f..0000000
--- a/dockerised_local_env/gerrit-2/docker-entrypoint.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash -ex
-
-echo "Starting git daemon"
-/usr/local/bin/git-daemon.sh &
-
-if [[ $INIT == 1 ]]; then
- java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit --batch --dev --no-auto-start --install-all-plugins
-
- echo "Remove git repos created during init phase"
- rm -fr /var/gerrit/git/*
-
- echo "Waiting for gerrit1 server to become available."
- sleep 120
-
- chmod go-r /var/gerrit/.ssh/id_rsa
- ssh-keyscan -t rsa -p 29418 gerrit-1 > /var/gerrit/.ssh/known_hosts
- ssh -p 29418 admin@gerrit-1 replication start
-
- echo "Waiting for replication to complete."
- sleep 30
-fi
-
-java -jar /var/gerrit/bin/gerrit.war daemon
diff --git a/dockerised_local_env/gerrit-2/ssh/authorized_keys b/dockerised_local_env/gerrit-2/ssh/authorized_keys
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-2/ssh/authorized_keys
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-2/ssh/config b/dockerised_local_env/gerrit-2/ssh/config
deleted file mode 100644
index e76bebf..0000000
--- a/dockerised_local_env/gerrit-2/ssh/config
+++ /dev/null
@@ -1,6 +0,0 @@
-Host *
- User root
- IdentityFile /var/gerrit/.ssh/id_rsa
- PreferredAuthentications publickey
- # Not ideal at all. Just a quick workaround to avoid updating the known_hosts at startup
- StrictHostKeyChecking no
diff --git a/dockerised_local_env/gerrit-2/ssh/id_rsa b/dockerised_local_env/gerrit-2/ssh/id_rsa
deleted file mode 100644
index 6535ddf..0000000
--- a/dockerised_local_env/gerrit-2/ssh/id_rsa
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-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
------END RSA PRIVATE KEY-----
diff --git a/dockerised_local_env/gerrit-2/ssh/id_rsa.pub b/dockerised_local_env/gerrit-2/ssh/id_rsa.pub
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-2/ssh/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-common/ReviewDB.h2.db b/dockerised_local_env/gerrit-common/ReviewDB.h2.db
deleted file mode 100644
index d23d444..0000000
--- a/dockerised_local_env/gerrit-common/ReviewDB.h2.db
+++ /dev/null
Binary files differ
diff --git a/dockerised_local_env/gerrit-common/ReviewDB.trace.db b/dockerised_local_env/gerrit-common/ReviewDB.trace.db
deleted file mode 100644
index 52681d8..0000000
--- a/dockerised_local_env/gerrit-common/ReviewDB.trace.db
+++ /dev/null
@@ -1,3 +0,0 @@
-11-23 08:24:02 jdbc[3]: exception
-org.h2.jdbc.JdbcSQLException: Table "SCHEMA_VERSION" not found; SQL statement:
-SELECT T.version_nbr,T.singleton FROM schema_version T WHERE T.singleton=? [42102-176]
diff --git a/dockerised_local_env/gerrit-common/gerrit.config b/dockerised_local_env/gerrit-common/gerrit.config
deleted file mode 100644
index 0a47bea..0000000
--- a/dockerised_local_env/gerrit-common/gerrit.config
+++ /dev/null
@@ -1,39 +0,0 @@
-[gerrit]
- basePath = git
- serverId = ff17821f-9571-42df-b690-30660f2d6e20
- canonicalWebUrl = http://localhost:8080/
- installModule = com.googlesource.gerrit.plugins.multisite.Module
-[database]
- type = h2
- database = db/ReviewDB
-[noteDb "changes"]
- autoMigrate = true
- disableReviewDb = true
- primaryStorage = note db
- read = true
- sequence = true
- write = true
-[container]
- javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
- javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
- javaHome = /usr/lib/jvm/java-1.8-openjdk/jre
- user = gerrit
-[index]
- type = LUCENE
-[auth]
- type = DEVELOPMENT_BECOME_ANY_ACCOUNT
-[receive]
- enableSignedPush = false
-[sendemail]
- smtpServer = localhost
-[sshd]
- listenAddress = *:29418
- advertisedAddress = *:29418
-[httpd]
- listenUrl = proxy-http://*:8080/
-[cache]
- directory = cache
-[plugins]
- allowRemoteAdmin = true
-[plugin "websession-flatfile"]
- directory = /var/gerrit/shared-dir
diff --git a/dockerised_local_env/gerrit-common/git-daemon.sh b/dockerised_local_env/gerrit-common/git-daemon.sh
deleted file mode 100644
index a54c8e0..0000000
--- a/dockerised_local_env/gerrit-common/git-daemon.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-git daemon --verbose --enable=receive-pack --base-path=/var/gerrit/git --export-all
diff --git a/dockerised_local_env/gerrit-common/healthcheck.config b/dockerised_local_env/gerrit-common/healthcheck.config
deleted file mode 100644
index 849e23f..0000000
--- a/dockerised_local_env/gerrit-common/healthcheck.config
+++ /dev/null
@@ -1,9 +0,0 @@
-[healthcheck]
- timeout = 10s
-
-[healthcheck "querychanges"]
- # No changes available when Gerrit is installed from scratch
- enabled = false
-
-[healthcheck "auth"]
- username = "admin"
\ No newline at end of file
diff --git a/dockerised_local_env/gerrit-common/multi-site.config b/dockerised_local_env/gerrit-common/multi-site.config
deleted file mode 100644
index deec00f..0000000
--- a/dockerised_local_env/gerrit-common/multi-site.config
+++ /dev/null
@@ -1,21 +0,0 @@
-[index]
- maxTries = 6
- retryInterval = 30000
- numStripedLocks = 100
-
-[kafka]
- bootstrapServers = kafka-broker:9092
- securityProtocol = PLAINTEXT
- indexEventTopic = gerrit_index
- streamEventTopic = gerrit_stream
- projectListEventTopic = gerrit_list_project
- cacheEventTopic = gerrit_cache_eviction
-
-[kafka "subscriber"]
- pollingIntervalMs = 1000
- KafkaProp-enableAutoCommit = true
- KafkaProp-autoCommitIntervalMs = 1000
- KafkaProp-autoOffsetReset = latest
-
-[ref-database "zookeeper"]
- connectString = "zookeeper:2181"
diff --git a/dockerised_local_env/gerrit-common/replication.config.template b/dockerised_local_env/gerrit-common/replication.config.template
deleted file mode 100644
index 3864e92..0000000
--- a/dockerised_local_env/gerrit-common/replication.config.template
+++ /dev/null
@@ -1,17 +0,0 @@
-[remote "Replication"]
- url = git://${GERRIT_REPLICATION_INSTANCE}:9418/${name}.git
- adminUrl = ssh://root@sshd:22/var/${GERRIT_REPLICATION_INSTANCE}/git/${name}.git
- push = +refs/*:refs/*
- timeout = 600
- rescheduleDelay = 15
- replicationDelay = 5
- mirror = true
- createMissingRepositories = true
- replicateProjectDeletions = true
- replicateHiddenProjects = true
-[gerrit]
- autoReload = true
- replicateOnStartup = false
-[replication]
- lockErrorMaxRetries = 5
- maxRetries = 5
diff --git a/dockerised_local_env/haproxy/Dockerfile b/dockerised_local_env/haproxy/Dockerfile
deleted file mode 100644
index dd3f9cd..0000000
--- a/dockerised_local_env/haproxy/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM haproxy:1.9.4
-
-RUN apt-get update && \
- apt-get -y install gettext-base netcat && \
- rm -rf /var/lib/apt/lists/* && \
- mkdir /var/lib/haproxy && \
- mkdir /var/run/haproxy && \
- useradd haproxy && \
- chown haproxy: /var/lib/haproxy /var/run/haproxy
-
-COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg.template
-
-COPY docker-entrypoint.sh /
diff --git a/dockerised_local_env/haproxy/docker-entrypoint.sh b/dockerised_local_env/haproxy/docker-entrypoint.sh
deleted file mode 100755
index b78a994..0000000
--- a/dockerised_local_env/haproxy/docker-entrypoint.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-envsubst < /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
-haproxy -f /usr/local/etc/haproxy/haproxy.cfg
diff --git a/dockerised_local_env/haproxy/haproxy.cfg b/dockerised_local_env/haproxy/haproxy.cfg
deleted file mode 100644
index 000ed9e..0000000
--- a/dockerised_local_env/haproxy/haproxy.cfg
+++ /dev/null
@@ -1,63 +0,0 @@
-global
- log $SYSLOG_SIDECAR local0
- maxconn 2048
-
-defaults
- log global
- mode http
- option httplog
- option dontlognull
- timeout connect 5000
- timeout client 900000
- timeout server 900000
- timeout check 30000
-
-frontend haproxynode
- bind *:$HAPROXY_HTTP_PORT
- mode http
- acl redirect_reads url_reg -i git-upload-pack
- acl redirect_reads url_reg -i clone.bundle
- acl redirect_writes url_reg -i git-receive-pack
- use_backend read-backendnodes if redirect_reads
- use_backend write-backendnodes if redirect_writes
- default_backend read-backendnodes
-
-frontend git_ssh
- bind *:$HAPROXY_SSH_PORT
- option tcplog
- mode tcp
- timeout client 5m
- default_backend ssh
-
-backend read-backendnodes
- mode http
- balance source
- option forwardfor
- http-request set-header X-Forwarded-Port %[dst_port]
- default-server inter 10s fall 3 rise 2
- option httpchk GET /config/server/healthcheck~status HTTP/1.0
- http-check expect status 200
- server node1 $GERRIT_1:$GERRIT_1_HTTP check inter 10s
- server node2 $GERRIT_2:$GERRIT_2_HTTP check inter 10s
-
-backend write-backendnodes
- mode http
- balance roundrobin
- option forwardfor
- http-request set-header X-Forwarded-Port %[dst_port]
- default-server inter 10s fall 3 rise 2
- option httpchk GET /config/server/healthcheck~status HTTP/1.0
- http-check expect status 200
- server node1 $GERRIT_1:$GERRIT_1_HTTP check inter 10s
- server node2 $GERRIT_2:$GERRIT_2_HTTP check inter 10s backup
-
-backend ssh
- mode tcp
- option redispatch
- option httpchk GET /config/server/healthcheck~status HTTP/1.0
- http-check expect status 200
- balance source
- timeout connect 10s
- timeout server 5m
- server ssh_node1 $GERRIT_1:$GERRIT_1_SSH check inter 10s check port $GERRIT_1_HTTP inter 10s
- server ssh_node2 $GERRIT_2:$GERRIT_2_SSH check inter 10s check port $GERRIT_2_HTTP inter 10s backup
diff --git a/dockerised_local_env/sshd/Dockerfile b/dockerised_local_env/sshd/Dockerfile
deleted file mode 100644
index d1065cd..0000000
--- a/dockerised_local_env/sshd/Dockerfile
+++ /dev/null
@@ -1,6 +0,0 @@
-FROM sickp/alpine-sshd:6.8
-
-RUN apk update && apk upgrade && \
- apk add --no-cache bash git netcat-openbsd curl
-
-COPY sshd_config /etc/ssh/sshd_config
diff --git a/dockerised_local_env/sshd/sshd_config b/dockerised_local_env/sshd/sshd_config
deleted file mode 100644
index c40561f..0000000
--- a/dockerised_local_env/sshd/sshd_config
+++ /dev/null
@@ -1,16 +0,0 @@
-Port 22
-HostKey /etc/ssh/ssh_host_rsa_key
-HostKey /etc/ssh/ssh_host_ecdsa_key
-HostKey /etc/ssh/ssh_host_ed25519_key
-SyslogFacility AUTHPRIV
-LogLevel INFO
-PermitRootLogin yes
-AuthorizedKeysFile /root/.ssh/authorized_keys
-PasswordAuthentication no
-ChallengeResponseAuthentication no
-UsePAM yes
-AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
-AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
-AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
-AcceptEnv XMODIFIERS
-Subsystem sftp /usr/libexec/openssh/sftp-server
diff --git a/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf b/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf
deleted file mode 100644
index bbd27b6..0000000
--- a/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf
+++ /dev/null
@@ -1,31 +0,0 @@
-@version: 3.11
-
-options {
- keep_hostname(yes);
- create_dirs(yes);
- ts_format(iso);
- time_reopen (10);
- chain_hostnames (no);
-};
-
-source s_net {
- tcp(
- ip("0.0.0.0")
- );
- udp(
- ip("0.0.0.0")
- );
- syslog(
- ip("0.0.0.0")
- );
- unix-stream("/var/run/lock/syslog-ng.sock");
-};
-
-destination logfiles {
- file("/var/log/syslog-ng/$PROGRAM.log");
-};
-
-log {
- source(s_net);
- destination(logfiles);
-};
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index fc1b8ad..b91d0d7 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -9,6 +9,6 @@
maven_jar(
name = "events-broker",
- artifact = "com.gerritforge:events-broker:3.4.0-rc0",
- sha1 = "8c34c88103d4783eb4c4decde6d93541bc1cf064",
+ artifact = "com.gerritforge:events-broker:3.4.0.4",
+ sha1 = "8d361d863382290e33828116e65698190118d0f1",
)
diff --git a/setup_local_env/configs/gerrit.config b/setup_local_env/configs/gerrit.config
index c4df06a..5dce6e6 100644
--- a/setup_local_env/configs/gerrit.config
+++ b/setup_local_env/configs/gerrit.config
@@ -5,6 +5,7 @@
installModule = com.gerritforge.gerrit.eventbroker.BrokerApiModule # events-broker module to setup BrokerApi dynamic item
installModule = com.googlesource.gerrit.plugins.multisite.Module # multi-site needs to be a gerrit lib
installDbModule = com.googlesource.gerrit.plugins.multisite.GitModule
+ instanceId = $INSTANCE_ID
[database]
type = h2
database = $LOCATION_TEST_SITE/db/ReviewDB
@@ -43,7 +44,7 @@
[plugin "events-kafka"]
sendAsync = true
bootstrapServers = localhost:$BROKER_PORT
- groupId = $GROUP_ID
+ groupId = $INSTANCE_ID
numberOfSubscribers = 6
securityProtocol = PLAINTEXT
pollingIntervalMs = 1000
@@ -55,12 +56,12 @@
pollingIntervalMs = 1000
region = us-east-1
endpoint = http://localhost:$BROKER_PORT
- applicationName = $GROUP_ID
+ applicationName = $INSTANCE_ID
initialPosition = trim_horizon
[plugin "events-gcloud-pubsub"]
numberOfSubscribers = 6
gcloudProject="test-project"
- subscriptionId=$GROUP_ID
+ subscriptionId=$INSTANCE_ID
privateKeyLocation="not used in local mode"
[plugin "metrics-reporter-prometheus"]
prometheusBearerToken = token
diff --git a/setup_local_env/setup.sh b/setup_local_env/setup.sh
index bebc863..f745482 100755
--- a/setup_local_env/setup.sh
+++ b/setup_local_env/setup.sh
@@ -70,7 +70,7 @@
export GERRIT_HOSTNAME=$7
export REPLICATION_HOSTNAME=$8
export REMOTE_DEBUG_PORT=$9
- export GROUP_ID=${10}
+ export INSTANCE_ID=${10}
export REPLICATION_URL=$(get_replication_url $REPLICATION_LOCATION_TEST_SITE $REPLICATION_HOSTNAME)
echo "Replacing variables for file $file and copying to $CONFIG_TEST_SITE/$file_name"
@@ -122,21 +122,21 @@
GERRIT_SITE1_SSHD_PORT=$3
CONFIG_TEST_SITE_1=$LOCATION_TEST_SITE_1/etc
GERRIT_SITE1_REMOTE_DEBUG_PORT="5005"
- GERRIT_SITE1_GROUP_ID="instance-1"
+ GERRIT_SITE1_INSTANCE_ID="instance-1"
# SITE 2
GERRIT_SITE2_HOSTNAME=$4
GERRIT_SITE2_HTTPD_PORT=$5
GERRIT_SITE2_SSHD_PORT=$6
CONFIG_TEST_SITE_2=$LOCATION_TEST_SITE_2/etc
GERRIT_SITE2_REMOTE_DEBUG_PORT="5006"
- GERRIT_SITE2_GROUP_ID="instance-2"
+ GERRIT_SITE2_INSTANCE_ID="instance-2"
# Set config SITE1
- copy_config_files $CONFIG_TEST_SITE_1 $GERRIT_SITE1_HTTPD_PORT $LOCATION_TEST_SITE_1 $GERRIT_SITE1_SSHD_PORT $GERRIT_SITE2_HTTPD_PORT $LOCATION_TEST_SITE_2 $GERRIT_SITE1_HOSTNAME $GERRIT_SITE2_HOSTNAME $GERRIT_SITE1_REMOTE_DEBUG_PORT $GERRIT_SITE1_GROUP_ID
+ copy_config_files $CONFIG_TEST_SITE_1 $GERRIT_SITE1_HTTPD_PORT $LOCATION_TEST_SITE_1 $GERRIT_SITE1_SSHD_PORT $GERRIT_SITE2_HTTPD_PORT $LOCATION_TEST_SITE_2 $GERRIT_SITE1_HOSTNAME $GERRIT_SITE2_HOSTNAME $GERRIT_SITE1_REMOTE_DEBUG_PORT $GERRIT_SITE1_INSTANCE_ID
# Set config SITE2
- copy_config_files $CONFIG_TEST_SITE_2 $GERRIT_SITE2_HTTPD_PORT $LOCATION_TEST_SITE_2 $GERRIT_SITE2_SSHD_PORT $GERRIT_SITE1_HTTPD_PORT $LOCATION_TEST_SITE_1 $GERRIT_SITE1_HOSTNAME $GERRIT_SITE2_HOSTNAME $GERRIT_SITE2_REMOTE_DEBUG_PORT $GERRIT_SITE2_GROUP_ID
+ copy_config_files $CONFIG_TEST_SITE_2 $GERRIT_SITE2_HTTPD_PORT $LOCATION_TEST_SITE_2 $GERRIT_SITE2_SSHD_PORT $GERRIT_SITE1_HTTPD_PORT $LOCATION_TEST_SITE_1 $GERRIT_SITE1_HOSTNAME $GERRIT_SITE2_HOSTNAME $GERRIT_SITE2_REMOTE_DEBUG_PORT $GERRIT_SITE2_INSTANCE_ID
}
function is_docker_desktop {
@@ -163,6 +163,9 @@
local stream=$1
export AWS_PAGER=''
+ export AWS_ACCESS_KEY_ID=accessKey
+ export AWS_SECRET_ACCESS_KEY=secretKey
+ export AWS_DEFAULT_REGION=us-east-1
echo "[KINESIS] Create stream $stream"
until aws --endpoint-url=http://localhost:$BROKER_PORT kinesis create-stream --shard-count 1 --stream-name "$stream"
do
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jMessageLogger.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jMessageLogger.java
index 1ec8886..95c417f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jMessageLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jMessageLogger.java
@@ -14,8 +14,8 @@
package com.googlesource.gerrit.plugins.multisite;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
import com.google.gerrit.extensions.systemstatus.ServerInformation;
+import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.events.EventGsonProvider;
import com.google.gerrit.server.util.PluginLogFile;
import com.google.gerrit.server.util.SystemLog;
@@ -41,7 +41,7 @@
}
@Override
- public void log(Direction direction, String topic, EventMessage event) {
+ public void log(Direction direction, String topic, Event event) {
msgLog.info("{} {} {}", direction, topic, gson.toJson(event));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/MessageLogger.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/MessageLogger.java
index b1f3e79..cc64b02 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/MessageLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/MessageLogger.java
@@ -14,7 +14,7 @@
package com.googlesource.gerrit.plugins.multisite;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
+import com.google.gerrit.server.events.Event;
public interface MessageLogger {
@@ -23,5 +23,5 @@
CONSUME;
}
- public void log(Direction direction, String topic, EventMessage event);
+ public void log(Direction direction, String topic, Event event);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
index f44f4f7..ad53449 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Module.java
@@ -16,30 +16,18 @@
import com.gerritforge.gerrit.globalrefdb.validation.LibModule;
import com.google.gerrit.lifecycle.LifecycleModule;
-import com.google.gerrit.server.config.SitePaths;
import com.google.inject.CreationException;
import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
import com.google.inject.spi.Message;
+import com.googlesource.gerrit.plugins.multisite.broker.BrokerModule;
import com.googlesource.gerrit.plugins.multisite.cache.CacheModule;
import com.googlesource.gerrit.plugins.multisite.event.EventModule;
import com.googlesource.gerrit.plugins.multisite.forwarder.ForwarderModule;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.RouterModule;
import com.googlesource.gerrit.plugins.multisite.index.IndexModule;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Collection;
-import java.util.UUID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class Module extends LifecycleModule {
- private static final Logger log = LoggerFactory.getLogger(Module.class);
private Configuration config;
@Inject
@@ -72,57 +60,8 @@
install(new IndexModule());
}
+ install(new BrokerModule());
+
install(new RouterModule());
}
-
- @Provides
- @Singleton
- @InstanceId
- UUID getInstanceId(SitePaths sitePaths) throws IOException {
- UUID instanceId = null;
- Path dataDir = sitePaths.data_dir.resolve(Configuration.PLUGIN_NAME);
- if (!dataDir.toFile().exists()) {
- dataDir.toFile().mkdirs();
- }
- String serverIdFile =
- dataDir.toAbsolutePath().toString() + "/" + Configuration.INSTANCE_ID_FILE;
-
- instanceId = tryToLoadSavedInstanceId(serverIdFile);
-
- if (instanceId == null) {
- instanceId = UUID.randomUUID();
- Files.createFile(Paths.get(serverIdFile));
- try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(serverIdFile))) {
- writer.write(instanceId.toString());
- } catch (IOException e) {
- log.warn(
- String.format(
- "Cannot write instance ID, a new one will be generated at instance restart. (%s)",
- e.getMessage()));
- }
- }
- return instanceId;
- }
-
- private UUID tryToLoadSavedInstanceId(String serverIdFile) {
- if (Files.exists(Paths.get(serverIdFile))) {
- try (BufferedReader br = Files.newBufferedReader(Paths.get(serverIdFile))) {
- return UUID.fromString(br.readLine());
- } catch (IOException e) {
- log.warn(
- String.format(
- "Cannot read instance ID from path '%s', deleting the old file and generating a new ID: (%s)",
- serverIdFile, e.getMessage()));
- try {
- Files.delete(Paths.get(serverIdFile));
- } catch (IOException e1) {
- log.warn(
- String.format(
- "Cannot delete old instance ID file at path '%s' with instance ID while generating a new one: (%s)",
- serverIdFile, e1.getMessage()));
- }
- }
- }
- return null;
- }
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapper.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapper.java
index 71be5e6..f58efa7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapper.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapper.java
@@ -15,62 +15,101 @@
package com.googlesource.gerrit.plugins.multisite.broker;
import com.gerritforge.gerrit.eventbroker.BrokerApi;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
import com.gerritforge.gerrit.eventbroker.TopicSubscriber;
+import com.google.common.base.Strings;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.server.events.Event;
import com.google.inject.Inject;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.MessageLogger.Direction;
import com.googlesource.gerrit.plugins.multisite.forwarder.Context;
import java.util.Set;
-import java.util.UUID;
+import java.util.concurrent.Executor;
import java.util.function.Consumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class BrokerApiWrapper implements BrokerApi {
+ private static final Logger log = LoggerFactory.getLogger(BrokerApiWrapper.class);
+ private final Executor executor;
private final DynamicItem<BrokerApi> apiDelegate;
private final BrokerMetrics metrics;
private final MessageLogger msgLog;
- private final UUID instanceId;
@Inject
public BrokerApiWrapper(
+ @BrokerExecutor Executor executor,
DynamicItem<BrokerApi> apiDelegate,
BrokerMetrics metrics,
- MessageLogger msgLog,
- @InstanceId UUID instanceId) {
+ MessageLogger msgLog) {
this.apiDelegate = apiDelegate;
+ this.executor = executor;
this.metrics = metrics;
this.msgLog = msgLog;
- this.instanceId = instanceId;
}
- public boolean send(String topic, Event event) {
- return send(topic, apiDelegate.get().newMessage(instanceId, event));
- }
-
- @Override
- public boolean send(String topic, EventMessage message) {
- if (Context.isForwardedEvent()) {
- return true;
- }
- boolean succeeded = false;
+ public boolean sendSync(String topic, Event event) {
try {
- succeeded = apiDelegate.get().send(topic, message);
- } finally {
- if (succeeded) {
- msgLog.log(Direction.PUBLISH, topic, message);
- metrics.incrementBrokerPublishedMessage();
- } else {
- metrics.incrementBrokerFailedToPublishMessage();
- }
+ return send(topic, event).get();
+ } catch (Throwable e) {
+ log.error(
+ "Failed to publish event '{}' to topic '{}' - error: {} - stack trace: {}",
+ event,
+ topic,
+ e.getMessage(),
+ e.getStackTrace());
+ metrics.incrementBrokerFailedToPublishMessage();
+ return false;
}
- return succeeded;
}
@Override
- public void receiveAsync(String topic, Consumer<EventMessage> messageConsumer) {
+ public ListenableFuture<Boolean> send(String topic, Event message) {
+ SettableFuture<Boolean> resultFuture = SettableFuture.create();
+ if (Context.isForwardedEvent()) {
+ resultFuture.set(true);
+ return resultFuture;
+ }
+
+ if (Strings.isNullOrEmpty(message.instanceId)) {
+ log.warn(
+ "Dropping event '{}' because event instance id cannot be null or empty",
+ message.toString());
+ resultFuture.set(true);
+ return resultFuture;
+ }
+
+ ListenableFuture<Boolean> resfultF = apiDelegate.get().send(topic, message);
+ Futures.addCallback(
+ resfultF,
+ new FutureCallback<Boolean>() {
+ @Override
+ public void onSuccess(Boolean result) {
+ msgLog.log(Direction.PUBLISH, topic, message);
+ metrics.incrementBrokerPublishedMessage();
+ }
+
+ @Override
+ public void onFailure(Throwable throwable) {
+ log.error(
+ "Failed to publish message '{}' to topic '{}' - error: {}",
+ message.toString(),
+ topic,
+ throwable.getMessage());
+ metrics.incrementBrokerFailedToPublishMessage();
+ }
+ },
+ executor);
+
+ return resfultF;
+ }
+
+ @Override
+ public void receiveAsync(String topic, Consumer<Event> messageConsumer) {
apiDelegate.get().receiveAsync(topic, messageConsumer);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/InstanceId.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutor.java
similarity index 83%
rename from src/main/java/com/googlesource/gerrit/plugins/multisite/InstanceId.java
rename to src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutor.java
index 87306a2..aa24eb1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/InstanceId.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutor.java
@@ -1,4 +1,4 @@
-// Copyright (C) 2019 The Android Open Source Project
+// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.googlesource.gerrit.plugins.multisite;
+package com.googlesource.gerrit.plugins.multisite.broker;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@@ -21,4 +21,4 @@
@Retention(RUNTIME)
@BindingAnnotation
-public @interface InstanceId {}
+@interface BrokerExecutor {}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutorProvider.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutorProvider.java
new file mode 100644
index 0000000..e843263
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerExecutorProvider.java
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite.broker;
+
+import com.google.gerrit.server.git.WorkQueue;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.googlesource.gerrit.plugins.multisite.ExecutorProvider;
+
+@Singleton
+class BrokerExecutorProvider extends ExecutorProvider {
+
+ @Inject
+ BrokerExecutorProvider(WorkQueue workQueue) {
+ super(workQueue, 1, "Multi-Site-Broker");
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerModule.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerModule.java
new file mode 100644
index 0000000..a5dac4a
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerModule.java
@@ -0,0 +1,28 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite.broker;
+
+import com.google.gerrit.lifecycle.LifecycleModule;
+import java.util.concurrent.Executor;
+
+public class BrokerModule extends LifecycleModule {
+
+ @Override
+ protected void configure() {
+ bind(Executor.class)
+ .annotatedWith(BrokerExecutor.class)
+ .toProvider(BrokerExecutorProvider.class);
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandler.java
index 2990264..e418da5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandler.java
@@ -17,6 +17,7 @@
import com.google.common.cache.RemovalNotification;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.server.cache.CacheRemovalListener;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.multisite.forwarder.CacheEvictionForwarder;
import com.googlesource.gerrit.plugins.multisite.forwarder.Context;
@@ -28,21 +29,25 @@
private final Executor executor;
private final DynamicSet<CacheEvictionForwarder> forwarders;
private final CachePatternMatcher matcher;
+ private final String instanceId;
@Inject
CacheEvictionHandler(
DynamicSet<CacheEvictionForwarder> forwarders,
@CacheExecutor Executor executor,
- CachePatternMatcher matcher) {
+ CachePatternMatcher matcher,
+ @GerritInstanceId String instanceId) {
this.forwarders = forwarders;
this.executor = executor;
this.matcher = matcher;
+ this.instanceId = instanceId;
}
@Override
public void onRemoval(String plugin, String cache, RemovalNotification<K, V> notification) {
if (!Context.isForwardedEvent() && !notification.wasEvicted() && matcher.matches(cache)) {
- executor.execute(new CacheEvictionTask(new CacheEvictionEvent(cache, notification.getKey())));
+ executor.execute(
+ new CacheEvictionTask(new CacheEvictionEvent(cache, notification.getKey(), instanceId)));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandler.java
index fdc6fc3..44f8417 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandler.java
@@ -19,6 +19,7 @@
import com.google.gerrit.extensions.events.ProjectDeletedListener;
import com.google.gerrit.extensions.events.ProjectEvent;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.forwarder.Context;
@@ -33,15 +34,18 @@
private final DynamicSet<ProjectListUpdateForwarder> forwarders;
private final Executor executor;
private final ProjectsFilter projectsFilter;
+ private final String instanceId;
@Inject
public ProjectListUpdateHandler(
DynamicSet<ProjectListUpdateForwarder> forwarders,
@CacheExecutor Executor executor,
- ProjectsFilter filter) {
+ ProjectsFilter filter,
+ @GerritInstanceId String instanceId) {
this.forwarders = forwarders;
this.executor = executor;
this.projectsFilter = filter;
+ this.instanceId = instanceId;
}
@Override
@@ -59,7 +63,8 @@
private void process(ProjectEvent event, boolean delete) {
if (!Context.isForwardedEvent() && projectsFilter.matches(event.getProjectName())) {
executor.execute(
- new ProjectListUpdateTask(new ProjectListUpdateEvent(event.getProjectName(), delete)));
+ new ProjectListUpdateTask(
+ new ProjectListUpdateEvent(event.getProjectName(), delete, instanceId)));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/AbstractSubcriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/AbstractSubcriber.java
index 1f8766a..7a20c7f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/AbstractSubcriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/AbstractSubcriber.java
@@ -14,19 +14,19 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
+import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
+import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.MessageLogger.Direction;
import com.googlesource.gerrit.plugins.multisite.forwarder.CacheNotFoundException;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.ForwardedEventRouter;
import java.io.IOException;
-import java.util.UUID;
import java.util.function.Consumer;
public abstract class AbstractSubcriber {
@@ -34,7 +34,7 @@
private final ForwardedEventRouter eventRouter;
private final DynamicSet<DroppedEventListener> droppedEventListeners;
- private final UUID instanceId;
+ private final String instanceId;
private final MessageLogger msgLog;
private SubscriberMetrics subscriberMetrics;
private final Configuration cfg;
@@ -43,13 +43,13 @@
public AbstractSubcriber(
ForwardedEventRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String gerritInstanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
this.eventRouter = eventRouter;
this.droppedEventListeners = droppedEventListeners;
- this.instanceId = instanceId;
+ this.instanceId = gerritInstanceId;
this.msgLog = msgLog;
this.subscriberMetrics = subscriberMetrics;
this.cfg = cfg;
@@ -58,28 +58,35 @@
protected abstract EventTopic getTopic();
- public Consumer<EventMessage> getConsumer() {
+ public Consumer<Event> getConsumer() {
return this::processRecord;
}
- private void processRecord(EventMessage event) {
+ private void processRecord(Event event) {
+ String sourceInstanceId = event.instanceId;
- if (event.getHeader().sourceInstanceId.equals(instanceId)) {
- logger.atFiner().log(
- "Dropping event %s produced by our instanceId %s",
- event.toString(), instanceId.toString());
+ if (Strings.isNullOrEmpty(sourceInstanceId) || instanceId.equals(sourceInstanceId)) {
+ if (Strings.isNullOrEmpty(sourceInstanceId)) {
+ logger.atWarning().log(
+ String.format(
+ "Dropping event %s because sourceInstanceId cannot be null", event.toString()));
+ } else {
+ logger.atFiner().log(
+ String.format(
+ "Dropping event %s produced by our instanceId %s", event.toString(), instanceId));
+ }
droppedEventListeners.forEach(l -> l.onEventDropped(event));
} else {
try {
msgLog.log(Direction.CONSUME, topic, event);
- eventRouter.route(event.getEvent());
+ eventRouter.route(event);
subscriberMetrics.incrementSubscriberConsumedMessage();
subscriberMetrics.updateReplicationStatusMetrics(event);
} catch (IOException e) {
- logger.atSevere().withCause(e).log("Malformed event '%s'", event.getHeader());
+ logger.atSevere().withCause(e).log("Malformed event '%s'", event);
subscriberMetrics.incrementSubscriberFailedToConsumeMessage();
} catch (PermissionBackendException | CacheNotFoundException e) {
- logger.atSevere().withCause(e).log("Cannot handle message '%s'", event.getHeader());
+ logger.atSevere().withCause(e).log("Cannot handle message '%s'", event);
subscriberMetrics.incrementSubscriberFailedToConsumeMessage();
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/BatchIndexEventSubscriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/BatchIndexEventSubscriber.java
index 5bbaee0..80f61f6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/BatchIndexEventSubscriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/BatchIndexEventSubscriber.java
@@ -15,14 +15,13 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.IndexEventRouter;
-import java.util.UUID;
@Singleton
public class BatchIndexEventSubscriber extends AbstractSubcriber {
@@ -30,7 +29,7 @@
public BatchIndexEventSubscriber(
IndexEventRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String instanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/CacheEvictionEventSubscriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/CacheEvictionEventSubscriber.java
index eae66b4..5f57156 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/CacheEvictionEventSubscriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/CacheEvictionEventSubscriber.java
@@ -15,14 +15,13 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.CacheEvictionEventRouter;
-import java.util.UUID;
@Singleton
public class CacheEvictionEventSubscriber extends AbstractSubcriber {
@@ -30,7 +29,7 @@
public CacheEvictionEventSubscriber(
CacheEvictionEventRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String instanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/DroppedEventListener.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/DroppedEventListener.java
index 6f4680c..b34e02c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/DroppedEventListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/DroppedEventListener.java
@@ -14,7 +14,7 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
+import com.google.gerrit.server.events.Event;
public interface DroppedEventListener {
/**
@@ -22,5 +22,5 @@
*
* @param event information about the event.
*/
- void onEventDropped(EventMessage event);
+ void onEventDropped(Event event);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/IndexEventSubscriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/IndexEventSubscriber.java
index 49d470a..8809799 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/IndexEventSubscriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/IndexEventSubscriber.java
@@ -15,14 +15,13 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.IndexEventRouter;
-import java.util.UUID;
@Singleton
public class IndexEventSubscriber extends AbstractSubcriber {
@@ -30,7 +29,7 @@
public IndexEventSubscriber(
IndexEventRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String instanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/ProjectUpdateEventSubscriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/ProjectUpdateEventSubscriber.java
index 6ff0969..239f3ac 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/ProjectUpdateEventSubscriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/ProjectUpdateEventSubscriber.java
@@ -15,14 +15,13 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.ProjectListUpdateRouter;
-import java.util.UUID;
@Singleton
public class ProjectUpdateEventSubscriber extends AbstractSubcriber {
@@ -30,7 +29,7 @@
public ProjectUpdateEventSubscriber(
ProjectListUpdateRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String instanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/StreamEventSubscriber.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/StreamEventSubscriber.java
index 20c355e..57a3f51 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/StreamEventSubscriber.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/StreamEventSubscriber.java
@@ -15,14 +15,13 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.InstanceId;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.EventTopic;
import com.googlesource.gerrit.plugins.multisite.forwarder.router.StreamEventRouter;
-import java.util.UUID;
@Singleton
public class StreamEventSubscriber extends AbstractSubcriber {
@@ -30,7 +29,7 @@
public StreamEventSubscriber(
StreamEventRouter eventRouter,
DynamicSet<DroppedEventListener> droppedEventListeners,
- @InstanceId UUID instanceId,
+ @GerritInstanceId String instanceId,
MessageLogger msgLog,
SubscriberMetrics subscriberMetrics,
Configuration cfg) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
index 1f264b0..f7d5f99 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
@@ -14,7 +14,6 @@
package com.googlesource.gerrit.plugins.multisite.consumer;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.entities.Project;
@@ -101,8 +100,7 @@
subscriberFailureCounter.increment(SUBSCRIBER_FAILURE_COUNTER);
}
- public void updateReplicationStatusMetrics(EventMessage eventMessage) {
- Event event = eventMessage.getEvent();
+ public void updateReplicationStatusMetrics(Event event) {
if (event instanceof RefReplicationDoneEvent
|| event instanceof RefReplicatedEvent
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
index da19fed..c833bbc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
@@ -46,6 +46,6 @@
return true;
}
- return broker.send(eventTopic.topic(cfg), event);
+ return broker.sendSync(eventTopic.topic(cfg), event);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerStreamEventForwarder.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerStreamEventForwarder.java
index 9ff4688..8a020fc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerStreamEventForwarder.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerStreamEventForwarder.java
@@ -35,6 +35,6 @@
@Override
public boolean send(Event event) {
- return broker.send(EventTopic.STREAM_EVENT_TOPIC.topic(cfg), event);
+ return broker.sendSync(EventTopic.STREAM_EVENT_TOPIC.topic(cfg), event);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/AccountIndexEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/AccountIndexEvent.java
index 317eb76..065ef7e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/AccountIndexEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/AccountIndexEvent.java
@@ -21,8 +21,8 @@
public int accountId;
- public AccountIndexEvent(int accountId) {
- super(TYPE);
+ public AccountIndexEvent(int accountId, String instanceId) {
+ super(TYPE, instanceId);
this.accountId = accountId;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/CacheEvictionEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/CacheEvictionEvent.java
index 1c2185f..4444756 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/CacheEvictionEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/CacheEvictionEvent.java
@@ -22,8 +22,8 @@
public String cacheName;
public Object key;
- public CacheEvictionEvent(String cacheName, Object key) {
- super(TYPE);
+ public CacheEvictionEvent(String cacheName, Object key, String instanceId) {
+ super(TYPE, instanceId);
this.cacheName = cacheName;
this.key = key;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ChangeIndexEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ChangeIndexEvent.java
index ab4ddf4..64fbdfb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ChangeIndexEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ChangeIndexEvent.java
@@ -28,8 +28,8 @@
public String targetSha;
public boolean deleted;
- public ChangeIndexEvent(String projectName, int changeId, boolean deleted) {
- super(TYPE);
+ public ChangeIndexEvent(String projectName, int changeId, boolean deleted, String instanceId) {
+ super(TYPE, instanceId);
this.projectName = projectName;
this.changeId = changeId;
this.deleted = deleted;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/GroupIndexEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/GroupIndexEvent.java
index 4981b2f..05ac198 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/GroupIndexEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/GroupIndexEvent.java
@@ -24,8 +24,8 @@
public final String groupUUID;
public final ObjectId sha1;
- public GroupIndexEvent(String groupUUID, @Nullable ObjectId sha1) {
- super(TYPE);
+ public GroupIndexEvent(String groupUUID, @Nullable ObjectId sha1, String instanceId) {
+ super(TYPE, instanceId);
this.groupUUID = groupUUID;
this.sha1 = sha1;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/IndexEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/IndexEvent.java
index ea2c3fb..2fdda72 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/IndexEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/IndexEvent.java
@@ -15,7 +15,7 @@
package com.googlesource.gerrit.plugins.multisite.forwarder.events;
public abstract class IndexEvent extends MultiSiteEvent {
- protected IndexEvent(String type) {
- super(type);
+ protected IndexEvent(String type, String instanceId) {
+ super(type, instanceId);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/MultiSiteEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/MultiSiteEvent.java
index 404d168..f29204b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/MultiSiteEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/MultiSiteEvent.java
@@ -29,7 +29,8 @@
register(ProjectListUpdateEvent.TYPE, ProjectListUpdateEvent.class);
}
- protected MultiSiteEvent(String type) {
+ protected MultiSiteEvent(String type, String instanceId) {
super(type);
+ this.instanceId = instanceId;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectIndexEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectIndexEvent.java
index 8bdb7b5..954befb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectIndexEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectIndexEvent.java
@@ -21,8 +21,8 @@
public String projectName;
- public ProjectIndexEvent(String projectName) {
- super(TYPE);
+ public ProjectIndexEvent(String projectName, String instanceId) {
+ super(TYPE, instanceId);
this.projectName = projectName;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectListUpdateEvent.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectListUpdateEvent.java
index d030e5b..0e18b27 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectListUpdateEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/events/ProjectListUpdateEvent.java
@@ -22,8 +22,8 @@
public String projectName;
public boolean remove;
- public ProjectListUpdateEvent(String projectName, boolean remove) {
- super(TYPE);
+ public ProjectListUpdateEvent(String projectName, boolean remove, String instanceId) {
+ super(TYPE, instanceId);
this.projectName = projectName;
this.remove = remove;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
index 08b26f7..983a07b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
@@ -19,6 +19,7 @@
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.change.ChangeFinder;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.util.ManualRequestContext;
@@ -42,6 +43,7 @@
private final OneOffRequestContext oneOffReqCtx;
private final String changeId;
private final ChangeFinder changeFinder;
+ private final String instanceId;
private Optional<Long> computedChangeTs = Optional.empty();
private Optional<ChangeNotes> changeNotes = Optional.empty();
@@ -55,12 +57,14 @@
CommentsUtil commentsUtil,
ChangeFinder changeFinder,
OneOffRequestContext oneOffReqCtx,
+ @GerritInstanceId String instanceId,
@Assisted String changeId) {
this.changeFinder = changeFinder;
this.gitRepoMgr = gitRepoMgr;
this.commentsUtil = commentsUtil;
this.oneOffReqCtx = oneOffReqCtx;
this.changeId = changeId;
+ this.instanceId = instanceId;
}
@Override
@@ -69,7 +73,8 @@
return getComputedChangeTs()
.map(
ts -> {
- ChangeIndexEvent event = new ChangeIndexEvent(projectName, changeId, deleted);
+ ChangeIndexEvent event =
+ new ChangeIndexEvent(projectName, changeId, deleted, instanceId);
event.eventCreatedOn = ts;
event.targetSha = getBranchTargetSha();
return event;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandler.java
index eef3e4b..02f1b1c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandler.java
@@ -21,6 +21,7 @@
import com.google.gerrit.extensions.events.GroupIndexedListener;
import com.google.gerrit.extensions.events.ProjectIndexedListener;
import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.multisite.forwarder.Context;
import com.googlesource.gerrit.plugins.multisite.forwarder.ForwarderTask;
@@ -48,6 +49,7 @@
private final ChangeCheckerImpl.Factory changeChecker;
private final ProjectsFilter projectsFilter;
private final GroupChecker groupChecker;
+ private final String instanceId;
@Inject
IndexEventHandler(
@@ -55,18 +57,20 @@
DynamicSet<IndexEventForwarder> forwarders,
ChangeCheckerImpl.Factory changeChecker,
ProjectsFilter projectsFilter,
- GroupChecker groupChecker) {
+ GroupChecker groupChecker,
+ @GerritInstanceId String instanceId) {
this.forwarders = forwarders;
this.executor = executor;
this.changeChecker = changeChecker;
this.projectsFilter = projectsFilter;
this.groupChecker = groupChecker;
+ this.instanceId = instanceId;
}
@Override
public void onAccountIndexed(int id) {
if (!Context.isForwardedEvent()) {
- IndexAccountTask task = new IndexAccountTask(new AccountIndexEvent(id));
+ IndexAccountTask task = new IndexAccountTask(new AccountIndexEvent(id, instanceId));
if (queuedTasks.add(task)) {
executor.execute(task);
}
@@ -87,7 +91,8 @@
public void onGroupIndexed(String groupUUID) {
if (!Context.isForwardedEvent()) {
IndexGroupTask task =
- new IndexGroupTask(new GroupIndexEvent(groupUUID, groupChecker.getGroupHead(groupUUID)));
+ new IndexGroupTask(
+ new GroupIndexEvent(groupUUID, groupChecker.getGroupHead(groupUUID), instanceId));
if (queuedTasks.add(task)) {
executor.execute(task);
}
@@ -97,7 +102,7 @@
@Override
public void onProjectIndexed(String projectName) {
if (!Context.isForwardedEvent() && projectsFilter.matches(projectName)) {
- IndexProjectTask task = new IndexProjectTask(new ProjectIndexEvent(projectName));
+ IndexProjectTask task = new IndexProjectTask(new ProjectIndexEvent(projectName, instanceId));
if (queuedTasks.add(task)) {
executor.execute(task);
}
@@ -132,7 +137,7 @@
private void executeDeleteChangeTask(int id) {
if (!Context.isForwardedEvent()) {
- IndexChangeTask task = new IndexChangeTask(new ChangeIndexEvent("", id, true));
+ IndexChangeTask task = new IndexChangeTask(new ChangeIndexEvent("", id, true, instanceId));
if (queuedTasks.add(task)) {
executor.execute(task);
}
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
index 623871b..159e4a0 100644
--- a/src/main/resources/Documentation/about.md
+++ b/src/main/resources/Documentation/about.md
@@ -7,7 +7,8 @@
message broker for aligning with the other masters over different sites.
The masters must be:
-
+* Gerrit instance id is mandatory for @PLUGIN@ plugin. All the master
+ must have [gerrit.instanceId](https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#gerrit) populated.
* events-broker library must be installed as a library module in the
`$GERRIT_SITE/lib` directory of all the masters
* global-refdb library must be installed as a library module in the
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/ModuleTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/ModuleTest.java
deleted file mode 100644
index 2df60dd..0000000
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/ModuleTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.multisite;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.gerrit.server.config.SitePaths;
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.UUID;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ModuleTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Configuration configMock;
-
- @Rule public TemporaryFolder tempFolder = new TemporaryFolder();
-
- private Module module;
-
- @Before
- public void setup() {
- module = new Module(configMock);
- }
-
- @Test
- public void shouldGetInstanceId() throws Exception {
- File tmpSitePath = tempFolder.newFolder();
- File tmpPluginDataPath =
- Paths.get(tmpSitePath.getPath(), "data", Configuration.PLUGIN_NAME).toFile();
- tmpPluginDataPath.mkdirs();
- Path path = Paths.get(tmpPluginDataPath.getPath(), Configuration.INSTANCE_ID_FILE);
- SitePaths sitePaths = new SitePaths(Paths.get(tmpSitePath.getPath()));
- assertThat(path.toFile().exists()).isFalse();
-
- UUID gotUUID1 = module.getInstanceId(sitePaths);
- assertThat(gotUUID1).isNotNull();
- assertThat(path.toFile().exists()).isTrue();
-
- UUID gotUUID2 = module.getInstanceId(sitePaths);
- assertThat(gotUUID1).isEqualTo(gotUUID2);
- }
-}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapperTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapperTest.java
index 92fa101..7d1751c 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapperTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerApiWrapperTest.java
@@ -1,15 +1,19 @@
package com.googlesource.gerrit.plugins.multisite.broker;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.gerritforge.gerrit.eventbroker.BrokerApi;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.SettableFuture;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.server.events.Event;
+import com.google.gerrit.server.events.ProjectCreatedEvent;
import com.googlesource.gerrit.plugins.multisite.MessageLogger;
-import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,28 +26,35 @@
@Mock private BrokerApi brokerApi;
@Mock Event event;
@Mock MessageLogger msgLog;
- private UUID instanceId = UUID.randomUUID();
private String topic = "index";
private BrokerApiWrapper objectUnderTest;
@Before
public void setUp() {
+ event.instanceId = "instance-id";
objectUnderTest =
new BrokerApiWrapper(
- DynamicItem.itemOf(BrokerApi.class, brokerApi), brokerMetrics, msgLog, instanceId);
+ MoreExecutors.directExecutor(),
+ DynamicItem.itemOf(BrokerApi.class, brokerApi),
+ brokerMetrics,
+ msgLog);
}
@Test
public void shouldIncrementBrokerMetricCounterWhenMessagePublished() {
- when(brokerApi.send(any(), any())).thenReturn(true);
+ SettableFuture<Boolean> resultF = SettableFuture.create();
+ resultF.set(true);
+ when(brokerApi.send(any(), any())).thenReturn(resultF);
objectUnderTest.send(topic, event);
verify(brokerMetrics, only()).incrementBrokerPublishedMessage();
}
@Test
public void shouldIncrementBrokerFailedMetricCounterWhenMessagePublishingFailed() {
- when(brokerApi.send(any(), any())).thenReturn(false);
+ SettableFuture<Boolean> resultF = SettableFuture.create();
+ resultF.setException(new Exception("Force Future failure"));
+ when(brokerApi.send(any(), any())).thenReturn(resultF);
objectUnderTest.send(topic, event);
verify(brokerMetrics, only()).incrementBrokerFailedToPublishMessage();
}
@@ -53,10 +64,26 @@
when(brokerApi.send(any(), any()))
.thenThrow(new RuntimeException("Unexpected runtime exception"));
try {
- objectUnderTest.send(topic, event);
+ objectUnderTest.sendSync(topic, event);
} catch (RuntimeException e) {
// expected
}
verify(brokerMetrics, only()).incrementBrokerFailedToPublishMessage();
}
+
+ @Test
+ public void shouldSkipMessageSendingWhenInstanceIdIsNull() {
+ ProjectCreatedEvent event = new ProjectCreatedEvent();
+ event.instanceId = null;
+ objectUnderTest.send(topic, event);
+ verify(brokerApi, never()).send(any(), eq(event));
+ }
+
+ @Test
+ public void shouldSkipMessageSendingWhenInstanceIdIsEmpty() {
+ ProjectCreatedEvent event = new ProjectCreatedEvent();
+ event.instanceId = "";
+ objectUnderTest.send(topic, event);
+ verify(brokerApi, never()).send(any(), eq(event));
+ }
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandlerTest.java
index 67be583..ce222d0 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/CacheEvictionHandlerTest.java
@@ -36,9 +36,10 @@
@Test
public void shouldNotPublishAccountsCacheEvictions() {
-
+ String instanceId = "instance-id";
final CacheEvictionHandler<String, String> handler =
- new CacheEvictionHandler<>(DynamicSet.emptySet(), executorMock, defaultCacheMatcher);
+ new CacheEvictionHandler<>(
+ DynamicSet.emptySet(), executorMock, defaultCacheMatcher, instanceId);
handler.onRemoval(
"test", "accounts", RemovalNotification.create("test", "accounts", RemovalCause.EXPLICIT));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandlerTest.java
index 4263ddb..c8216bd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/cache/ProjectListUpdateHandlerTest.java
@@ -41,6 +41,8 @@
@RunWith(MockitoJUnitRunner.class)
public class ProjectListUpdateHandlerTest {
+ private static final String INSTANCE_ID = "instance-id";
+
private ProjectListUpdateHandler handler;
@Mock private ProjectListUpdateForwarder forwarder;
@@ -51,7 +53,7 @@
when(projectsFilter.matches(any(String.class))).thenReturn(true);
handler =
new ProjectListUpdateHandler(
- asDynamicSet(forwarder), MoreExecutors.directExecutor(), projectsFilter);
+ asDynamicSet(forwarder), MoreExecutors.directExecutor(), projectsFilter, INSTANCE_ID);
}
private DynamicSet<ProjectListUpdateForwarder> asDynamicSet(
@@ -69,7 +71,8 @@
handler.onNewProjectCreated(event);
verify(forwarder)
.updateProjectList(
- any(ProjectListUpdateTask.class), eq(new ProjectListUpdateEvent(projectName, false)));
+ any(ProjectListUpdateTask.class),
+ eq(new ProjectListUpdateEvent(projectName, false, INSTANCE_ID)));
}
@Test
@@ -80,7 +83,8 @@
handler.onProjectDeleted(event);
verify(forwarder)
.updateProjectList(
- any(ProjectListUpdateTask.class), eq(new ProjectListUpdateEvent(projectName, true)));
+ any(ProjectListUpdateTask.class),
+ eq(new ProjectListUpdateEvent(projectName, true, INSTANCE_ID)));
}
@Test
@@ -101,18 +105,22 @@
handler.onNewProjectCreated(event);
verify(forwarder, never())
.updateProjectList(
- any(ProjectListUpdateTask.class), eq(new ProjectListUpdateEvent(projectName, true)));
+ any(ProjectListUpdateTask.class),
+ eq(new ProjectListUpdateEvent(projectName, true, INSTANCE_ID)));
}
@Test
public void testProjectUpdateTaskToString() throws Exception {
String projectName = "someProjectName";
ProjectListUpdateTask task =
- handler.new ProjectListUpdateTask(new ProjectListUpdateEvent(projectName, false));
+ handler
+ .new ProjectListUpdateTask(new ProjectListUpdateEvent(projectName, false, INSTANCE_ID));
assertThat(task.toString())
.isEqualTo(String.format("Update project list in target instance: add '%s'", projectName));
- task = handler.new ProjectListUpdateTask(new ProjectListUpdateEvent(projectName, true));
+ task =
+ handler
+ .new ProjectListUpdateTask(new ProjectListUpdateEvent(projectName, true, INSTANCE_ID));
assertThat(task.toString())
.isEqualTo(
String.format("Update project list in target instance: remove '%s'", projectName));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
index c27dea2..aa17c36 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
@@ -19,18 +19,17 @@
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import com.gerritforge.gerrit.eventbroker.EventMessage;
import com.google.common.base.Suppliers;
import com.google.gerrit.entities.Project;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.server.data.RefUpdateAttribute;
+import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.events.RefUpdatedEvent;
import com.googlesource.gerrit.plugins.multisite.ProjectVersionLogger;
import com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate;
import com.googlesource.gerrit.plugins.replication.events.ProjectDeletionReplicationSucceededEvent;
import java.net.URISyntaxException;
import java.util.Optional;
-import java.util.UUID;
import org.eclipse.jgit.transport.URIish;
import org.junit.Before;
import org.junit.Test;
@@ -48,11 +47,9 @@
@Mock private ProjectVersionLogger verLogger;
@Mock private ProjectVersionRefUpdate projectVersionRefUpdate;
private SubscriberMetrics metrics;
- private EventMessage.Header msgHeader;
@Before
public void setup() throws Exception {
- msgHeader = new EventMessage.Header(UUID.randomUUID(), UUID.randomUUID());
metrics = new SubscriberMetrics(metricMaker, projectVersionRefUpdate, verLogger);
}
@@ -64,7 +61,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(globalRefDbVersion);
- EventMessage eventMessage = new EventMessage(msgHeader, newRefUpdateEvent());
+ Event eventMessage = newRefUpdateEvent();
metrics.updateReplicationStatusMetrics(eventMessage);
@@ -80,7 +77,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(globalRefDbVersion);
- EventMessage eventMessage = new EventMessage(msgHeader, newRefUpdateEvent());
+ Event eventMessage = newRefUpdateEvent();
metrics.updateReplicationStatusMetrics(eventMessage);
@@ -99,7 +96,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(globalRefDbVersion);
- EventMessage refUpdateEventMessage = new EventMessage(msgHeader, newRefUpdateEvent());
+ Event refUpdateEventMessage = newRefUpdateEvent();
metrics.updateReplicationStatusMetrics(refUpdateEventMessage);
assertThat(metrics.getReplicationStatus(A_TEST_PROJECT_NAME)).isEqualTo(replicationLagSecs);
@@ -108,7 +105,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(Optional.empty());
- EventMessage projectDeleteEventMessage = new EventMessage(msgHeader, projectDeletionSuccess());
+ Event projectDeleteEventMessage = projectDeletionSuccess();
metrics.updateReplicationStatusMetrics(projectDeleteEventMessage);
verify(verLogger).logDeleted(A_TEST_PROJECT_NAME_KEY);
@@ -117,7 +114,7 @@
@Test
public void shouldNotLogUponProjectDeletionSuccessWhenSubscriberMetricsDoNotExist()
throws Exception {
- EventMessage eventMessage = new EventMessage(msgHeader, projectDeletionSuccess());
+ Event eventMessage = projectDeletionSuccess();
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(Optional.empty());
@@ -131,7 +128,7 @@
@Test
public void shouldNotLogUponProjectDeletionSuccessWhenLocalVersionStillExists() throws Exception {
- EventMessage eventMessage = new EventMessage(msgHeader, projectDeletionSuccess());
+ Event eventMessage = projectDeletionSuccess();
Optional<Long> anyRefVersionValue = Optional.of(System.currentTimeMillis() / 1000);
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(anyRefVersionValue);
@@ -151,7 +148,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(globalRefDbVersion);
- EventMessage eventMessage = new EventMessage(msgHeader, newRefUpdateEvent());
+ Event eventMessage = newRefUpdateEvent();
metrics.updateReplicationStatusMetrics(eventMessage);
@@ -160,7 +157,7 @@
when(projectVersionRefUpdate.getProjectLocalVersion(A_TEST_PROJECT_NAME))
.thenReturn(Optional.empty());
- EventMessage projectDeleteEvent = new EventMessage(msgHeader, projectDeletionSuccess());
+ Event projectDeleteEvent = projectDeletionSuccess();
metrics.updateReplicationStatusMetrics(projectDeleteEvent);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
index bf5c5d9..50507e7 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
@@ -31,6 +31,7 @@
@RunWith(MockitoJUnitRunner.class)
public class CacheEvictionEventRouterTest {
+ private static final String INSTANCE_ID = "instance-id";
private CacheEvictionEventRouter router;
@Mock private ForwardedCacheEvictionHandler cacheEvictionHandler;
@@ -41,7 +42,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_CacheEviction() throws Exception {
- final CacheEvictionEvent event = new CacheEvictionEvent("cache", "key");
+ final CacheEvictionEvent event = new CacheEvictionEvent("cache", "key", INSTANCE_ID);
router.route(event);
verify(cacheEvictionHandler).evict(CacheEntry.from(event.cacheName, event.key));
@@ -50,7 +51,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_ProjectCacheEvictionWithSlash()
throws Exception {
- final CacheEvictionEvent event = new CacheEvictionEvent("cache", "some/project");
+ final CacheEvictionEvent event = new CacheEvictionEvent("cache", "some/project", INSTANCE_ID);
router.route(event);
verify(cacheEvictionHandler).evict(CacheEntry.from(event.cacheName, event.key));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
index f22cb14..8efa2ed 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
@@ -44,7 +44,7 @@
@RunWith(MockitoJUnitRunner.class)
public class IndexEventRouterTest {
-
+ private static final String INSTANCE_ID = "instance-id";
private IndexEventRouter router;
@Mock private ForwardedIndexAccountHandler indexAccountHandler;
@Mock private ForwardedIndexChangeHandler indexChangeHandler;
@@ -66,7 +66,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_AccountIndex() throws Exception {
- final AccountIndexEvent event = new AccountIndexEvent(1);
+ final AccountIndexEvent event = new AccountIndexEvent(1, INSTANCE_ID);
router.route(event);
verify(indexAccountHandler)
@@ -80,7 +80,7 @@
StreamEventRouter streamEventRouter = new StreamEventRouter(forwardedEventHandler, router);
- final AccountIndexEvent event = new AccountIndexEvent(1);
+ final AccountIndexEvent event = new AccountIndexEvent(1, INSTANCE_ID);
router.route(event);
verify(indexAccountHandler)
@@ -96,7 +96,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_GroupIndex() throws Exception {
final String groupId = "12";
- final GroupIndexEvent event = new GroupIndexEvent(groupId, ObjectId.zeroId());
+ final GroupIndexEvent event = new GroupIndexEvent(groupId, ObjectId.zeroId(), INSTANCE_ID);
router.route(event);
verify(indexGroupHandler)
@@ -108,7 +108,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_ProjectIndex() throws Exception {
final String projectName = "projectName";
- final ProjectIndexEvent event = new ProjectIndexEvent(projectName);
+ final ProjectIndexEvent event = new ProjectIndexEvent(projectName, INSTANCE_ID);
router.route(event);
verify(indexProjectHandler)
@@ -119,7 +119,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_ChangeIndex() throws Exception {
- final ChangeIndexEvent event = new ChangeIndexEvent("projectName", 3, false);
+ final ChangeIndexEvent event = new ChangeIndexEvent("projectName", 3, false, INSTANCE_ID);
router.route(event);
verify(indexChangeHandler)
@@ -133,7 +133,7 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_ChangeIndexDelete() throws Exception {
- final ChangeIndexEvent event = new ChangeIndexEvent("projectName", 3, true);
+ final ChangeIndexEvent event = new ChangeIndexEvent("projectName", 3, true, INSTANCE_ID);
router.route(event);
verify(indexChangeHandler)
@@ -147,7 +147,7 @@
@Test
public void routerShouldFailForNotRecognisedEvents() throws Exception {
- final IndexEvent newEventType = new IndexEvent("new-type") {};
+ final IndexEvent newEventType = new IndexEvent("new-type", INSTANCE_ID) {};
assertThrows(UnsupportedOperationException.class, () -> router.route(newEventType));
verifyZeroInteractions(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/ProjectListUpdateRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/ProjectListUpdateRouterTest.java
index 93daf92..8a21c39 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/ProjectListUpdateRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/ProjectListUpdateRouterTest.java
@@ -38,7 +38,8 @@
@Test
public void routerShouldSendEventsToTheAppropriateHandler_ProjectListUpdate() throws Exception {
- final ProjectListUpdateEvent event = new ProjectListUpdateEvent("project", false);
+ String instanceId = "instance-id";
+ final ProjectListUpdateEvent event = new ProjectListUpdateEvent("project", false, instanceId);
router.route(event);
verify(projectListUpdateHandler).update(event);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java
index 74d8917..6aab497 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java
@@ -70,7 +70,7 @@
public static class TestEvent extends MultiSiteEvent {
protected TestEvent() {
- super("test");
+ super("test", "instance-id");
}
}
@@ -92,7 +92,7 @@
@Test
public void shouldSendEventToBrokerFromGenericSourceThread() {
brokerForwarder.send(newForwarderTask(), testTopic, testEvent);
- verify(brokerMock).send(eq(testTopicName), eq(testEvent));
+ verify(brokerMock).sendSync(eq(testTopicName), eq(testEvent));
}
@Test
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerIT.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerIT.java
index fb2a50b..b3d46cf 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerIT.java
@@ -22,6 +22,7 @@
import com.google.common.collect.Sets;
import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.server.cache.CacheRemovalListener;
@@ -121,9 +122,10 @@
}
@Test
+ @GerritConfig(name = "gerrit.instanceId", value = "testInstanceId")
public void shouldEvictProjectCache() throws Exception {
objectUnderTest.route(
- new CacheEvictionEvent(ProjectCacheImpl.CACHE_NAME, gson.toJson(project)));
+ new CacheEvictionEvent(ProjectCacheImpl.CACHE_NAME, gson.toJson(project), "instance-id"));
evictionsCacheTracker.waitForExpectedEvictions();
assertThat(evictionsCacheTracker.trackedEvictionsFor(ProjectCacheImpl.CACHE_NAME))
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
index e64759c..452a0d2 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
@@ -104,7 +104,9 @@
public void changeIsStillIndexedEvenWhenOutdated() throws Exception {
setupChangeAccessRelatedMocks(CHANGE_EXISTS, CHANGE_OUTDATED);
handler.index(
- TEST_CHANGE_ID, Operation.INDEX, Optional.of(new ChangeIndexEvent("foo", 1, false)));
+ TEST_CHANGE_ID,
+ Operation.INDEX,
+ Optional.of(new ChangeIndexEvent("foo", 1, false, "instance-id")));
verify(indexerMock, times(1)).index(any(Change.class));
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
index 65d8d20..b49dbfa 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
@@ -143,6 +143,6 @@
}
private Optional<GroupIndexEvent> groupIndexEvent(String uuid) {
- return Optional.of(new GroupIndexEvent(uuid, null));
+ return Optional.of(new GroupIndexEvent(uuid, null, "instance-id"));
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
index 9893ce7..2412c79 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
@@ -34,6 +34,7 @@
@RunWith(MockitoJUnitRunner.class)
public class ForwardedProjectListUpdateHandlerTest {
+ private static final String INSTANCE_ID = "instance-id";
private static final String PROJECT_NAME = "someProject";
private static final String SOME_MESSAGE = "someMessage";
private static final Project.NameKey PROJECT_KEY = Project.nameKey(PROJECT_NAME);
@@ -48,13 +49,13 @@
@Test
public void testSuccessfulAdd() throws Exception {
- handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false));
+ handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false, INSTANCE_ID));
verify(projectCacheMock).onCreateProject(PROJECT_KEY);
}
@Test
public void testSuccessfulRemove() throws Exception {
- handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true));
+ handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true, INSTANCE_ID));
verify(projectCacheMock).remove(PROJECT_KEY);
}
@@ -72,7 +73,7 @@
.onCreateProject(PROJECT_KEY);
assertThat(Context.isForwardedEvent()).isFalse();
- handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false));
+ handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false, INSTANCE_ID));
assertThat(Context.isForwardedEvent()).isFalse();
verify(projectCacheMock).onCreateProject(PROJECT_KEY);
@@ -92,7 +93,7 @@
.remove(PROJECT_KEY);
assertThat(Context.isForwardedEvent()).isFalse();
- handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true));
+ handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true, INSTANCE_ID));
assertThat(Context.isForwardedEvent()).isFalse();
verify(projectCacheMock).remove(PROJECT_KEY);
@@ -113,7 +114,7 @@
RuntimeException thrown =
assertThrows(
RuntimeException.class,
- () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false)));
+ () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false, INSTANCE_ID)));
assertThat(thrown).hasMessageThat().isEqualTo(SOME_MESSAGE);
assertThat(Context.isForwardedEvent()).isFalse();
@@ -135,7 +136,7 @@
RuntimeException thrown =
assertThrows(
RuntimeException.class,
- () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true)));
+ () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true, INSTANCE_ID)));
assertThat(thrown).hasMessageThat().isEqualTo(SOME_MESSAGE);
assertThat(Context.isForwardedEvent()).isFalse();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
index 6403cce..09f8f59 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
@@ -101,7 +101,7 @@
}
private Optional<GroupIndexEvent> groupIndexEvent(String uuid, @Nullable ObjectId sha1) {
- return Optional.of(new GroupIndexEvent(uuid, sha1));
+ return Optional.of(new GroupIndexEvent(uuid, sha1, "instance-id"));
}
private void setCommitExistsInRepo(boolean commitExists) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupEventIndexTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupEventIndexTest.java
index 93cec05..099f1dd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupEventIndexTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupEventIndexTest.java
@@ -16,7 +16,7 @@
import static com.google.common.truth.Truth.assertThat;
-import com.gerritforge.gerrit.eventbroker.EventGsonProvider;
+import com.google.gerrit.server.events.EventGsonProvider;
import com.google.gson.Gson;
import com.googlesource.gerrit.plugins.multisite.forwarder.events.GroupIndexEvent;
import java.util.UUID;
@@ -24,13 +24,14 @@
import org.junit.Test;
public class GroupEventIndexTest {
+ private static final String INSTANCE_ID = "instance-id";
private static final Gson gson = new EventGsonProvider().get();
@Test
public void groupEventIndexRoundTripWithSha1() {
String aGroupUUID = UUID.randomUUID().toString();
ObjectId anObjectId = ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
- GroupIndexEvent original = new GroupIndexEvent(aGroupUUID, anObjectId);
+ GroupIndexEvent original = new GroupIndexEvent(aGroupUUID, anObjectId, INSTANCE_ID);
assertThat(gson.fromJson(gson.toJson(original), GroupIndexEvent.class)).isEqualTo(original);
}
@@ -38,7 +39,7 @@
@Test
public void groupEventIndexRoundTripWithoutSha1() {
String aGroupUUID = UUID.randomUUID().toString();
- GroupIndexEvent original = new GroupIndexEvent(aGroupUUID, null);
+ GroupIndexEvent original = new GroupIndexEvent(aGroupUUID, null, INSTANCE_ID);
assertThat(gson.fromJson(gson.toJson(original), GroupIndexEvent.class)).isEqualTo(original);
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandlerTest.java
index 660a302..3fd13c6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/IndexEventHandlerTest.java
@@ -36,6 +36,8 @@
@RunWith(MockitoJUnitRunner.class)
public class IndexEventHandlerTest {
+ private static final String INSTANCE_ID = "instance-id";
+
private IndexEventHandler eventHandler;
@Mock private ProjectsFilter projectsFilter;
@@ -50,7 +52,8 @@
asDynamicSet(forwarder),
changeChecker,
projectsFilter,
- new TestGroupChecker(true));
+ new TestGroupChecker(true),
+ INSTANCE_ID);
}
private DynamicSet<IndexEventForwarder> asDynamicSet(IndexEventForwarder forwarder) {
@@ -65,7 +68,7 @@
eventHandler.onProjectIndexed("test_project");
verify(forwarder, never())
- .index(any(IndexProjectTask.class), eq(new ProjectIndexEvent("test_project")));
+ .index(any(IndexProjectTask.class), eq(new ProjectIndexEvent("test_project", INSTANCE_ID)));
}
@Test