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,29 +75,37 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConcurrentCreateAndDeleteOverTheSameConfig() {
|
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
|
||||||
final String configName = "testconfig";
|
// reset when it's done.
|
||||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
final Logger logger = Logger.getLogger("org.apache.solr");
|
||||||
uploadConfig(configDir, configName); // upload config once, to be used by all collections
|
final Level SAVED_LEVEL = logger.getLevel();
|
||||||
final SolrClient solrClient = new HttpSolrClient(solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString());
|
|
||||||
final AtomicReference<Exception> failure = new AtomicReference<>();
|
|
||||||
final int timeToRunSec = 30;
|
|
||||||
final Thread[] threads = new Thread[2];
|
|
||||||
for (int i = 0; i < threads.length; i++) {
|
|
||||||
final String collectionName = "collection" + i;
|
|
||||||
threads[i] = new CreateDeleteCollectionThread("create-delete-" + i, collectionName, configName,
|
|
||||||
timeToRunSec, solrClient, failure);
|
|
||||||
}
|
|
||||||
|
|
||||||
startAll(threads);
|
|
||||||
joinAll(threads);
|
|
||||||
|
|
||||||
assertNull("concurrent create and delete collection failed: " + failure.get(), failure.get());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
solrClient.close();
|
logger.setLevel(Level.WARN);
|
||||||
} catch (IOException e) {
|
final String configName = "testconfig";
|
||||||
throw new RuntimeException(e);
|
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||||
|
uploadConfig(configDir, configName); // upload config once, to be used by all collections
|
||||||
|
final SolrClient solrClient = new HttpSolrClient(solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString());
|
||||||
|
final AtomicReference<Exception> failure = new AtomicReference<>();
|
||||||
|
final int timeToRunSec = 30;
|
||||||
|
final Thread[] threads = new Thread[2];
|
||||||
|
for (int i = 0; i < threads.length; i++) {
|
||||||
|
final String collectionName = "collection" + i;
|
||||||
|
threads[i] = new CreateDeleteCollectionThread("create-delete-" + i, collectionName, configName,
|
||||||
|
timeToRunSec, solrClient, failure);
|
||||||
|
}
|
||||||
|
|
||||||
|
startAll(threads);
|
||||||
|
joinAll(threads);
|
||||||
|
|
||||||
|
assertNull("concurrent create and delete collection failed: " + failure.get(), failure.get());
|
||||||
|
|
||||||
|
try {
|
||||||
|
solrClient.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
logger.setLevel(SAVED_LEVEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,4 +230,4 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,12 @@ import org.junit.BeforeClass;
|
||||||
*/
|
*/
|
||||||
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
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
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
|
|
||||||
// SOLR-7603
|
// SOLR-7603 - remove
|
||||||
SAVED_LEVEL = org.apache.log4j.LogManager.getRootLogger().getLevel();
|
SAVED_LEVEL = org.apache.log4j.LogManager.getRootLogger().getLevel();
|
||||||
org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
|
org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@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);
|
org.apache.log4j.LogManager.getRootLogger().setLevel(SAVED_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,16 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
||||||
|
|
||||||
public void testUpdateDistribChainSkipping() throws Exception {
|
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;
|
final int EXPECTED_CHAIN_LENGTH = 5;
|
||||||
SolrCore core = h.getCore();
|
SolrCore core = h.getCore();
|
||||||
for (final String name : Arrays.asList("distrib-chain-explicit",
|
for (final String name : Arrays.asList("distrib-chain-explicit",
|
||||||
|
@ -165,3 +175,4 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue