You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/04/19 09:40:24 UTC
lucene-solr:master: SOLR-8349: trying to address test failures
Repository: lucene-solr
Updated Branches:
refs/heads/master af09c618e -> 456d5c04c
SOLR-8349: trying to address test failures
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/456d5c04
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/456d5c04
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/456d5c04
Branch: refs/heads/master
Commit: 456d5c04c87744659a241f85d0fa04c683c81a2c
Parents: af09c61
Author: Noble Paul <no...@apache.org>
Authored: Tue Apr 19 13:09:59 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Tue Apr 19 13:09:59 2016 +0530
----------------------------------------------------------------------
.../solr/core/BlobRepositoryCloudTest.java | 36 +++++---------------
1 file changed, 8 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/456d5c04/solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java b/solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java
index 3e51b36..2ef7083 100644
--- a/solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java
+++ b/solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java
@@ -2,15 +2,12 @@ package org.apache.solr.core;
import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Set;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
@@ -19,6 +16,8 @@ import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.cloud.ZkTestServer;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.handler.TestBlobHandler;
import org.apache.zookeeper.server.DataNode;
import org.apache.zookeeper.server.DataTree;
import org.apache.zookeeper.server.ZKDatabase;
@@ -54,10 +53,9 @@ public class BlobRepositoryCloudTest extends SolrCloudTestCase {
// Thread.sleep(2000);
HashMap<String, String> params = new HashMap<>();
cluster.createCollection(".system", 1, 1, null, params);
-// Thread.sleep(2000);
// test component will fail if it cant' find a blob with this data by this name
- postBlob("testResource", "foo,bar\nbaz,bam");
-// Thread.sleep(2000);
+ TestBlobHandler.postData(cluster.getSolrClient(), findLiveNodeURI(), "testResource", ByteBuffer.wrap("foo,bar\nbaz,bam".getBytes(StandardCharsets.UTF_8)));
+ // Thread.sleep(2000);
// if these don't load we probably failed to post the blob above
cluster.createCollection("col1", 1, 1, "configname", params);
cluster.createCollection("col2", 1, 1, "configname", params);
@@ -95,28 +93,10 @@ public class BlobRepositoryCloudTest extends SolrCloudTestCase {
assertLastQueryToCollection("col2");
}
- // TODO: move this up to parent class? Probably accepting entity, or with alternative signatures
- private static void postBlob(String name, String string) throws IOException {
- HttpPost post = new HttpPost(findLiveNodeURI() + "/.system/blob/" + name);
- StringEntity csv = new StringEntity(string, ContentType.create("application/octet-stream"));
- post.setEntity(csv);
- try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
- httpclient.execute(post);
- }
- }
-
// TODO: move this up to parent class?
private static String findLiveNodeURI() {
- ZkTestServer zkServer = cluster.getZkServer();
- ZKDatabase zkDatabase = zkServer.getZKDatabase();
- DataTree dataTree = zkDatabase.getDataTree();
- DataNode node = dataTree.getNode("/solr/live_nodes");
- Set<String> children = node.getChildren();
- String liveNode = children.iterator().next();
- String[] split = liveNode.split("_");
- String host = split[0];
- String name = split[1];
- return "http://" + host + "/" + name;
+ ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
+ return zkStateReader.getBaseUrlForNodeName(zkStateReader.getClusterState().getCollection(".system").getSlices().iterator().next().getLeader().getNodeName());
}
private void assertLastQueryToCollection(String collection) throws SolrServerException, IOException {