lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject [22/50] lucene-solr:feature/autoscaling_72: SOLR-10628: Fix test failures due to global log level change
Date Sat, 02 Sep 2017 15:44:15 GMT
SOLR-10628: Fix test failures due to global log level change


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c4a1bd52
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c4a1bd52
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c4a1bd52

Branch: refs/heads/feature/autoscaling_72
Commit: c4a1bd52e9b9bf47da1b621023590e0d012f43b7
Parents: b4c6bfa
Author: Jan Høydahl <janhoy@apache.org>
Authored: Wed Aug 30 15:43:30 2017 +0200
Committer: Jan Høydahl <janhoy@apache.org>
Committed: Wed Aug 30 19:58:35 2017 +0200

----------------------------------------------------------------------
 .../org/apache/solr/util/StartupLoggingUtils.java     | 14 ++++++++++++++
 .../src/java/org/apache/solr/SolrTestCaseJ4.java      |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c4a1bd52/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
index 4db6a42..c582eff 100644
--- a/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java
@@ -112,4 +112,18 @@ public final class StartupLoggingUtils {
     log.warn("{} Dynamic log manipulation currently only supported for Log4j. "
         + "Please consult your logging framework of choice on how to configure the appropriate
logging.", msg);
   }
+
+  /**
+   * Return a string representing the current static ROOT logging level
+   * @return a string TRACE, DEBUG, WARN, ERROR or INFO representing current log level. Default
is INFO
+   */
+  public static String getLogLevelString() {
+    final Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+    if (rootLogger.isTraceEnabled()) return "TRACE";
+    else if (rootLogger.isDebugEnabled()) return "DEBUG";
+    else if (rootLogger.isInfoEnabled()) return "INFO";
+    else if (rootLogger.isWarnEnabled()) return "WARN";
+    else if (rootLogger.isErrorEnabled()) return "ERROR";
+    else return "INFO";
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c4a1bd52/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 2f2f9cc..c35004e 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -122,6 +122,7 @@ import org.apache.solr.util.RandomizeSSL.SSLRandomizer;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.RevertDefaultThreadHandlerRule;
 import org.apache.solr.util.SSLTestConfig;
+import org.apache.solr.util.StartupLoggingUtils;
 import org.apache.solr.util.TestHarness;
 import org.apache.solr.util.TestInjection;
 import org.apache.zookeeper.KeeperException;
@@ -180,6 +181,8 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
 
   public static int DEFAULT_CONNECTION_TIMEOUT = 60000;  // default socket connection timeout
in ms
   
+  private static String initialRootLogLevel;
+
   protected void writeCoreProperties(Path coreDirectory, String corename) throws IOException
{
     Properties props = new Properties();
     props.setProperty("name", corename);
@@ -251,7 +254,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
 
   @BeforeClass
   public static void setupTestCases() {
-
+    initialRootLogLevel = StartupLoggingUtils.getLogLevelString();
     initClassLogLevels();
 
     initCoreDataDir = createTempDir("init-core-data").toFile();
@@ -321,6 +324,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
 
     LogLevel.Configurer.restoreLogLevels(savedClassLogLevels);
     savedClassLogLevels.clear();
+    StartupLoggingUtils.changeLogLevel(initialRootLogLevel);
   }
   
   /**


Mime
View raw message