Revert "Acceptance: set log threshold level for tests"
This reverts commit a73d761b8a
.
Reason for revert: log level for tests was reduced to INFO per default
in I6b13ee50459.
Moreover, the search in: [1], reveals that there is no usages of this
annotation in gerrit core and plugins.
[1] https://cs.bazel.build/search?q=r%3Agerrit+LogThreshold
Change-Id: Ic3b1d7bb06bd5a49870ec2ff44982cdced150091
This commit is contained in:
@@ -103,8 +103,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(
|
||||
@@ -124,8 +123,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) {
|
||||
@@ -137,14 +135,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
|
||||
@@ -174,8 +164,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");
|
||||
@@ -364,7 +352,7 @@ public class GerritServer implements AutoCloseable {
|
||||
throws Exception {
|
||||
checkArgument(site != null, "site is required (even for in-memory server");
|
||||
desc.checkValidAnnotations();
|
||||
configureLogging(desc.logLevelThreshold());
|
||||
configureLogging();
|
||||
CyclicBarrier serverStarted = new CyclicBarrier(2);
|
||||
Daemon daemon =
|
||||
new Daemon(
|
||||
@@ -469,7 +457,7 @@ public class GerritServer implements AutoCloseable {
|
||||
return new GerritServer(desc, site, createTestInjector(daemon), daemon, daemonService);
|
||||
}
|
||||
|
||||
private static void configureLogging(Level threshold) {
|
||||
private static void configureLogging() {
|
||||
LogManager.resetConfiguration();
|
||||
|
||||
PatternLayout layout = new PatternLayout();
|
||||
@@ -478,7 +466,7 @@ public class GerritServer implements AutoCloseable {
|
||||
ConsoleAppender dst = new ConsoleAppender();
|
||||
dst.setLayout(layout);
|
||||
dst.setTarget("System.err");
|
||||
dst.setThreshold(threshold);
|
||||
dst.setThreshold(Level.DEBUG);
|
||||
dst.activateOptions();
|
||||
|
||||
Logger root = LogManager.getRootLogger();
|
||||
|
@@ -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