[TEST] added debug info to GeoBoundsTests to try to solve build issue

This commit is contained in:
Colin Goodheart-Smithe 2014-09-08 10:50:25 +01:00
parent aadbfa44b4
commit 12ca36574e
1 changed files with 17 additions and 2 deletions

View File

@ -24,10 +24,13 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.util.BigArray; import org.elasticsearch.common.util.BigArray;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds; import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsAggregator; import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsAggregator;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test; import org.junit.Test;
@ -142,9 +145,21 @@ public class GeoBoundsTests extends ElasticsearchIntegrationTest {
.field("tag", "tag" + i) .field("tag", "tag" + i)
.endObject())); .endObject()));
} }
indexRandom(true, builders); indexRandom(true, builders);
ensureSearchable(); ensureSearchable();
// Added to debug a test failure (Dev issue #266) where the terms aggregation seems to be reporting two documents with the same value for NUMBER_FIELD_NAME. This will chaeck that after
// random indexing each document only has 1 value for NUMBER_FIELD_NAME and it is the correct value
SearchResponse response = client().prepareSearch("high_card_idx").addField(NUMBER_FIELD_NAME).addSort(SortBuilders.fieldSort(NUMBER_FIELD_NAME).order(SortOrder.ASC)).setSize(5000).get();
assertSearchResponse(response);
assertThat(response.getHits().totalHits(), equalTo(2000l));
for (int i = 0; i < 2000; i++) {
SearchHitField hitField = response.getHits().getAt(i).field(NUMBER_FIELD_NAME);
assertThat("Hit " + i + " has wrong number of values", hitField.getValues().size(), equalTo(1));
Integer value = hitField.getValue();
assertThat("Hit " + i + " has wrong value", value, equalTo(i));
}
} }
private void updateBoundsBottomRight(GeoPoint geoPoint, GeoPoint currentBound) { private void updateBoundsBottomRight(GeoPoint geoPoint, GeoPoint currentBound) {
@ -335,7 +350,7 @@ public class GeoBoundsTests extends ElasticsearchIntegrationTest {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Bucket bucket = buckets.get(i); Bucket bucket = buckets.get(i);
assertThat(bucket, notNullValue()); assertThat(bucket, notNullValue());
assertThat(bucket.getDocCount(), equalTo(1l)); assertThat("Bucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1l));
GeoBounds geoBounds = bucket.getAggregations().get("geoBounds"); GeoBounds geoBounds = bucket.getAggregations().get("geoBounds");
assertThat(geoBounds, notNullValue()); assertThat(geoBounds, notNullValue());
assertThat(geoBounds.getName(), equalTo("geoBounds")); assertThat(geoBounds.getName(), equalTo("geoBounds"));