mirror of https://github.com/apache/lucene.git
SOLR-7468: Close the cloud client created for test in a finally block.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1681413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3b3de98bb
commit
5a96141d7f
|
@ -146,30 +146,34 @@ public class TestSolrCloudWithKerberos extends AbstractFullDistribZkTestBase {
|
|||
|
||||
@Test
|
||||
public void testKerberizedSolr() throws Exception {
|
||||
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
|
||||
CloudSolrClient testClient = createCloudClient("testcollection");
|
||||
|
||||
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
|
||||
create.setCollectionName("testcollection");
|
||||
create.setConfigName("conf1");
|
||||
create.setNumShards(1);
|
||||
create.setReplicationFactor(1);
|
||||
create.process(testClient);
|
||||
|
||||
waitForCollection(testClient.getZkStateReader(), "testcollection", 1);
|
||||
CollectionAdminRequest.List list = new CollectionAdminRequest.List();
|
||||
|
||||
CollectionAdminResponse response = list.process(testClient);
|
||||
assertTrue("Expected to see testcollection but it doesn't exist",
|
||||
((ArrayList) response.getResponse().get("collections")).contains("testcollection"));
|
||||
|
||||
testClient.setDefaultCollection("testcollection");
|
||||
indexDoc(testClient, params("commit", "true"), getDoc("id", 1));
|
||||
//cloudClient.commit();
|
||||
CloudSolrClient testClient = null;
|
||||
try {
|
||||
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
|
||||
testClient = createCloudClient("testcollection");
|
||||
|
||||
QueryResponse queryResponse = testClient.query(new SolrQuery("*:*"));
|
||||
assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size());
|
||||
testClient.close();
|
||||
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
|
||||
create.setCollectionName("testcollection");
|
||||
create.setConfigName("conf1");
|
||||
create.setNumShards(1);
|
||||
create.setReplicationFactor(1);
|
||||
create.process(testClient);
|
||||
|
||||
waitForCollection(testClient.getZkStateReader(), "testcollection", 1);
|
||||
CollectionAdminRequest.List list = new CollectionAdminRequest.List();
|
||||
|
||||
CollectionAdminResponse response = list.process(testClient);
|
||||
assertTrue("Expected to see testcollection but it doesn't exist",
|
||||
((ArrayList) response.getResponse().get("collections")).contains("testcollection"));
|
||||
|
||||
testClient.setDefaultCollection("testcollection");
|
||||
indexDoc(testClient, params("commit", "true"), getDoc("id", 1));
|
||||
|
||||
QueryResponse queryResponse = testClient.query(new SolrQuery("*:*"));
|
||||
assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size());
|
||||
} finally {
|
||||
if(testClient != null)
|
||||
testClient.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue