Merge branch 'stable-3.1'

* stable-3.1:
  Update git submodules
  Update download-commands plugin to latest master revision
  Bazel: Bump java docs api to 11
  Set Elastic/Lucene test deps log to WARN log level
  Open relative commentlinks in same tab
  VersionedMetaData: Emit debug log after update has been committed
  VersionedMetaData: Trim message sent to log
  Update git submodules
  ChangeIdHandler: Make assumption on number of query results explicit
  ChangeIdHandler: Remove unnecessary 'final' modifiers
  Update git submodules
  AbstractQueryChangesTest: Add method to create change as private
  AbstractQueryChangesTest: Fix comment in byPrivate
  AbstractQueryChangesTest: Use overloaded newChange method where possible
  AbstractQueryChangesTest: Extend testing of visibleto predicate
  ChangeQueryBuilder: Rename status_open to statusOpen
  ChangeQueryBuilder: Rename is_visible to isVisible
  ChangeNotificationsIT: Fix eclipse warning(s) about static use
  Extract duplicated code of {Ssh|Http}LogJsonLayout
  Add option to log SSH events in JSON format
  Remove duplicated constants storing key names of Ssh logs
  Add option to log HTTP logging events in JSON format
  CacheMetrics: Make F_NAME a final constant in class scope
  Fix more cases where Collection.isEmpty() should be used
  Use Set instead of EnumSet in method signatures
  Replace negation of anyMatch() with noneMatch()
  AllExternalIds: Replace lambdas with method references
  PostReview: Replace filter and findFirst with anyMatch
  XContentBuilder: Use UTF_8 from Java's StandardCharsets rather than Guava
  Update git submodules
  Update git submodules
  Update git submodules
  Fail gracefully when a change has an invalid server id
  QueryDocumentationExecutor: Make WEIGHTS final and use ImmutableMap
  BooleanProjectConfigTransformations: Make MAPPER final
  TestSubmitRuleInfo: Make INSTANCE final
  TrackingFootersProvider: Make constants final
  ChangeCleanupConfig: Make constants final
  SetParent: Simplify lambda expression
  ProjectsConsistencyChecker: Simplify lambda expression
  Remove redundant null checks used with "instanceof"
  Remove unnecessary array creation for varargs parameters
  Remove redundant parentheses in lambda statements
  PreferencesBox: Remove unnecessary boxing to Boolean
  GitwebServlet: Rename bufferSize to BUFFER_SIZE and make static
  GetPatch: Make FILE_NOT_FOUND static
  DeleteZombieCommentsRefs: Make constants static
  AbstractNotificationTest: Make constants static and rename
  TabFile: Make TRIM final
  Remove redundant calls to toString()
  OpenIdServiceImpl: Fix incorrect null comparison of Optional
  Consistently use isEmpty to check for empty collection
  PageLinks: Reuse ADMIN_PROJECTS constant
  PageLinks: Fix typo in method name
  FlushCaches: Use isEmpty to check for empty list
  JGitMetricModule: Replace anonymous Supplier instances with method references
  Adapt to deprecation of WindowCacheStats methods in JGit
  Documentation: Fix collapsed words and broken link
  Use Flogger instead of System.out.println in DeleteZombieCommentsRefs
  Fix a dependency injection runtime error in DeleteZombieDrafts pgm
  Update git submodules
  Upgrade JGit to v5.6.1.202002131546-r
  Bazel: Move runtime dependencies only from deps to runtime_deps
  Update rename project documentation in project owner guide
  Fix issues with caching edited commit message
  Use internal navigation instead of hard reload
  Fix width of commit message to fit 72 chars
  Add "edit" button to diff view
  Show files with comments in diff-view file list
  Fix missing file name in diff view when file has no change but comments
  Remove egit plugin from project owner guide Documentation
  Error Prone: Enable and fix OperatorPrecedence
  Bazel: Remove superfluous dependencies flagged by unused_deps
  Remove Nullable annotation from ProjectIT.getRemoteHead method
  GerritBaseTests: Activate test logging
  Revert "Enable optional DEBUG level logs for query tests"
  Allow to control the Gerrit log level for running tests from system var
  Revert "Acceptance: set log threshold level for tests"
  Reduce log level for tests to INFO
  Bazel: Update time attribute of file entries in plugin artifact
  Add Jetty connection metrics
  Add additional JGit WindowCache metrics
  Update JGit to 5.1.13.202002110435-r
  BucketedCallback: fix prune() to remove unset sub-metrics from registry
  Modify draft ref updates commits to point to an empty parent
  Upgrade gitiles-servlet and blame-cache to 0.2-12
  Upgrade JGit to 5.3.7.202002110540-r

Change-Id: I22730db348c53060f75c6954637bbed4ce83f147
This commit is contained in:
Marco Miller
2020-02-22 17:11:15 -05:00
91 changed files with 1094 additions and 500 deletions

View File

@@ -319,6 +319,9 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
}
protected class StagedUsers {
public static final String REVIEWER_BY_EMAIL = "reviewerByEmail@example.com";
public static final String CC_BY_EMAIL = "ccByEmail@example.com";
public final TestAccount owner;
public final TestAccount author;
public final TestAccount uploader;
@@ -327,8 +330,6 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
public final TestAccount starrer;
public final TestAccount assignee;
public final TestAccount watchingProjectOwner;
public final String reviewerByEmail = "reviewerByEmail@example.com";
public final String ccerByEmail = "ccByEmail@example.com";
private final Map<NotifyType, TestAccount> watchers = new HashMap<>();
private final Map<String, TestAccount> accountsByEmail = new HashMap<>();
@@ -429,9 +430,9 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
ReviewInput in =
ReviewInput.noScore()
.reviewer(reviewer.email())
.reviewer(reviewerByEmail)
.reviewer(REVIEWER_BY_EMAIL)
.reviewer(ccer.email(), ReviewerState.CC, false)
.reviewer(ccerByEmail, ReviewerState.CC, false);
.reviewer(CC_BY_EMAIL, ReviewerState.CC, false);
ReviewResult result = gApi.changes().id(r.getChangeId()).current().review(in);
supportReviewersByEmail = true;
if (result.reviewers.values().stream().anyMatch(v -> v.error != null)) {

View File

@@ -48,8 +48,6 @@ DEPLOY_ENV = [
"//lib/guice:guice-servlet",
"//lib/mail",
"//lib/mina:sshd",
"//lib/log:impl-log4j",
"//lib/log:log4j",
"//lib:guava",
"//lib/bouncycastle:bcpg",
"//lib/bouncycastle:bcprov",

View File

@@ -18,13 +18,11 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.util.Objects.requireNonNull;
import static org.apache.log4j.Logger.getLogger;
import com.google.auto.value.AutoValue;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gerrit.acceptance.config.ConfigAnnotationParser;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.acceptance.config.GerritConfigs;
@@ -55,6 +53,7 @@ import com.google.gerrit.server.util.SystemLog;
import com.google.gerrit.testing.FakeEmailSender;
import com.google.gerrit.testing.InMemoryRepositoryManager;
import com.google.gerrit.testing.SshMode;
import com.google.gerrit.testing.TestLoggingActivator;
import com.google.inject.AbstractModule;
import com.google.inject.BindingAnnotation;
import com.google.inject.Injector;
@@ -80,11 +79,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.RepositoryCache;
import org.eclipse.jgit.util.FS;
@@ -122,8 +116,7 @@ public class GerritServer implements AutoCloseable {
null, // @GerritConfig is only valid on methods.
null, // @GerritConfigs is only valid on methods.
null, // @GlobalPluginConfig is only valid on methods.
null, // @GlobalPluginConfigs is only valid on methods.
getLogLevelThresholdAnnotation(testDesc));
null); // @GlobalPluginConfigs is only valid on methods.
}
public static Description forTestMethod(
@@ -159,8 +152,7 @@ public class GerritServer implements AutoCloseable {
testDesc.getAnnotation(GerritConfig.class),
testDesc.getAnnotation(GerritConfigs.class),
testDesc.getAnnotation(GlobalPluginConfig.class),
testDesc.getAnnotation(GlobalPluginConfigs.class),
getLogLevelThresholdAnnotation(testDesc));
testDesc.getAnnotation(GlobalPluginConfigs.class));
}
private static boolean has(Class<? extends Annotation> annotation, Class<?> clazz) {
@@ -182,14 +174,6 @@ public class GerritServer implements AutoCloseable {
return null;
}
private static Level getLogLevelThresholdAnnotation(org.junit.runner.Description testDesc) {
LogThreshold logLevelThreshold = testDesc.getTestClass().getAnnotation(LogThreshold.class);
if (logLevelThreshold == null) {
return Level.DEBUG;
}
return Level.toLevel(logLevelThreshold.level());
}
abstract org.junit.runner.Description testDescription();
@Nullable
@@ -229,8 +213,6 @@ public class GerritServer implements AutoCloseable {
@Nullable
abstract GlobalPluginConfigs pluginConfigs();
abstract Level logLevelThreshold();
private void checkValidAnnotations() {
if (useClockStep() != null && useSystemTime()) {
throw new IllegalStateException("Use either @UseClockStep or @UseSystemTime, not both");
@@ -267,54 +249,6 @@ public class GerritServer implements AutoCloseable {
}
}
private static final ImmutableMap<String, Level> LOG_LEVELS =
ImmutableMap.<String, Level>builder()
.put("com.google.gerrit", getGerritLogLevel())
// Silence non-critical messages from MINA SSHD.
.put("org.apache.mina", Level.WARN)
.put("org.apache.sshd.common", Level.WARN)
.put("org.apache.sshd.server", Level.WARN)
.put("org.apache.sshd.common.keyprovider.FileKeyPairProvider", Level.INFO)
.put("com.google.gerrit.sshd.GerritServerSession", Level.WARN)
// Silence non-critical messages from mime-util.
.put("eu.medsea.mimeutil", Level.WARN)
// Silence non-critical messages from openid4java.
.put("org.apache.xml", Level.WARN)
.put("org.openid4java", Level.WARN)
.put("org.openid4java.consumer.ConsumerManager", Level.FATAL)
.put("org.openid4java.discovery.Discovery", Level.ERROR)
.put("org.openid4java.server.RealmVerifier", Level.ERROR)
.put("org.openid4java.message.AuthSuccess", Level.ERROR)
// Silence non-critical messages from c3p0 (if used).
.put("com.mchange.v2.c3p0", Level.WARN)
.put("com.mchange.v2.resourcepool", Level.WARN)
.put("com.mchange.v2.sql", Level.WARN)
// Silence non-critical messages from apache.http.
.put("org.apache.http", Level.WARN)
// Silence non-critical messages from Jetty.
.put("org.eclipse.jetty", Level.WARN)
// Silence non-critical messages from JGit.
.put("org.eclipse.jgit.transport.PacketLineIn", Level.WARN)
.put("org.eclipse.jgit.transport.PacketLineOut", Level.WARN)
.put("org.eclipse.jgit.internal.storage.file.FileSnapshot", Level.WARN)
.put("org.eclipse.jgit.util.FS", Level.WARN)
.build();
private static Level getGerritLogLevel() {
String value = Strings.nullToEmpty(System.getenv("GERRIT_LOG_LEVEL"));
if (value.isEmpty()) {
value = Strings.nullToEmpty(System.getProperty("gerrit.logLevel"));
}
return Level.toLevel(value, Level.INFO);
}
private static boolean forceLocalDisk() {
String value = Strings.nullToEmpty(System.getenv("GERRIT_FORCE_LOCAL_DISK"));
if (value.isEmpty()) {
@@ -430,7 +364,7 @@ public class GerritServer implements AutoCloseable {
throws Exception {
checkArgument(site != null, "site is required (even for in-memory server");
desc.checkValidAnnotations();
configureLogging(desc.logLevelThreshold());
TestLoggingActivator.configureLogging();
CyclicBarrier serverStarted = new CyclicBarrier(2);
Daemon daemon =
new Daemon(
@@ -531,25 +465,6 @@ public class GerritServer implements AutoCloseable {
return new GerritServer(desc, site, createTestInjector(daemon), daemon, daemonService);
}
private static void configureLogging(Level threshold) {
LogManager.resetConfiguration();
PatternLayout layout = new PatternLayout();
layout.setConversionPattern("%-5p %c %x: %m%n");
ConsoleAppender dst = new ConsoleAppender();
dst.setLayout(layout);
dst.setTarget("System.err");
dst.setThreshold(threshold);
dst.activateOptions();
Logger root = LogManager.getRootLogger();
root.removeAllAppenders();
root.addAppender(dst);
LOG_LEVELS.entrySet().stream().forEach(e -> getLogger(e.getKey()).setLevel(e.getValue()));
}
private static void mergeTestConfig(Config cfg) {
String forceEphemeralPort = String.format("%s:0", getLocalHost().getHostName());
String url = "http://" + forceEphemeralPort + "/";

View File

@@ -1,29 +0,0 @@
// Copyright (C) 2019 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;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Target({TYPE, METHOD})
@Retention(RUNTIME)
@Inherited
public @interface LogThreshold {
String level() default "DEBUG";
}