Apache Lucene open-source search software
tests: fix test of unordered namedlist, skip explain comparisons
Yonik Seeley0834c89f9299
diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.javaindex 2a3948bc016..afac95666ef 100755--- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java+++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java@@ -310,7 +310,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {unIgnoreException("isShard is only acceptable");// test debugging- handle.put("explain", UNORDERED);+ // handle.put("explain", UNORDERED);+ handle.put("explain", SKIPVAL); // internal docids differ, idf differs w/o global idfhandle.put("debug", UNORDERED);handle.put("time", SKIPVAL);query("q","now their fox sat had put","fl","*,score",CommonParams.DEBUG_QUERY, "true");diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.javaindex cfc723eeb11..821b6047282 100644--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java@@ -281,7 +281,7 @@ public class BasicDistributedZkTest extends AbstractDistributedZkTestCase {}// test debugging- handle.put("explain", UNORDERED);+ handle.put("explain", SKIPVAL);handle.put("debug", UNORDERED);handle.put("time", SKIPVAL);query("q","now their fox sat had put","fl","*,score",CommonParams.DEBUG_QUERY, "true");diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.javaindex ae076bd7b86..263ce7a98de 100644--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java@@ -845,7 +845,7 @@ public class FullSolrCloudTest extends AbstractDistributedZkTestCase {}private void testDebugQueries() throws Exception {- handle.put("explain", UNORDERED);+ handle.put("explain", SKIPVAL);handle.put("debug", UNORDERED);handle.put("time", SKIPVAL);query("q", "now their fox sat had put", "fl", "*,score",diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.javaindex 1c3d4ed88bc..3d391b07eab 100644--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java@@ -450,11 +450,25 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {// System.out.println("resp b:" + b);boolean ordered = (flags & UNORDERED) == 0;+ if (!ordered) {+ Map mapA = new HashMap(a.size());+ for (int i=0; i<a.size(); i++) {+ Object prev = mapA.put(a.getName(i), a.getVal(i));+ }++ Map mapB = new HashMap(b.size());+ for (int i=0; i<b.size(); i++) {+ Object prev = mapB.put(b.getName(i), b.getVal(i));+ }++ return compare(mapA, mapB, flags, handle);+ }+int posa = 0, posb = 0;int aSkipped = 0, bSkipped = 0;for (; ;) {- if (posa >= a.size() || posb >= b.size()) {+ if (posa >= a.size() && posb >= b.size()) {break;}@@ -468,29 +482,27 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {posa++;flagsa = flags(handle, namea);if ((flagsa & SKIP) != 0) {+ namea = null; vala = null;aSkipped++;continue;}break;}- if (!ordered) posb = 0; // reset if not ordered-while (posb < b.size()) {nameb = b.getName(posb);valb = b.getVal(posb);posb++;flagsb = flags(handle, nameb);if ((flagsb & SKIP) != 0) {+ nameb = null; valb = null;bSkipped++;continue;}if (eq(namea, nameb)) {break;}- if (ordered) {- return "." + namea + "!=" + nameb + " (unordered or missing)";- }+ return "." + namea + "!=" + nameb + " (unordered or missing)";// if unordered, continue until we find the right field.}@@ -503,7 +515,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {if (a.size() - aSkipped != b.size() - bSkipped) {- return ".size()==" + a.size() + "," + b.size() + "skipped=" + aSkipped + "," + bSkipped;+ return ".size()==" + a.size() + "," + b.size() + " skipped=" + aSkipped + "," + bSkipped;}return null;