From 90feaa753ce135b400e42e7d4419e9e8f8eb781c Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Tue, 17 Oct 2017 15:45:31 +0200 Subject: [PATCH] In unit tests do not log the creation of indexes anymore The huge number of log lines slow down our development cycles. Especially opening the travis logs is slow, if the test output is too verbose. --- .../test/java/org/sonar/server/es/EsTester.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java index ce735982ac1..170abcefe6c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java @@ -56,6 +56,9 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.test.NodeConfigurationSource; import org.junit.rules.ExternalResource; import org.sonar.api.config.internal.MapSettings; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.LoggerLevel; +import org.sonar.api.utils.log.Loggers; import org.sonar.core.config.ConfigurationProvider; import org.sonar.core.platform.ComponentContainer; import org.sonar.elasticsearch.test.EsTestCluster; @@ -160,7 +163,19 @@ public class EsTester extends ExternalResource { container.addSingleton(MetadataIndex.class); container.addSingleton(MetadataIndexDefinition.class); container.addSingleton(TestEsDbCompatibility.class); - container.startComponents(); + + Logger logger = Loggers.get(IndexCreator.class); + LoggerLevel oldLevel = logger.getLevel(); + if (oldLevel == LoggerLevel.INFO) { + logger.setLevel(LoggerLevel.WARN); + } + + try { + container.startComponents(); + } finally { + logger.setLevel(oldLevel); + } + container.stopComponents(); client().close(); } -- 2.39.5