Shutdown logging in logging configuration tests
The logging configuration tests write to log files which are deleted at the end of the test. If these files are not closed, some operating systems will complain when these deletes are performed. This commit ensures that the logging system is properly shutdown so that these files can be properly deleted.
This commit is contained in:
parent
12141d5f9d
commit
b8396cd2d6
|
@ -43,7 +43,7 @@ import static org.elasticsearch.common.util.CollectionUtils.asArrayList;
|
||||||
*/
|
*/
|
||||||
public class Loggers {
|
public class Loggers {
|
||||||
|
|
||||||
private static final String commonPrefix = System.getProperty("es.logger.prefix", "org.elasticsearch.");
|
static final String commonPrefix = System.getProperty("es.logger.prefix", "org.elasticsearch.");
|
||||||
|
|
||||||
public static final String SPACE = " ";
|
public static final String SPACE = " ";
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,13 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
|
||||||
public class EvilLoggerConfigurationTests extends ESTestCase {
|
public class EvilLoggerConfigurationTests extends ESTestCase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
LoggerContext context = (LoggerContext) LogManager.getContext(false);
|
||||||
|
Configurator.shutdown(context);
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
public void testResolveMultipleConfigs() throws Exception {
|
public void testResolveMultipleConfigs() throws Exception {
|
||||||
final Level level = ESLoggerFactory.getLogger("test").getLevel();
|
final Level level = ESLoggerFactory.getLogger("test").getLevel();
|
||||||
try {
|
try {
|
||||||
|
@ -89,13 +96,7 @@ public class EvilLoggerConfigurationTests extends ESTestCase {
|
||||||
final Environment environment = new Environment(settings);
|
final Environment environment = new Environment(settings);
|
||||||
LogConfigurator.configure(environment, true);
|
LogConfigurator.configure(environment, true);
|
||||||
|
|
||||||
final String loggerName;
|
final String loggerName = Loggers.commonPrefix + "test";
|
||||||
if (LogManager.getContext(false).hasLogger("org.elasticsearch.test", new PrefixMessageFactory())) {
|
|
||||||
loggerName = "org.elasticsearch.test";
|
|
||||||
} else {
|
|
||||||
assertTrue(LogManager.getContext(false).hasLogger("test", new PrefixMessageFactory()));
|
|
||||||
loggerName = "test";
|
|
||||||
}
|
|
||||||
final Logger logger = ESLoggerFactory.getLogger(loggerName);
|
final Logger logger = ESLoggerFactory.getLogger(loggerName);
|
||||||
assertThat(logger.getLevel().toString(), equalTo(level));
|
assertThat(logger.getLevel().toString(), equalTo(level));
|
||||||
}
|
}
|
||||||
|
@ -112,13 +113,7 @@ public class EvilLoggerConfigurationTests extends ESTestCase {
|
||||||
LogConfigurator.configure(environment, true);
|
LogConfigurator.configure(environment, true);
|
||||||
|
|
||||||
// args should overwrite whatever is in the config
|
// args should overwrite whatever is in the config
|
||||||
final String loggerName;
|
final String loggerName = Loggers.commonPrefix + "test_resolve_order";
|
||||||
if (LogManager.getContext(false).hasLogger("org.elasticsearch.test_resolve_order", new PrefixMessageFactory())) {
|
|
||||||
loggerName = "org.elasticsearch.test_resolve_order";
|
|
||||||
} else {
|
|
||||||
assertTrue(LogManager.getContext(false).hasLogger("test_resolve_order", new PrefixMessageFactory()));
|
|
||||||
loggerName = "test_resolve_order";
|
|
||||||
}
|
|
||||||
final Logger logger = ESLoggerFactory.getLogger(loggerName);
|
final Logger logger = ESLoggerFactory.getLogger(loggerName);
|
||||||
assertTrue(logger.isTraceEnabled());
|
assertTrue(logger.isTraceEnabled());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue