Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: Error Prone: Enable and fix OperatorPrecedence 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 CommentsIT: Adapt to the 3.0 version of Gerrit. Change-Id: I532d092329bdd94a85cccdf2b34dd150944a6699
This commit is contained in:
@@ -89,8 +89,6 @@ java_library2(
|
||||
"//lib/httpcomponents:httpcore",
|
||||
"//lib/jetty:servlet",
|
||||
"//lib/jgit/org.eclipse.jgit.junit:junit",
|
||||
"//lib/log:impl-log4j",
|
||||
"//lib/log:log4j",
|
||||
"//lib/mockito",
|
||||
"//lib/truth",
|
||||
"//lib/truth:truth-java8-extension",
|
||||
|
||||
@@ -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.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperationsImpl;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
@@ -49,6 +47,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;
|
||||
@@ -74,11 +73,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;
|
||||
@@ -113,8 +107,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(
|
||||
@@ -136,8 +129,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) {
|
||||
@@ -149,14 +141,6 @@ public class GerritServer implements AutoCloseable {
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -188,8 +172,6 @@ public class GerritServer implements AutoCloseable {
|
||||
@Nullable
|
||||
abstract GlobalPluginConfigs pluginConfigs();
|
||||
|
||||
abstract Level logLevelThreshold();
|
||||
|
||||
private void checkValidAnnotations() {
|
||||
if (configs() != null && config() != null) {
|
||||
throw new IllegalStateException("Use either @GerritConfigs or @GerritConfig not both");
|
||||
@@ -223,46 +205,6 @@ public class GerritServer implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ImmutableMap<String, Level> LOG_LEVELS =
|
||||
ImmutableMap.<String, Level>builder()
|
||||
.put("com.google.gerrit", Level.DEBUG)
|
||||
|
||||
// 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 boolean forceLocalDisk() {
|
||||
String value = Strings.nullToEmpty(System.getenv("GERRIT_FORCE_LOCAL_DISK"));
|
||||
if (value.isEmpty()) {
|
||||
@@ -378,7 +320,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(
|
||||
@@ -482,25 +424,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 + "/";
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
Reference in New Issue
Block a user