Merge branch 'stable-3.2'

* stable-3.2:
  Add metric monitoring Java deadlocks
  Fix wrong status returned when auth backend couldn't be reached
  Add debug logs for copying approvals to new patch sets
  Revert "ApprovalCopier: Add debug logging of logic in canCopy"
  Update replication plugin to latest master revision
  ChangeKindCacheImpl: Add debug logging of detected change kind
  ApprovalCopier: Add debug logging of logic in canCopy
  Documentation: Fix plugins install REST API & curl example
  Fix minor typo in WORKSPACE
  Update webhooks plugin to latest master revision
  Fix `parent` in `gr-change-metadata` when switching patchsets
  Set version to 3.2.0-SNAPSHOT
  Set version to 3.2.0-rc3
  Update git submodules
  Update git submodules
  Revert "Fix edit diff url"
  Fix textarea styling for firefox
  Upgrade testcontainers to 1.14.2
  Update git submodules
  Propagate instanceId in Events
  Use UUID rather than group_id for links in gr-admin-group-list
  Verify that instanceId is accessible from plugins
  Add InstanceId configuration in gerrit.config
  Fix Postgresql JDBC driver leaking memory

Change-Id: Ide18136b3b0a0b1dccc078f2cf2236332400c8ff
This commit is contained in:
David Pursehouse
2020-05-21 15:29:09 +09:00
25 changed files with 458 additions and 18 deletions

View File

@@ -0,0 +1,34 @@
// Copyright (C) 2020 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.google.gerrit.acceptance.config;
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import org.junit.Test;
public class GerritInstanceIdIT extends AbstractDaemonTest {
@Test
@GerritConfig(name = "gerrit.instanceId", value = "testInstanceId")
public void shouldReturnInstanceIdWhenDefined() {
assertThat(instanceId).isEqualTo("testInstanceId");
}
@Test
public void shouldReturnNullWhenNotDefined() {
assertThat(instanceId).isNull();
}
}

View File

@@ -0,0 +1,64 @@
// Copyright (C) 2020 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.google.gerrit.acceptance.config;
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.TestPlugin;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.server.config.GerritInstanceId;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Scopes;
import org.junit.Test;
@TestPlugin(
name = "instance-id-from-plugin",
sysModule = "com.google.gerrit.acceptance.config.InstanceIdFromPluginIT$Module")
public class InstanceIdFromPluginIT extends LightweightPluginDaemonTest {
public static class Module extends AbstractModule {
@Override
protected void configure() {
bind(InstanceIdLoader.class).in(Scopes.SINGLETON);
}
}
public static class InstanceIdLoader {
public final String gerritInstanceId;
@Inject
InstanceIdLoader(@Nullable @GerritInstanceId String gerritInstanceId) {
this.gerritInstanceId = gerritInstanceId;
}
}
@Test
@GerritConfig(name = "gerrit.instanceId", value = "testInstanceId")
public void shouldReturnInstanceIdWhenDefined() {
assertThat(getInstanceIdLoader().gerritInstanceId).isEqualTo("testInstanceId");
}
@Test
public void shouldReturnNullWhenNotDefined() {
assertThat(getInstanceIdLoader().gerritInstanceId).isNull();
}
private InstanceIdLoader getInstanceIdLoader() {
return plugin.getSysInjector().getInstance(InstanceIdLoader.class);
}
}

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2020 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.google.gerrit.acceptance.server.event;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.events.EventDispatcher;
import com.google.gerrit.server.events.EventTypes;
import com.google.inject.Inject;
import org.junit.Before;
import org.junit.Test;
@NoHttpd
public class InstanceIdInEventIT extends AbstractDaemonTest {
public static class TestDispatcher {
private final DynamicItem<EventDispatcher> eventDispatcher;
@Inject
TestDispatcher(DynamicItem<EventDispatcher> eventDispatcher) {
this.eventDispatcher = eventDispatcher;
}
public void postEvent(TestEvent event) {
try {
eventDispatcher.get().postEvent(event);
} catch (Exception e) {
fail("Exception raised when posting Event " + e.getCause());
}
}
}
public static class TestEvent extends Event {
private static final String TYPE = "test-event-instance-id";
public TestEvent() {
super(TYPE);
}
}
@Inject private DynamicItem<EventDispatcher> eventDispatcher;
TestDispatcher testDispatcher;
@Before
public void setUp() throws Exception {
testDispatcher = new TestDispatcher(eventDispatcher);
EventTypes.register(TestEvent.TYPE, TestEvent.class);
}
@Test
@GerritConfig(name = "gerrit.instanceId", value = "testInstanceId")
public void shouldSetInstanceIdWhenDefined() {
testDispatcher.postEvent(new TestEvent());
ImmutableList<Event> events = eventRecorder.getGenericEvents(TestEvent.TYPE, 1);
assertThat(events.get(0).instanceId).isEqualTo("testInstanceId");
}
@Test
public void shouldNotSetInstanceIdWhenNotDefined() {
testDispatcher.postEvent(new TestEvent());
ImmutableList<Event> events = eventRecorder.getGenericEvents(TestEvent.TYPE, 1);
assertThat(events.get(0).instanceId).isNull();
}
}