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 00:57:13 UTC
svn commit: r1682565 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/
solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
Author: hossman
Date: Fri May 29 22:57:13 2015
New Revision: 1682565
URL: http://svn.apache.org/r1682565
Log:
SOLR-7603: more detail in asserts, and more asserts on the initial chain (before looking at the distributed version) to try and figure out WTF is going on here (merge r1682564)
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/update/processor/UpdateRequestProcessorFactoryTest.java
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=1682565&r1=1682564&r2=1682565&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 Fri May 29 22:57:13 2015
@@ -20,22 +20,36 @@ package org.apache.solr.update.processor
import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.solr.core.SolrCore;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
*
*/
public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
+
+ private static org.apache.log4j.Level SAVED_LEVEL = null; // SOLR-7603
@BeforeClass
public static void beforeClass() throws Exception {
+
+ // SOLR-7603
+ SAVED_LEVEL = org.apache.log4j.LogManager.getRootLogger().getLevel();
+ org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
+
initCore("solrconfig-transformers.xml", "schema.xml");
}
+ @AfterClass
+ public static void fixLogLevelAfterClass() throws Exception { // SOLR-7603
+ org.apache.log4j.LogManager.getRootLogger().setLevel(SAVED_LEVEL);
+ }
public void testConfiguration() throws Exception
{
@@ -78,60 +92,76 @@ public class UpdateRequestProcessorFacto
"distrib-chain-noop")) {
UpdateRequestProcessor proc;
+ List<UpdateRequestProcessor> procs;
+
UpdateRequestProcessorChain chain = core.getUpdateProcessingChain(name);
assertNotNull(name, chain);
-
// either explicitly, or because of injection
- assertEquals(name + " chain length", EXPECTED_CHAIN_LENGTH,
+ assertEquals(name + " chain length: " + chain.toString(), EXPECTED_CHAIN_LENGTH,
chain.getFactories().length);
- // Custom comes first in all three of our chains
+ // test a basic (non distrib) chain
proc = chain.createProcessor(req(), new SolrQueryResponse());
- assertTrue(name + " first processor isn't a CustomUpdateRequestProcessor: "
- + proc.getClass().getName(),
- proc instanceof CustomUpdateRequestProcessor);
+ procs = procToList(proc);
+ assertEquals(name + " procs size: " + procs.toString(),
+ // -1 = NoOpDistributingUpdateProcessorFactory produces no processor
+ EXPECTED_CHAIN_LENGTH - ("distrib-chain-noop".equals(name) ? 1 : 0),
+ procs.size());
+
+ // Custom comes first in all three of our chains
+ assertTrue(name + " first processor isn't a CustomUpdateRequestProcessor: " + procs.toString(),
+ ( // compare them both just because i'm going insane and the more checks the better
+ proc instanceof CustomUpdateRequestProcessor
+ && procs.get(0) instanceof CustomUpdateRequestProcessor));
+
+ // Log should always come second in our chain.
+ assertNotNull(name + " proc.next is null", proc.next);
+ assertNotNull(name + " second proc is null", procs.get(1));
+
+ assertTrue(name + " second proc isn't LogUpdateProcessor: " + procs.toString(),
+ ( // compare them both just because i'm going insane and the more checks the better
+ proc.next instanceof LogUpdateProcessor
+ && procs.get(1) instanceof LogUpdateProcessor));
- // varies depending on chain, but definitely shouldn't be Custom
+ // fetch the distributed version of this chain
proc = chain.createProcessor(req(DISTRIB_UPDATE_PARAM, "non_blank_value"),
new SolrQueryResponse());
-
- assertNotNull(name + " distrib chain had no proc's in it",
- proc);
- assertFalse(name + " post distrib proc should not be a CustomUpdateRequestProcessor: "
- + proc.getClass().getName(),
- proc instanceof CustomUpdateRequestProcessor);
-
- int n=0;
- boolean foundLog = false;
- String seen = "";
- for (;;) {
- n++;
- seen = seen + proc.toString() + ", ";
- if (proc instanceof LogUpdateProcessor) {
- foundLog = true;
- }
- if (null == proc.next) {
- break;
- } else {
- proc = proc.next;
- }
- }
-
- // some processors should have been dropped
- assertTrue(name + " expected a distrib chain shorter then " + EXPECTED_CHAIN_LENGTH + " but got: " + n
- + " (" + seen +")",
- n < EXPECTED_CHAIN_LENGTH );
- // make sure the marker interface was successful in keeping the log processor even though it comes
- // before distrib
- assertTrue(name + " expected LogUpdateProcessor in chain due to @RunAllways, but not found: " + seen,
- foundLog );
-
- // all of these (shortened) distrib chains should still end with RunUpdateprocessor
- assertTrue(name + " last processor isn't a RunUpdateProcessor: " + proc.getClass().getName(),
- proc instanceof RunUpdateProcessor);
+ procs = procToList(proc);
+ assertNotNull(name + " (distrib) chain produced null proc", proc);
+ assertFalse(name + " (distrib) procs is empty", procs.isEmpty());
+
+ // for these 3 (distrib) chains, the first proc should always be LogUpdateProcessor
+ assertTrue(name + " (distrib) first proc should be LogUpdateProcessor because of @RunAllways: "
+ + procs.toString(),
+ ( // compare them both just because i'm going insane and the more checks the better
+ proc instanceof LogUpdateProcessor
+ && procs.get(0) instanceof LogUpdateProcessor));
+
+ // for these 3 (distrib) chains, the last proc should always be RunUpdateProcessor
+ assertTrue(name + " (distrib) last processor isn't a RunUpdateProcessor: " + procs.toString(),
+ procs.get(procs.size()-1) instanceof RunUpdateProcessor );
+
+ // either 1 proc was droped in distrib mode, or 1 for the "implicit" chain
+ assertEquals(name + " (distrib) chain has wrong length: " + procs.toString(),
+ // -1 = all chains lose CustomUpdateRequestProcessorFactory
+ // -1 = distrib-chain-noop: NoOpDistributingUpdateProcessorFactory produces no processor
+ // -1 = distrib-chain-implicit: does RemoveBlank before distrib
+ EXPECTED_CHAIN_LENGTH - ( "distrib-chain-explicit".equals(name) ? 1 : 2),
+ procs.size());
}
}
+ /**
+ * walks the "next" values of the proc building up a List of the procs for easier testing
+ */
+ public static List<UpdateRequestProcessor> procToList(UpdateRequestProcessor proc) {
+ List<UpdateRequestProcessor> result = new ArrayList<UpdateRequestProcessor>(7);
+ while (null != proc) {
+ result.add(proc);
+ proc = proc.next;
+ }
+ return result;
+ }
}