mirror of https://github.com/apache/lucene.git
SOLR-7603: more test tweaks to protect ourselves from unexpected log levels in tests like the one introduced by SOLR-7408
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682570 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9cf98e784e
commit
405b29c886
|
@ -75,7 +75,12 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
public void testConcurrentCreateAndDeleteOverTheSameConfig() {
|
||||
Logger.getLogger("org.apache.solr").setLevel(Level.WARN);
|
||||
// TODO: no idea what this test needs to override the level, but regardless of reason it should
|
||||
// reset when it's done.
|
||||
final Logger logger = Logger.getLogger("org.apache.solr");
|
||||
final Level SAVED_LEVEL = logger.getLevel();
|
||||
try {
|
||||
logger.setLevel(Level.WARN);
|
||||
final String configName = "testconfig";
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
uploadConfig(configDir, configName); // upload config once, to be used by all collections
|
||||
|
@ -99,6 +104,9 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} finally {
|
||||
logger.setLevel(SAVED_LEVEL);
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadConfig(File configDir, String configName) {
|
||||
|
|
|
@ -34,12 +34,12 @@ import org.junit.BeforeClass;
|
|||
*/
|
||||
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
||||
|
||||
private static org.apache.log4j.Level SAVED_LEVEL = null; // SOLR-7603
|
||||
private static org.apache.log4j.Level SAVED_LEVEL = null; // SOLR-7603 - remove
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
// SOLR-7603
|
||||
// SOLR-7603 - remove
|
||||
SAVED_LEVEL = org.apache.log4j.LogManager.getRootLogger().getLevel();
|
||||
org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void fixLogLevelAfterClass() throws Exception { // SOLR-7603
|
||||
public static void fixLogLevelAfterClass() throws Exception { // SOLR-7603 - remove
|
||||
org.apache.log4j.LogManager.getRootLogger().setLevel(SAVED_LEVEL);
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,16 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
|||
|
||||
public void testUpdateDistribChainSkipping() throws Exception {
|
||||
|
||||
// a key part of this test is verifying that LogUpdateProcessor is found in all chains because it
|
||||
// is a @RunAllways processor -- but in order for that to work, we have to sanity check that the log
|
||||
// level is at least "INFO" otherwise the factory won't even produce a processor and all our assertions
|
||||
// are for nought. (see LogUpdateProcessorFactory.getInstance)
|
||||
//
|
||||
// TODO: maybe create a new mock Processor w/ @RunAlways annot if folks feel requiring INFO is evil.
|
||||
assertTrue("Tests must be run with INFO level logging "+
|
||||
"otherwise LogUpdateProcessor isn't used and can't be tested.",
|
||||
LogUpdateProcessor.log.isInfoEnabled());
|
||||
|
||||
final int EXPECTED_CHAIN_LENGTH = 5;
|
||||
SolrCore core = h.getCore();
|
||||
for (final String name : Arrays.asList("distrib-chain-explicit",
|
||||
|
@ -165,3 +175,4 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue