Apache Solr open-source search software
SOLR-13454: Investigate ReindexCollectionTest failures
Erick Erickson577be08bf278
diff --git a/solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java b/solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.javaindex 68a76ffdb69..a1c5961e5e6 100644--- a/solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java@@ -179,7 +179,7 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {CloudSolrClient client = cluster.getSolrClient();client.deleteByQuery("*:*");client.commit();- Solr11035BandAid(client, COLLECTION, "id", 0, "*:*");+ Solr11035BandAid(client, COLLECTION, "id", 0, "*:*", "DocValuesNotINdexedTest.clean");resetFields(fieldsToTestSingle);resetFields(fieldsToTestMulti);resetFields(fieldsToTestGroupSortFirst);@@ -255,7 +255,7 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {new UpdateRequest().add(docs).commit(client, COLLECTION);- Solr11035BandAid(client, COLLECTION, "id", 4, "*:*");+ Solr11035BandAid(client, COLLECTION, "id", 4, "*:*", "DocValuesNotINdexedTest.testGroupSorting");checkSortOrder(client, fieldsToTestGroupSortFirst, "asc", new String[]{"4", "2", "1", "3"}, new String[]{"4", "1", "2", "3"});checkSortOrder(client, fieldsToTestGroupSortFirst, "desc", new String[]{"3", "1", "2", "4"}, new String[]{"2", "3", "1", "4"});@@ -298,7 +298,7 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {.add(docs).commit(client, COLLECTION);- Solr11035BandAid(client, COLLECTION, "id", 4, "*:*");+ Solr11035BandAid(client, COLLECTION, "id", 4, "*:*", "DocValuesNotINdexedTest.testGroupingDocAbsent");// when grouping on any of these DV-only (not indexed) fields we expect exactly 4 groups except for Boolean.for (FieldProps prop : fieldsToTestGroupSortFirst) {// Special handling until SOLR-9802 is fixed@@ -362,7 +362,7 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {.add(docs).commit(client, COLLECTION);- Solr11035BandAid(client, COLLECTION,"id", 59, "*:*");+ Solr11035BandAid(client, COLLECTION,"id", 59, "*:*", "DocValuesNotINdexedTest.doGroupingDvOnly");// OK, we should have one group with 10 entries for null, a group with 1 entry and 7 groups with 7for (FieldProps prop : fieldProps) {diff --git a/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.javaindex 6c84253afea..354d34cc573 100644--- a/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ReindexCollectionTest.java@@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch;import java.util.concurrent.TimeUnit;import java.util.function.Function;+import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.client.solrj.cloud.DistribStateManager;import org.apache.solr.client.solrj.cloud.SolrCloudManager;import org.apache.solr.client.solrj.impl.CloudSolrClient;@@ -139,6 +140,10 @@ public class ReindexCollectionTest extends SolrCloudTestCase {});// verify the target docs existQueryResponse queryResponse = solrClient.query(targetCollection, params(CommonParams.Q, "*:*"));++ SolrTestCaseJ4.Solr11035BandAid(solrClient, targetCollection, "id", NUM_DOCS, "*:*",+ "ReindexCollectionTest.testBasicReindexing", true);+assertEquals("copied num docs", NUM_DOCS, queryResponse.getResults().getNumFound());}@@ -177,6 +182,8 @@ public class ReindexCollectionTest extends SolrCloudTestCase {});// verify the target docs existQueryResponse rsp = solrClient.query(targetCollection, params(CommonParams.Q, "*:*"));+ SolrTestCaseJ4.Solr11035BandAid(solrClient, targetCollection, "id", NUM_DOCS, "*:*",+ "ReindexCollectionTest.testSameTargetReindex", true);assertEquals("copied num docs", NUM_DOCS, rsp.getResults().getNumFound());}@@ -205,6 +212,8 @@ public class ReindexCollectionTest extends SolrCloudTestCase {});// verify the target docs existQueryResponse rsp = solrClient.query(targetCollection, params(CommonParams.Q, "*:*"));+ SolrTestCaseJ4.Solr11035BandAid(solrClient, targetCollection, "id", NUM_DOCS, "*:*",+ "ReindexCollectionTest.testLossyScherma", true);assertEquals("copied num docs", NUM_DOCS, rsp.getResults().getNumFound());for (SolrDocument doc : rsp.getResults()) {String id = (String)doc.getFieldValue("id");@@ -240,6 +249,9 @@ public class ReindexCollectionTest extends SolrCloudTestCase {});// verify the target docs existQueryResponse rsp = solrClient.query(targetCollection, params(CommonParams.Q, "*:*"));++ SolrTestCaseJ4.Solr11035BandAid(solrClient, targetCollection, "id", 11, "*:*",+ "ReindexCollectionTest.testReshapeReindexTarget", true);// 10 and 100-109assertEquals("copied num docs", 11, rsp.getResults().getNumFound());// verify the correct fields existdiff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex b6541abdf35..e752c7a6a63 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -3032,10 +3032,26 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {* @param idField - the uniqueKey for this collection. This MUST be a string* @param expectedDocCount - numFound for the query* @param query - The Solr query to check for expectedDocCount.+ * @param tag - additional information to display on a failure. Often class.method is useful.*/public static void Solr11035BandAid(SolrClient client, String collection, String idField,- long expectedDocCount, String query) throws IOException, SolrServerException {+ long expectedDocCount, String query,+ String tag) throws IOException, SolrServerException {++ Solr11035BandAid(client, collection, idField, expectedDocCount, query, tag, false);+ }++ // Pass true for failAnyway to have this bandaid fail if+ // 1> it had to attempt the repair+ // 2> it would have successfully repaired it+ //+ // This is useful for verifying that SOLR-11035.+ //+ public static void Solr11035BandAid(SolrClient client, String collection, String idField,+ long expectedDocCount, String query, String tag,+ boolean failAnyway) throws IOException, SolrServerException {+final SolrQuery solrQuery = new SolrQuery(query);QueryResponse rsp = client.query(collection, solrQuery);long found = rsp.getResults().getNumFound();@@ -3066,7 +3082,9 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {// so change the pattern in log4j2.xml if you need to see the whole thing.log.error("Dumping response" + rsp.toString());assertEquals("Solr11035BandAid failed, counts differ after updates:", found, expectedDocCount);+ } else if (failAnyway) {+ fail("failAnyway == true, would have successfully repaired the collection: '" + collection+ + "' extra info: '" + tag + "'");}-}}