Skip to content

Commit

Permalink
In unit tests do not log the creation of indexes anymore
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Daniel Schwarz authored and bartfastiel committed Oct 19, 2017
1 parent 1cadfd7 commit 90feaa7
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
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;
Expand Down Expand Up @@ -160,7 +163,19 @@ public void before() throws Throwable {
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();
}
Expand Down

0 comments on commit 90feaa7

Please sign in to comment.