From abed84e8367a2e5e8553788ff154dd10f75351d4 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Fri, 18 Apr 2014 02:37:12 +0000 Subject: [PATCH] SOLR-5989: Pass add and delete fails to checkShardConsistency call in ChaosMonkeyNothingisSafeTest so that legal differences are ignored. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1588403 13f79535-47bb-0310-9956-ffa450edef68 --- .../cloud/ChaosMonkeyNothingIsSafeTest.java | 26 +++++++++++++++++-- .../cloud/AbstractFullDistribZkTestBase.java | 7 ++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java index 523c5a6c61b..66166e7fa4a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java @@ -19,6 +19,7 @@ package org.apache.solr.cloud; import java.net.ConnectException; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; @@ -128,11 +129,13 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase del("*:*"); List threads = new ArrayList<>(); + List indexTreads = new ArrayList<>(); int threadCount = TEST_NIGHTLY ? 3 : 1; int i = 0; for (i = 0; i < threadCount; i++) { StopableIndexingThread indexThread = new StopableIndexingThread(controlClient, cloudClient, Integer.toString(i), true); threads.add(indexThread); + indexTreads.add(indexThread); indexThread.start(); } @@ -213,9 +216,12 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase } } + + Set addFails = getAddFails(indexTreads); + Set deleteFails = getDeleteFails(indexTreads); // full throttle thread can // have request fails - checkShardConsistency(!runFullThrottle, true); + checkShardConsistency(!runFullThrottle, true, addFails, deleteFails); long ctrlDocs = controlClient.query(new SolrQuery("*:*")).getResults() .getNumFound(); @@ -250,7 +256,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase List numShardsNumReplicas = new ArrayList<>(2); numShardsNumReplicas.add(1); numShardsNumReplicas.add(1); - checkForCollection("testcollection",numShardsNumReplicas, null); + checkForCollection("testcollection", numShardsNumReplicas, null); testsSuccesful = true; } finally { @@ -260,6 +266,22 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase } } + private Set getAddFails(List threads) { + Set addFails = new HashSet(); + for (StopableIndexingThread thread : threads) { + addFails.addAll(thread.getAddFails()); + } + return addFails; + } + + private Set getDeleteFails(List threads) { + Set deleteFails = new HashSet(); + for (StopableIndexingThread thread : threads) { + deleteFails.addAll(thread.getDeleteFails()); + } + return deleteFails; + } + class FullThrottleStopableIndexingThread extends StopableIndexingThread { private HttpClient httpClient = HttpClientUtil.createClient(null); private volatile boolean stop = false; diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index 988ba6ac384..70c20092156 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -1133,10 +1133,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes return sb.toString(); } - boolean checkForLegalDiff(SolrDocumentList a, SolrDocumentList b, String aName, String bName, Set addFails, Set deleteFails) { - // System.err.println("######"+aName+ ": " + toStr(a,10)); - // System.err.println("######"+bName+ ": " + toStr(b,10)); - //System.err.println("###### sizes=" + a.size() + "," + b.size()); + boolean checkIfDiffIsLegal(SolrDocumentList a, SolrDocumentList b, String aName, String bName, Set addFails, Set deleteFails) { boolean legal = true; Set setA = new HashSet<>(); for (SolrDocument sdoc : a) { @@ -1321,7 +1318,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes }; if (addFails != null || deleteFails != null) { - boolean legal = checkForLegalDiff(controlDocList, cloudDocList, + boolean legal = checkIfDiffIsLegal(controlDocList, cloudDocList, "controlDocList", "cloudDocList", addFails, deleteFails); if (legal) { return false;