make ping tests run faster using cluster state api

This commit is contained in:
kimchy 2010-09-19 18:13:03 +02:00
parent 589dbce89b
commit 20b6688b0a
1 changed files with 9 additions and 4 deletions

View File

@ -19,6 +19,8 @@
package org.elasticsearch.test.integration.ping; package org.elasticsearch.test.integration.ping;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.admin.cluster.ping.broadcast.BroadcastPingResponse; import org.elasticsearch.action.admin.cluster.ping.broadcast.BroadcastPingResponse;
import org.elasticsearch.action.admin.cluster.ping.replication.ReplicationPingResponse; import org.elasticsearch.action.admin.cluster.ping.replication.ReplicationPingResponse;
import org.elasticsearch.action.admin.cluster.ping.single.SinglePingResponse; import org.elasticsearch.action.admin.cluster.ping.single.SinglePingResponse;
@ -34,7 +36,7 @@ import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
/** /**
* @author kimchy (Shay Banon) * @author kimchy (shay.banon)
*/ */
public class PingActionTests extends AbstractNodesTests { public class PingActionTests extends AbstractNodesTests {
@ -49,14 +51,17 @@ public class PingActionTests extends AbstractNodesTests {
closeAllNodes(); closeAllNodes();
} }
@Test public void testIndexActions() throws Exception { @Test public void testPingActions() throws Exception {
logger.info("Creating index [test1]"); logger.info("Creating index [test1]");
client("server1").admin().indices().create(createIndexRequest("test1")).actionGet(); client("server1").admin().indices().create(createIndexRequest("test1")).actionGet();
logger.info("Creating index [test2]"); logger.info("Creating index [test2]");
client("server1").admin().indices().create(createIndexRequest("test2")).actionGet(); client("server1").admin().indices().create(createIndexRequest("test2")).actionGet();
logger.info("Sleeping to shards allocate and start"); logger.info("Running Cluster Health");
Thread.sleep(500); ClusterHealthResponse clusterHealth = client("server1").admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
logger.info("Done Cluster Health, status " + clusterHealth.status());
assertThat(clusterHealth.timedOut(), equalTo(false));
assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.GREEN));
logger.info("Pinging single person with id 1"); logger.info("Pinging single person with id 1");
SinglePingResponse singleResponse = client("server1").admin().cluster().ping(pingSingleRequest("test1").type("person").id("1")).actionGet(); SinglePingResponse singleResponse = client("server1").admin().cluster().ping(pingSingleRequest("test1").type("person").id("1")).actionGet();