You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2016/04/27 20:22:25 UTC
[41/50] [abbrv] lucene-solr:solr-5750: SOLR-5750: test asyncId usage.
SOLR-5750: test asyncId usage.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/97b49d88
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/97b49d88
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/97b49d88
Branch: refs/heads/solr-5750
Commit: 97b49d8801aa74bfe3b57ebdbd60cfd301d76b33
Parents: 3ce00a5
Author: David Smiley <ds...@apache.org>
Authored: Tue Apr 26 20:19:46 2016 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Tue Apr 26 20:19:46 2016 -0400
----------------------------------------------------------------------
.../solr/cloud/TestCloudBackupRestore.java | 64 ++++++++++----------
1 file changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/97b49d88/solr/core/src/test/org/apache/solr/cloud/TestCloudBackupRestore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudBackupRestore.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudBackupRestore.java
index f0817e2..222c853 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudBackupRestore.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudBackupRestore.java
@@ -30,12 +30,11 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.RequestStatusState;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.ImplicitDocRouter;
import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -88,7 +87,6 @@ public class TestCloudBackupRestore extends SolrCloudTestCase {
}
create.process(cluster.getSolrClient());
- waitForCollection(collectionName);
indexDocs(collectionName);
if (!isImplicit && random().nextBoolean()) {
@@ -135,7 +133,6 @@ public class TestCloudBackupRestore extends SolrCloudTestCase {
private void testBackupAndRestore(String collectionName) throws Exception {
String backupName = "mytestbackup";
- String restoreCollectionName = collectionName + "_restored";
CloudSolrClient client = cluster.getSolrClient();
DocCollection backupCollection = client.getZkStateReader().getClusterState().getCollection(collectionName);
@@ -147,30 +144,42 @@ public class TestCloudBackupRestore extends SolrCloudTestCase {
log.info("Triggering Backup command");
- CollectionAdminRequest.Backup backup = CollectionAdminRequest.backupCollection(collectionName, backupName)
- .setLocation(location);
- NamedList<Object> rsp = cluster.getSolrClient().request(backup);
- assertEquals(0, ((NamedList)rsp.get("responseHeader")).get("status"));
+ {
+ CollectionAdminRequest.Backup backup = CollectionAdminRequest.backupCollection(collectionName, backupName)
+ .setLocation(location);
+ if (random().nextBoolean()) {
+ assertEquals(0, backup.process(client).getStatus());
+ } else {
+ assertEquals(RequestStatusState.COMPLETED, backup.processAndWait(client, 30));//async
+ }
+ }
log.info("Triggering Restore command");
- //nocommit test with async
- CollectionAdminRequest.Restore restore = CollectionAdminRequest.restoreCollection(restoreCollectionName, backupName)
- .setLocation(location);
- if (origShardToDocCount.size() > cluster.getJettySolrRunners().size()) {
- // may need to increase maxShardsPerNode (e.g. if it was shard split, then now we need more)
- restore.getCreateOptions().setMaxShardsPerNode(origShardToDocCount.size());
- }
- Properties props = new Properties();
- props.setProperty("customKey", "customVal");
- restore.getCreateOptions().setProperties(props);
+ String restoreCollectionName = collectionName + "_restored";
boolean sameConfig = random().nextBoolean();
- if (sameConfig==false) {
- restore.getCreateOptions().setConfigName("customConfigName");//nocommit ugh, this is deprecated
+
+ {
+ CollectionAdminRequest.Restore restore = CollectionAdminRequest.restoreCollection(restoreCollectionName, backupName)
+ .setLocation(location);
+ if (origShardToDocCount.size() > cluster.getJettySolrRunners().size()) {
+ // may need to increase maxShardsPerNode (e.g. if it was shard split, then now we need more)
+ restore.getCreateOptions().setMaxShardsPerNode(origShardToDocCount.size());
+ }
+ Properties props = new Properties();
+ props.setProperty("customKey", "customVal");
+ restore.getCreateOptions().setProperties(props);
+ if (sameConfig==false) {
+ restore.getCreateOptions().setConfigName("customConfigName");//nocommit ugh, this is deprecated
+ }
+ if (random().nextBoolean()) {
+ assertEquals(0, restore.process(client).getStatus());
+ } else {
+ assertEquals(RequestStatusState.COMPLETED, restore.processAndWait(client, 30));//async
+ }
+ AbstractDistribZkTestBase.waitForRecoveriesToFinish(
+ restoreCollectionName, cluster.getSolrClient().getZkStateReader(), log.isDebugEnabled(), true, 30);
}
- rsp = cluster.getSolrClient().request(restore); // DO IT!
- assertEquals(0, ((NamedList)rsp.get("responseHeader")).get("status"));
- waitForCollection(restoreCollectionName);
//Check the number of results are the same
DocCollection restoreCollection = client.getZkStateReader().getClusterState().getCollection(restoreCollectionName);
@@ -204,13 +213,4 @@ public class TestCloudBackupRestore extends SolrCloudTestCase {
return shardToDocCount;
}
- public void waitForCollection(String collection) throws Exception {
- // note: NUM_SHARDS may be too small because of shard split, but that's okay?
- ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
- AbstractFullDistribZkTestBase.waitForCollection(zkStateReader, collection, NUM_SHARDS);
- AbstractDistribZkTestBase.waitForRecoveriesToFinish(collection, zkStateReader, log.isDebugEnabled(), true, 30);
- AbstractDistribZkTestBase.assertAllActive(collection, zkStateReader);
- assertFalse(zkStateReader.getClusterState().getCollection(collection).getActiveSlices().isEmpty());
- }
-
}