Stabelize more failing tests.
- SimpleSortTests#testSortScript which was not using the mapping correctly - SearchStatsTests#testSimpleStats which didn't clear the stats before running the test and a previous run could have added queries
This commit is contained in:
parent
85f54edf66
commit
4ff471ff82
|
@ -148,7 +148,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
|||
for (String name : names) {
|
||||
try {
|
||||
prepareCreate(name).setSettings(getSettings()).execute().actionGet();
|
||||
return;
|
||||
continue;
|
||||
} catch (IndexAlreadyExistsException ex) {
|
||||
wipeIndex(name);
|
||||
}
|
||||
|
@ -236,6 +236,13 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
|
|||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
return actionGet.getStatus();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus ensureYellow() {
|
||||
ClusterHealthResponse actionGet = client().admin().cluster()
|
||||
.health(Requests.clusterHealthRequest().waitForYellowStatus().waitForEvents(Priority.LANGUID)).actionGet();
|
||||
assertThat(actionGet.isTimedOut(), equalTo(false));
|
||||
return actionGet.getStatus();
|
||||
}
|
||||
|
||||
public static String commaString(Iterable<String> strings) {
|
||||
return Joiner.on(',').join(strings);
|
||||
|
|
|
@ -179,20 +179,11 @@ public class IgnoreIndicesTests extends AbstractSharedClusterTest {
|
|||
@Test
|
||||
// For now don't handle closed indices
|
||||
public void testClosed() throws Exception {
|
||||
client().admin().indices().prepareDelete().execute().actionGet();
|
||||
|
||||
client().admin().indices().prepareCreate("test1").execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test2").execute().actionGet();
|
||||
|
||||
ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
|
||||
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
|
||||
|
||||
createIndex("test1", "test2");
|
||||
ensureYellow();
|
||||
client().prepareSearch("test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
||||
|
||||
client().admin().indices().prepareClose("test2").execute().actionGet();
|
||||
|
||||
clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
|
||||
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
|
||||
ensureYellow();
|
||||
|
||||
try {
|
||||
client().prepareSearch("test1", "test2").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.elasticsearch.common.Priority;
|
|||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
|
@ -526,31 +527,18 @@ public class SimpleSortTests extends AbstractSharedClusterTest {
|
|||
|
||||
@Test
|
||||
public void testSortScript() throws IOException {
|
||||
String mapping = jsonBuilder().startObject().startObject("profile").field("dynamic", "strict")
|
||||
.startObject("properties")
|
||||
.startObject("id").field("type", "integer").field("index", "not_analyzed").field("store", true).endObject()
|
||||
.startObject("groups_code").startObject("properties").field("type", "integer").field("index", "not_analyzed").endObject().endObject()
|
||||
.startObject("date").field("type", "date").field("index", "not_analyzed").field("format", "date_time_no_millis").endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
prepareCreate("test")
|
||||
.setSettings(randomSettingsBuilder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0)).addMapping("test", mapping);
|
||||
createIndexMapped("test", "test", "value", "string");
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "test", "1").setSource(jsonBuilder().startObject()
|
||||
.startArray("groups_code").startObject().field("id", 47642).field("date", "2010-08-12T07:54:55Z").endObject().endArray()
|
||||
.endObject()).execute().actionGet();
|
||||
client().prepareIndex("test", "test", "2").setSource(jsonBuilder().startObject()
|
||||
.startArray("groups_code").startObject().field("id", 47642).field("date", "2010-05-04T12:10:54Z").endObject().endArray()
|
||||
.endObject()).execute().actionGet();
|
||||
client().admin().indices().prepareRefresh("test").execute().actionGet();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
client().prepareIndex("test", "test", "1").setSource(jsonBuilder().startObject()
|
||||
.field("value", "" + i).endObject()).execute().actionGet();
|
||||
}
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch()
|
||||
.setQuery(matchAllQuery())
|
||||
.addSort(SortBuilders.scriptSort("\u0027\u0027", "string")).setSize(10)
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -52,6 +52,8 @@ public class SearchStatsTests extends AbstractSharedClusterTest {
|
|||
|
||||
@Test
|
||||
public void testSimpleStats() throws Exception {
|
||||
// clear all stats first
|
||||
client().admin().indices().prepareStats().clear().execute().actionGet();
|
||||
createIndex("test1");
|
||||
for (int i = 0; i < 500; i++) {
|
||||
client().prepareIndex("test1", "type", Integer.toString(i)).setSource("field", "value").execute().actionGet();
|
||||
|
|
Loading…
Reference in New Issue