Skip to content

Commit 12ca365

Browse files
committed
[TEST] added debug info to GeoBoundsTests to try to solve build issue
1 parent aadbfa4 commit 12ca365

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsTests.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
import org.elasticsearch.common.geo.GeoPoint;
2525
import org.elasticsearch.common.settings.ImmutableSettings;
2626
import org.elasticsearch.common.util.BigArray;
27+
import org.elasticsearch.search.SearchHitField;
2728
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
2829
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
2930
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;
3031
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsAggregator;
32+
import org.elasticsearch.search.sort.SortBuilders;
33+
import org.elasticsearch.search.sort.SortOrder;
3134
import org.elasticsearch.test.ElasticsearchIntegrationTest;
3235
import org.junit.Test;
3336

@@ -142,9 +145,21 @@ public void setupSuiteScopeCluster() throws Exception {
142145
.field("tag", "tag" + i)
143146
.endObject()));
144147
}
145-
148+
146149
indexRandom(true, builders);
147150
ensureSearchable();
151+
152+
// 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
153+
// random indexing each document only has 1 value for NUMBER_FIELD_NAME and it is the correct value
154+
SearchResponse response = client().prepareSearch("high_card_idx").addField(NUMBER_FIELD_NAME).addSort(SortBuilders.fieldSort(NUMBER_FIELD_NAME).order(SortOrder.ASC)).setSize(5000).get();
155+
assertSearchResponse(response);
156+
assertThat(response.getHits().totalHits(), equalTo(2000l));
157+
for (int i = 0; i < 2000; i++) {
158+
SearchHitField hitField = response.getHits().getAt(i).field(NUMBER_FIELD_NAME);
159+
assertThat("Hit " + i + " has wrong number of values", hitField.getValues().size(), equalTo(1));
160+
Integer value = hitField.getValue();
161+
assertThat("Hit " + i + " has wrong value", value, equalTo(i));
162+
}
148163
}
149164

150165
private void updateBoundsBottomRight(GeoPoint geoPoint, GeoPoint currentBound) {
@@ -335,7 +350,7 @@ public void singleValuedFieldAsSubAggToHighCardTermsAgg() {
335350
for (int i = 0; i < 10; i++) {
336351
Bucket bucket = buckets.get(i);
337352
assertThat(bucket, notNullValue());
338-
assertThat(bucket.getDocCount(), equalTo(1l));
353+
assertThat("Bucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1l));
339354
GeoBounds geoBounds = bucket.getAggregations().get("geoBounds");
340355
assertThat(geoBounds, notNullValue());
341356
assertThat(geoBounds.getName(), equalTo("geoBounds"));

0 commit comments

Comments
 (0)