Tests: Add test case from #11692

This commit is contained in:
Adrien Grand 2015-06-16 10:34:51 +02:00
parent 2bc033d786
commit cdd13253de
1 changed files with 11 additions and 2 deletions

View File

@ -56,6 +56,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.notNullValue;
@ -97,10 +98,10 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest {
@Override @Override
public void setupSuiteScopeCluster() throws Exception { public void setupSuiteScopeCluster() throws Exception {
createIndex("idx"); assertAcked(prepareCreate("idx").addMapping("type", "_timestamp", "enabled=true"));
createIndex("idx_unmapped"); createIndex("idx_unmapped");
// TODO: would be nice to have more random data here // TODO: would be nice to have more random data here
prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").execute().actionGet(); assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer"));
List<IndexRequestBuilder> builders = new ArrayList<>(); List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
builders.add(client().prepareIndex("empty_bucket_idx", "type", ""+i).setSource(jsonBuilder() builders.add(client().prepareIndex("empty_bucket_idx", "type", ""+i).setSource(jsonBuilder()
@ -1314,4 +1315,12 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest {
assertThat(e.toString(), containsString("ElasticsearchParseException")); assertThat(e.toString(), containsString("ElasticsearchParseException"));
} }
} }
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/pull/11482")
public void testTimestampField() {
SearchResponse response = client().prepareSearch("idx").addAggregation(dateHistogram("histo").field("_timestamp").interval(randomFrom(DateHistogramInterval.DAY, DateHistogramInterval.MONTH))).get();
assertSearchResponse(response);
Histogram histo = response.getAggregations().get("histo");
assertThat(histo.getBuckets().size(), greaterThan(0));
}
} }