From b19ad613105d814b128de265c86b174af0d399e4 Mon Sep 17 00:00:00 2001 From: emiguez Date: Sun, 13 Sep 2015 22:23:24 +0200 Subject: [PATCH] [test] ensure TransportClient compatibility add test that show usage of plugin side by side with the TransportClient without problem. closes #58 --- .../TransportClientIntegrationTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/TransportClientIntegrationTest.java diff --git a/src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/TransportClientIntegrationTest.java b/src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/TransportClientIntegrationTest.java new file mode 100644 index 0000000..6a26383 --- /dev/null +++ b/src/test/java/com/asquera/elasticsearch/plugins/http/auth/integration/TransportClientIntegrationTest.java @@ -0,0 +1,60 @@ + +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.asquera.elasticsearch.plugins.http.auth.integration; + +import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.junit.Test; + +import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; +import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope; +import static org.hamcrest.Matchers.equalTo; + +import org.elasticsearch.client.Client; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.client.Requests.refreshRequest; +import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse.*; +import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; + +/** + * Test the transport client is compatible with the plugin + */ +@ClusterScope(transportClientRatio = 1.0, scope = Scope.SUITE, numDataNodes = 1) +public class TransportClientIntegrationTest extends HttpBasicServerPluginIntegrationTest { + + @Test + public void testHealthCheck() throws Exception { + Client client = ElasticsearchIntegrationTest.client(); + logger.info("-->creating index [testto]"); + client.admin().indices() + .create(createIndexRequest("testto")).actionGet(); + client.admin().indices() + .refresh(refreshRequest()).actionGet(); + logger.info("-->cluster_health"); + ClusterHealthResponse clusterHealth = client.admin().cluster(). + health((new ClusterHealthRequest("testto")) + .waitForGreenStatus()).actionGet(); + logger.info("-->cluster_health, status " + clusterHealth.getStatus()); + assertThat(clusterHealth.isTimedOut(),equalTo(false)); + assertThat(clusterHealth.getStatus(),equalTo(ClusterHealthStatus.GREEN)); + } + +}