Merge branch 'stable-3.1' into stable-3.2 * stable-3.1: Bump Bazel version to 3.4.1 e2e-tests: Replace hardcoded scheme with property Change-Id: I019c67cec9bbfcfcf88086326f61b19e11cfbdf1
diff --git a/BUILD b/BUILD index c3f5a11..3b896ff 100644 --- a/BUILD +++ b/BUILD
@@ -25,6 +25,7 @@ junit_tests( name = "high-availability_tests", srcs = glob(["src/test/java/**/*.java"]), + javacopts = ["-Xep:DoNotMock:OFF"], resources = glob(["src/test/resources/**/*"]), tags = [ "high-availability",
diff --git a/WORKSPACE b/WORKSPACE index 8191aab..b66c67f 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "b6cb89690a5e06261932eb30c95fd8db34a7943a", + commit = "74f9d8e76d5014d218ae6fe55127a5288c9a32c3", #local_path = "/home/<user>/projects/bazlets", )
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/autoreindex/IndexTs.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/autoreindex/IndexTs.java index 6255986..ff42a4e 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/autoreindex/IndexTs.java +++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/autoreindex/IndexTs.java
@@ -113,12 +113,12 @@ currCtx.onlyWithContext( (ctx) -> { try { - ChangeNotes changeNotes = changeFinder.findOne(projectName + "~" + id); + Optional<ChangeNotes> changeNotes = changeFinder.findOne(projectName + "~" + id); update( IndexName.CHANGE, - changeNotes == null + !changeNotes.isPresent() ? LocalDateTime.now() - : changeNotes.getChange().getLastUpdatedOn().toLocalDateTime()); + : changeNotes.get().getChange().getLastUpdatedOn().toLocalDateTime()); } catch (Exception e) { log.atWarning().withCause(e).log("Unable to update the latest TS for change %d", id); }
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBroker.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBroker.java index f156da4..700d5e1 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBroker.java +++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBroker.java
@@ -14,6 +14,7 @@ package com.ericsson.gerrit.plugins.highavailability.forwarder; +import com.google.gerrit.server.config.GerritInstanceId; import com.google.gerrit.server.events.Event; import com.google.gerrit.server.events.EventBroker; import com.google.gerrit.server.events.EventListener; @@ -23,6 +24,7 @@ import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.project.ProjectCache; import com.google.inject.Inject; +import javax.annotation.Nullable; class ForwardedAwareEventBroker extends EventBroker { @@ -32,8 +34,15 @@ PluginSetContext<EventListener> unrestrictedListeners, PermissionBackend permissionBackend, ProjectCache projectCache, - Factory notesFactory) { - super(listeners, unrestrictedListeners, permissionBackend, projectCache, notesFactory); + Factory notesFactory, + @Nullable @GerritInstanceId String gerritInstanceId) { + super( + listeners, + unrestrictedListeners, + permissionBackend, + projectCache, + notesFactory, + gerritInstanceId); } @Override
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/index/ChangeCheckerImpl.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/index/ChangeCheckerImpl.java index 4a0cad7..fe04ee9 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/index/ChangeCheckerImpl.java +++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/index/ChangeCheckerImpl.java
@@ -76,7 +76,7 @@ @Override public Optional<ChangeNotes> getChangeNotes() { try (ManualRequestContext ctx = oneOffReqCtx.open()) { - changeNotes = Optional.ofNullable(changeFinder.findOne(changeId)); + changeNotes = changeFinder.findOne(changeId); return changeNotes; } }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index b2715bb..377626d 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md
@@ -3,8 +3,8 @@ ========================= The @PLUGIN@ plugin must be installed on all the instances. Each instance should -be configured with the same [gerrit.serverId](https://gerrit-documentation.storage.googleapis.com/Documentation/3.1.0/config-gerrit.html#gerrit.serverId). -If there are existing changes in [NoteDb](https://gerrit-documentation.storage.googleapis.com/Documentation/3.1.0/note-db.html) +be configured with the same [gerrit.serverId](https://gerrit-documentation.storage.googleapis.com/Documentation/3.2.0/config-gerrit.html#gerrit.serverId). +If there are existing changes in [NoteDb](https://gerrit-documentation.storage.googleapis.com/Documentation/3.2.0/note-db.html) made with another `serverId`, then this plugin might not be able to access them. Likewise, if the HA gerrit.serverIds differ, then changes conveyed by one instance will not be accessible by the other.
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/CacheEvictionIT.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/CacheEvictionIT.java index e91e2ae..8918c65 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/CacheEvictionIT.java +++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/CacheEvictionIT.java
@@ -26,8 +26,8 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule; import com.google.common.cache.LoadingCache; -import com.google.gerrit.acceptance.GerritConfig; -import com.google.gerrit.acceptance.GlobalPluginConfig; +import com.google.gerrit.acceptance.config.GerritConfig; +import com.google.gerrit.acceptance.config.GlobalPluginConfig; import com.google.gerrit.acceptance.LightweightPluginDaemonTest; import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.TestPlugin;
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/ProjectListIT.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/ProjectListIT.java index 22ef89e..dd51ba4 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/ProjectListIT.java +++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/cache/ProjectListIT.java
@@ -25,7 +25,7 @@ import static com.google.common.truth.Truth.assertThat; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.gerrit.acceptance.GlobalPluginConfig; +import com.google.gerrit.acceptance.config.GlobalPluginConfig; import com.google.gerrit.acceptance.LightweightPluginDaemonTest; import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.TestPlugin;
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java index 36cc953..ec5b1de 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedAwareEventBrokerTest.java
@@ -39,7 +39,7 @@ DynamicSet<EventListener> set = DynamicSet.emptySet(); set.add("high-availability", listenerMock); PluginSetContext<EventListener> listeners = new PluginSetContext<>(set, mockMetrics); - broker = new ForwardedAwareEventBroker(null, listeners, null, null, null); + broker = new ForwardedAwareEventBroker(null, listeners, null, null, null, null); } @Test
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java index af4637e..bd4dfd1 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java +++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java
@@ -26,7 +26,7 @@ import static com.google.common.truth.Truth.assertThat; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.gerrit.acceptance.GlobalPluginConfig; +import com.google.gerrit.acceptance.config.GlobalPluginConfig; import com.google.gerrit.acceptance.LightweightPluginDaemonTest; import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.TestPlugin;