[TEST] Fix SimpleQueryTests.testRangeQuery assumptions.

This test assumed that the `num` field was mapped as an integer on all shards
and thus that all of them should fail when providing a timezone. However, since
it used dynamic mappings, some shards might have this field not mapped, as a
consequence they didn't fail.
This commit is contained in:
Adrien Grand 2014-08-11 13:57:33 +02:00
parent 36083cb27f
commit 1210b08ecb
1 changed files with 20 additions and 20 deletions

View File

@ -2348,16 +2348,17 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
@Test
public void testRangeFilterWithTimeZone() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "date", "type=date"));
.addMapping("type1", "date", "type=date", "num", "type=integer"));
ensureGreen();
index("test", "type1", "1", "date", "2014-01-01", "num", 1);
index("test", "type1", "2", "date", "2013-12-31T23:00:00", "num", 2);
index("test", "type1", "3", "date", "2014-01-01T01:00:00", "num", 3);
indexRandom(true,
client().prepareIndex("test", "type1", "1").setSource("date", "2014-01-01", "num", 1),
client().prepareIndex("test", "type1", "2").setSource("date", "2013-12-31T23:00:00", "num", 2),
client().prepareIndex("test", "type1", "3").setSource("date", "2014-01-01T01:00:00", "num", 3),
// Now in UTC+1
index("test", "type1", "4", "date", DateTime.now(DateTimeZone.forOffsetHours(1)).getMillis(), "num", 4);
client().prepareIndex("test", "type1", "4").setSource("date", DateTime.now(DateTimeZone.forOffsetHours(1)).getMillis(), "num", 4));
refresh();
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(QueryBuilders.filteredQuery(matchAllQuery(), FilterBuilders.rangeFilter("date").from("2014-01-01T00:00:00").to("2014-01-01T00:59:00")))
@ -2445,16 +2446,15 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
@Test
public void testRangeQueryWithTimeZone() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type1", "date", "type=date"));
.addMapping("type1", "date", "type=date", "num", "type=integer"));
ensureGreen();
index("test", "type1", "1", "date", "2014-01-01", "num", 1);
index("test", "type1", "2", "date", "2013-12-31T23:00:00", "num", 2);
index("test", "type1", "3", "date", "2014-01-01T01:00:00", "num", 3);
indexRandom(true,
client().prepareIndex("test", "type1", "1").setSource("date", "2014-01-01", "num", 1),
client().prepareIndex("test", "type1", "2").setSource("date", "2013-12-31T23:00:00", "num", 2),
client().prepareIndex("test", "type1", "3").setSource("date", "2014-01-01T01:00:00", "num", 3),
// Now in UTC+1
index("test", "type1", "4", "date", DateTime.now(DateTimeZone.forOffsetHours(1)).getMillis(), "num", 4);
refresh();
client().prepareIndex("test", "type1", "4").setSource("date", DateTime.now(DateTimeZone.forOffsetHours(1)).getMillis(), "num", 4));
// Ensure all shards have our mappings, otherwise we can sometimes fail to hit the expected exceptions below, because some shards
// will succeed in running a query (that returns 0 hits) instead of throwing the expected exception: