You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2015/12/14 15:07:46 UTC
svn commit: r1719915 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
Author: cpoerschke
Date: Mon Dec 14 14:07:46 2015
New Revision: 1719915
URL: http://svn.apache.org/viewvc?rev=1719915&view=rev
Log:
SOLR-8352: randomise unload order in UnloadDistributedZkTest.testUnloadShardAndCollection (merge in revision 1719908 from trunk)
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1719915&r1=1719914&r2=1719915&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Mon Dec 14 14:07:46 2015
@@ -115,6 +115,8 @@ Other Changes
* SOLR-8404: tweak SolrQueryResponse.getToLogAsString, add TestSolrQueryResponse.testToLog (Christine Poerschke)
+* SOLR-8352: randomise unload order in UnloadDistributedZkTest.testUnloadShardAndCollection (Christine Poerschke)
+
================== 5.4.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java?rev=1719915&r1=1719914&r2=1719915&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java Mon Dec 14 14:07:46 2015
@@ -26,6 +26,8 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -38,6 +40,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.Random;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -72,15 +75,51 @@ public class UnloadDistributedZkTest ext
}
}
+ private void checkCoreNamePresenceAndSliceCount(String collectionName, String coreName,
+ boolean shouldBePresent, int expectedSliceCount) throws Exception {
+ final TimeOut timeout = new TimeOut(45, TimeUnit.SECONDS);
+ Boolean isPresent = null; // null meaning "don't know"
+ while (null == isPresent || shouldBePresent != isPresent.booleanValue()) {
+ final Collection<Slice> slices = getCommonCloudSolrClient().getZkStateReader().getClusterState().getSlices(collectionName);
+ if (timeout.hasTimedOut()) {
+ printLayout();
+ fail("checkCoreNamePresenceAndSliceCount failed:"
+ +" collection="+collectionName+" CoreName="+coreName
+ +" shouldBePresent="+shouldBePresent+" isPresent="+isPresent
+ +" expectedSliceCount="+expectedSliceCount+" actualSliceCount="+slices.size());
+ }
+ if (expectedSliceCount == (slices == null ? 0 : slices.size())) {
+ isPresent = false;
+ if (slices != null) {
+ for (Slice slice : slices) {
+ for (Replica replica : slice.getReplicas()) {
+ if (coreName.equals(replica.get("core"))) {
+ isPresent = true;
+ }
+ }
+ }
+ }
+ }
+ Thread.sleep(1000);
+ }
+ }
+
private void testUnloadShardAndCollection() throws Exception{
+
+ final int numShards = 2;
+
+ final String collection = "test_unload_shard_and_collection";
+
+ final String coreName1 = collection+"_1";
+ final String coreName2 = collection+"_2";
+
// create one leader and one replica
Create createCmd = new Create();
- createCmd.setCoreName("test_unload_shard_and_collection_1");
- String collection = "test_unload_shard_and_collection";
+ createCmd.setCoreName(coreName1);
createCmd.setCollection(collection);
String coreDataDir = createTempDir().toFile().getAbsolutePath();
createCmd.setDataDir(getDataDir(coreDataDir));
- createCmd.setNumShards(2);
+ createCmd.setNumShards(numShards);
SolrClient client = clients.get(0);
String url1 = getBaseUrl(client);
@@ -91,8 +130,7 @@ public class UnloadDistributedZkTest ext
adminClient.request(createCmd);
createCmd = new Create();
- createCmd.setCoreName("test_unload_shard_and_collection_2");
- collection = "test_unload_shard_and_collection";
+ createCmd.setCoreName(coreName2);
createCmd.setCollection(collection);
coreDataDir = createTempDir().toFile().getAbsolutePath();
createCmd.setDataDir(getDataDir(coreDataDir));
@@ -102,28 +140,23 @@ public class UnloadDistributedZkTest ext
// does not mean they are active and up yet :*
waitForRecoveriesToFinish(collection, false);
+ final boolean unloadInOrder = random().nextBoolean();
+ final String unloadCmdCoreName1 = (unloadInOrder ? coreName1 : coreName2);
+ final String unloadCmdCoreName2 = (unloadInOrder ? coreName2 : coreName1);
+
// now unload one of the two
Unload unloadCmd = new Unload(false);
- unloadCmd.setCoreName("test_unload_shard_and_collection_2");
+ unloadCmd.setCoreName(unloadCmdCoreName1);
adminClient.request(unloadCmd);
// there should be only one shard
- int slices = getCommonCloudSolrClient().getZkStateReader().getClusterState().getSlices(collection).size();
- final TimeOut timeout = new TimeOut(45, TimeUnit.SECONDS);
- while (slices != 1) {
- if (timeout.hasTimedOut()) {
- printLayout();
- fail("Expected to find only one slice in " + collection);
- }
-
- Thread.sleep(1000);
- slices = getCommonCloudSolrClient().getZkStateReader().getClusterState().getSlices(collection).size();
- }
+ checkCoreNamePresenceAndSliceCount(collection, unloadCmdCoreName1, false /* shouldBePresent */, numShards-1 /* expectedSliceCount */);
// now unload one of the other
unloadCmd = new Unload(false);
- unloadCmd.setCoreName("test_unload_shard_and_collection_1");
+ unloadCmd.setCoreName(unloadCmdCoreName2);
adminClient.request(unloadCmd);
+ checkCoreNamePresenceAndSliceCount(collection, unloadCmdCoreName2, false /* shouldBePresent */, numShards-2 /* expectedSliceCount */);
}
//printLayout();