From 47f9ac4be3a89ca56df29b933a519cf7553622d2 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sun, 16 Feb 2020 08:45:20 +0100 Subject: [PATCH] Revert "Acceptance: set log threshold level for tests" This reverts commit a73d761b8a6cbf1626e7daf83214ea94b5e18960. 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 --- .../gerrit/acceptance/GerritServer.java | 22 ++++---------- .../gerrit/acceptance/LogThreshold.java | 29 ------------------- 2 files changed, 5 insertions(+), 46 deletions(-) delete mode 100644 java/com/google/gerrit/acceptance/LogThreshold.java diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java index 8c6b5a33a9..9a8320b856 100644 --- a/java/com/google/gerrit/acceptance/GerritServer.java +++ b/java/com/google/gerrit/acceptance/GerritServer.java @@ -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 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(); diff --git a/java/com/google/gerrit/acceptance/LogThreshold.java b/java/com/google/gerrit/acceptance/LogThreshold.java deleted file mode 100644 index 36831f3f1a..0000000000 --- a/java/com/google/gerrit/acceptance/LogThreshold.java +++ /dev/null @@ -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"; -}