mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Stabelize more tests
Wait for relocation before checking statistics or run refresh / optimze.
This commit is contained in:
parent
1c513bc262
commit
3b01f812d6
@ -23,6 +23,8 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFa
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -242,6 +244,24 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
||||
return actionGet.getStatus();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus waitForRelocation() {
|
||||
return waitForRelocation(null);
|
||||
}
|
||||
|
||||
public ClusterHealthStatus waitForRelocation(ClusterHealthStatus status) {
|
||||
ClusterHealthRequest request = Requests.clusterHealthRequest().waitForRelocatingShards(0);
|
||||
if (status != null) {
|
||||
request.waitForStatus(status);
|
||||
}
|
||||
ClusterHealthResponse actionGet = client().admin().cluster()
|
||||
.health(request).actionGet();
|
||||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
if (status != null) {
|
||||
assertThat(actionGet.getStatus(), equalTo(status));
|
||||
}
|
||||
return actionGet.getStatus();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus ensureYellow() {
|
||||
ClusterHealthResponse actionGet = client().admin().cluster()
|
||||
.health(Requests.clusterHealthRequest().waitForYellowStatus().waitForEvents(Priority.LANGUID)).actionGet();
|
||||
|
@ -107,8 +107,9 @@ public class DocumentActionsTests extends AbstractSharedClusterTest {
|
||||
ClearIndicesCacheResponse clearIndicesCacheResponse = client().admin().indices().clearCache(clearIndicesCacheRequest("test").recycler(true).fieldDataCache(true).filterCache(true).idCache(true)).actionGet();
|
||||
assertNoFailures(clearIndicesCacheResponse);
|
||||
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(10));
|
||||
|
||||
|
||||
logger.info("Optimizing");
|
||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||
OptimizeResponse optimizeResponse = optimize();
|
||||
assertThat(optimizeResponse.getSuccessfulShards(), equalTo(10));
|
||||
|
||||
@ -279,9 +280,10 @@ public class DocumentActionsTests extends AbstractSharedClusterTest {
|
||||
assertThat(bulkResponse.getItems()[4].getIndex(), equalTo(getConcreteIndexName()));
|
||||
assertThat(bulkResponse.getItems()[4].getType(), equalTo("type1"));
|
||||
|
||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
|
||||
assertNoFailures(refreshResponse);
|
||||
assertThat(refreshResponse.getSuccessfulShards(), equalTo(10));
|
||||
assertThat(refreshResponse.getFailedShards(), equalTo(0));
|
||||
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
@ -179,12 +179,12 @@ public class IgnoreIndicesTests extends AbstractSharedClusterTest {
|
||||
@Test
|
||||
// For now don't handle closed indices
|
||||
public void testClosed() throws Exception {
|
||||
cluster().ensureAtLeastNumNodes(2);
|
||||
createIndex("test1", "test2");
|
||||
ensureYellow();
|
||||
ensureGreen();
|
||||
client().prepareSearch("test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
||||
client().admin().indices().prepareClose("test2").execute().actionGet();
|
||||
ensureYellow();
|
||||
|
||||
ensureGreen();
|
||||
try {
|
||||
client().prepareSearch("test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
||||
fail("Exception should have been thrown");
|
||||
|
Loading…
x
Reference in New Issue
Block a user