You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2015/05/30 02:59:38 UTC

svn commit: r1682571 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java

Author: hossman
Date: Sat May 30 00:59:37 2015
New Revision: 1682571

URL: http://svn.apache.org/r1682571
Log:
SOLR-7603: more test tweaks to protect ourselves from unexpected log levels in tests like the one introduced by SOLR-7408 (merge r1682570)

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java?rev=1682571&r1=1682570&r2=1682571&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java Sat May 30 00:59:37 2015
@@ -75,29 +75,37 @@ public class ConcurrentDeleteAndCreateCo
   }
   
   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<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);
+    // 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
+      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);
+      }
     
-    assertNull("concurrent create and delete collection failed: " + failure.get(), failure.get());
+      startAll(threads);
+      joinAll(threads);
     
-    try {
-      solrClient.close();
-    } catch (IOException e) {
-      throw new RuntimeException(e);
+      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 ConcurrentDeleteAndCreateCo
     
   }
   
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java?rev=1682571&r1=1682570&r2=1682571&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java Sat May 30 00:59:37 2015
@@ -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 UpdateRequestProcessorFacto
   }
   
   @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 UpdateRequestProcessorFacto
 
   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 UpdateRequestProcessorFacto
     return result;
   }
 }
+