diff --git a/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java index c60386f91a6..e244cd38213 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java @@ -75,29 +75,37 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 { } public void testConcurrentCreateAndDeleteOverTheSameConfig() { - Logger.getLogger("org.apache.solr").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 - final SolrClient solrClient = new HttpSolrClient(solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString()); - final AtomicReference 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()); - + // 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 { - solrClient.close(); - } catch (IOException e) { - throw new RuntimeException(e); + 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 + final SolrClient solrClient = new HttpSolrClient(solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString()); + final AtomicReference 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 { } -} \ No newline at end of file +} diff --git a/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java index e0644bdad9e..101be70f083 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java @@ -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; } } +