call ensureGreen instead of explicit call
This commit is contained in:
parent
04c560ce9f
commit
4eab186ce6
|
@ -255,7 +255,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
|||
.health(Requests.clusterHealthRequest().waitForGreenStatus().waitForEvents(Priority.LANGUID).waitForRelocatingShards(0)).actionGet();
|
||||
if (actionGet.isTimedOut()) {
|
||||
logger.info("ensureGreen timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint());
|
||||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
assertThat("timed out waiting for green state", actionGet.isTimedOut(), equalTo(false));
|
||||
}
|
||||
assertThat(actionGet.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
return actionGet.getStatus();
|
||||
|
@ -274,7 +274,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
|||
.health(request).actionGet();
|
||||
if (actionGet.isTimedOut()) {
|
||||
logger.info("waitForRelocation timed out (status={}), cluster state:\n{}\n{}", status, client().admin().cluster().prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint());
|
||||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
assertThat("timed out waiting for relocation", actionGet.isTimedOut(), equalTo(false));
|
||||
}
|
||||
if (status != null) {
|
||||
assertThat(actionGet.getStatus(), equalTo(status));
|
||||
|
@ -287,7 +287,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
|||
.health(Requests.clusterHealthRequest().waitForRelocatingShards(0).waitForYellowStatus().waitForEvents(Priority.LANGUID)).actionGet();
|
||||
if (actionGet.isTimedOut()) {
|
||||
logger.info("ensureYellow timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint());
|
||||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
assertThat("timed out waiting for yellow", actionGet.isTimedOut(), equalTo(false));
|
||||
}
|
||||
return actionGet.getStatus();
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.elasticsearch.aliases;
|
|||
|
||||
import org.elasticsearch.AbstractSharedClusterTest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
|
||||
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse;
|
||||
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse;
|
||||
|
@ -69,12 +67,8 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
//
|
||||
ensureGreen();
|
||||
//
|
||||
// try {
|
||||
// logger.info("--> indexing against [alias1], should fail");
|
||||
// client().index(indexRequest("alias1").type("type1").id("1").source(source("1", "test"))).actionGet();
|
||||
|
@ -94,11 +88,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test_x")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> remove [alias1], Aliasing index [test_x] with [alias1]");
|
||||
client().admin().indices().aliases(indexAliasesRequest().removeAlias("test", "alias1").addAlias("test_x", "alias1")).actionGet();
|
||||
|
@ -117,11 +107,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
try {
|
||||
logger.info("--> aliasing index [test] with [alias1] and filter [t]");
|
||||
|
@ -140,11 +126,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> aliasing index [test] with [alias1] and filter [user:kimchy]");
|
||||
FilterBuilder filter = termFilter("user", "kimchy");
|
||||
|
@ -166,11 +148,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> adding filtering aliases to index [test]");
|
||||
client().admin().indices().prepareAliases().addAlias("test", "alias1").execute().actionGet();
|
||||
|
@ -249,11 +227,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test2]");
|
||||
client().admin().indices().create(createIndexRequest("test2")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> adding filtering aliases to index [test1]");
|
||||
client().admin().indices().prepareAliases().addAlias("test1", "aliasToTest1").execute().actionGet();
|
||||
|
@ -319,11 +293,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
client().admin().indices().create(createIndexRequest("test2")).actionGet();
|
||||
client().admin().indices().create(createIndexRequest("test3")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> adding aliases to indices");
|
||||
client().admin().indices().prepareAliases().addAlias("test1", "alias12").execute().actionGet();
|
||||
|
@ -389,11 +359,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test2]");
|
||||
client().admin().indices().create(createIndexRequest("test2")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> adding filtering aliases to index [test1]");
|
||||
client().admin().indices().prepareAliases().addAlias("test1", "aliasToTest1").execute().actionGet();
|
||||
|
@ -455,11 +421,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
assertThat(client().admin().indices().prepareAliases().addAlias("test", "alias" + i).execute().actionGet().isAcknowledged(), equalTo(true));
|
||||
|
@ -476,11 +438,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.numberOfReplicas", 0).put("index.numberOfShards", 1))).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
assertThat(client().admin().indices().prepareAliases().addAlias("test", "alias" + i).execute().actionGet().isAcknowledged(), equalTo(true));
|
||||
|
@ -497,11 +455,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(aliasCount);
|
||||
for (int i = 0; i < aliasCount; i++) {
|
||||
|
@ -530,11 +484,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
logger.info("--> creating index [test]");
|
||||
client().admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> creating alias1 ");
|
||||
assertThat(client().admin().indices().prepareAliases().addAlias("test", "alias1").execute().actionGet().isAcknowledged(), equalTo(true));
|
||||
|
@ -598,11 +548,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
|
|||
.setSettings(indexSettings)
|
||||
.execute().actionGet();
|
||||
|
||||
logger.info("--> running cluster_health");
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
ensureGreen();
|
||||
|
||||
logger.info("--> creating aliases [alias1, alias2]");
|
||||
client().admin().indices().prepareAliases()
|
||||
|
|
Loading…
Reference in New Issue