]> source.dussan.org Git - sonarqube.git/commitdiff
In unit tests do not log the creation of indexes anymore
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Tue, 17 Oct 2017 13:45:31 +0000 (15:45 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Thu, 19 Oct 2017 10:14:52 +0000 (12:14 +0200)
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.

server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java

index ce735982ac1aed8bd416628cd88625c54f3c9392..170abcefe6c02f325a393435aa7adc2825c11a38 100644 (file)
@@ -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();
     }