mirror of https://github.com/apache/lucene.git
SOLR-10628: Fix test failures due to global log level change
This commit is contained in:
parent
b4c6bfafdb
commit
c4a1bd52e9
|
@ -112,4 +112,18 @@ public final class StartupLoggingUtils {
|
||||||
log.warn("{} Dynamic log manipulation currently only supported for Log4j. "
|
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);
|
+ "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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ import org.apache.solr.util.RandomizeSSL.SSLRandomizer;
|
||||||
import org.apache.solr.util.RefCounted;
|
import org.apache.solr.util.RefCounted;
|
||||||
import org.apache.solr.util.RevertDefaultThreadHandlerRule;
|
import org.apache.solr.util.RevertDefaultThreadHandlerRule;
|
||||||
import org.apache.solr.util.SSLTestConfig;
|
import org.apache.solr.util.SSLTestConfig;
|
||||||
|
import org.apache.solr.util.StartupLoggingUtils;
|
||||||
import org.apache.solr.util.TestHarness;
|
import org.apache.solr.util.TestHarness;
|
||||||
import org.apache.solr.util.TestInjection;
|
import org.apache.solr.util.TestInjection;
|
||||||
import org.apache.zookeeper.KeeperException;
|
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
|
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 {
|
protected void writeCoreProperties(Path coreDirectory, String corename) throws IOException {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("name", corename);
|
props.setProperty("name", corename);
|
||||||
|
@ -251,7 +254,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupTestCases() {
|
public static void setupTestCases() {
|
||||||
|
initialRootLogLevel = StartupLoggingUtils.getLogLevelString();
|
||||||
initClassLogLevels();
|
initClassLogLevels();
|
||||||
|
|
||||||
initCoreDataDir = createTempDir("init-core-data").toFile();
|
initCoreDataDir = createTempDir("init-core-data").toFile();
|
||||||
|
@ -321,6 +324,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
|
|
||||||
LogLevel.Configurer.restoreLogLevels(savedClassLogLevels);
|
LogLevel.Configurer.restoreLogLevels(savedClassLogLevels);
|
||||||
savedClassLogLevels.clear();
|
savedClassLogLevels.clear();
|
||||||
|
StartupLoggingUtils.changeLogLevel(initialRootLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue