client1.admin().indices().create(createIndexRequest("test")).actionGet();
logger.info("--> running cluster_health");
ClusterHealthResponse clusterHealth = client1.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));
assertThat(client2.admin().indices().prepareAliases().addAlias("test", "alias1").setTimeout(TimeValue.timeValueMillis(0)).execute().actionGet().acknowledged(), equalTo(false));
assertThat(client1.admin().indices().prepareAliases().addAlias("test", "alias2").setTimeout(TimeValue.timeValueMillis(0)).execute().actionGet().acknowledged(), equalTo(false));
assertThat(client2.admin().indices().prepareAliases().addAlias("test", "alias3").execute().actionGet().acknowledged(), equalTo(true));