stabelize more tests

This commit is contained in:
Simon Willnauer 2013-06-12 13:25:26 +02:00
parent c449fbdd68
commit cb0cf3167c
3 changed files with 8 additions and 13 deletions

View File

@ -274,8 +274,6 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
@Test
public void multiNested() throws Exception {
client().admin().indices().prepareDelete().execute().actionGet();
client().admin().indices().prepareCreate("test")
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("nested1")
@ -285,8 +283,7 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
.endObject().endObject().endObject())
.execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder()
.startObject()
.field("field", "value")
@ -297,10 +294,10 @@ public class SimpleNestedTests extends AbstractSharedClusterTest {
.endObject()).execute().actionGet();
// flush, so we fetch it from the index (as see that we filter nested docs)
client().admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
flush();
GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet();
assertThat(getResponse.isExists(), equalTo(true));
waitForRelocation(ClusterHealthStatus.GREEN);
// check the numDocs
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(7l));

View File

@ -406,7 +406,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest {
assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0));
assertThat(searchResponse.getHits().totalHits(), equalTo(4l));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("1"), equalTo("3"))); // could be both depending on the order of the docs internally (lucene order)
assertThat(searchResponse.getHits().getAt(0).score(), equalTo(5.0f));
logger.info("--> Hit[0] {} Explanation {}", searchResponse.getHits().getAt(0).id(), searchResponse.getHits().getAt(0).explanation());

View File

@ -905,19 +905,17 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.endObject().endObject()
.endObject().endObject().endObject())
.execute().actionGet();
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
waitForRelocation();
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource("title", "this is a test").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
refresh();
// simple search on body with standard analyzer with a simple field query
SearchResponse search = client().prepareSearch()
.setQuery(fieldQuery("title", "this is a test"))
.setHighlighterEncoder("html")
.addHighlightedField("title", 50, 1)
.execute().actionGet();
assertThat(Arrays.toString(search.getShardFailures()), search.getFailedShards(), equalTo(0));
SearchHit hit = search.getHits().getAt(0);
assertThat(hit.highlightFields().get("title").fragments()[0].string(), equalTo("this is a <em>test</em>"));