Skip to content

Commit

Permalink
Fix random sampler consistency test (#107957)
Browse files Browse the repository at this point in the history
Random sampler consistency requires a restricted number of segments, to
ensure we always hit the same number of segments and that no merging is
occurring, this merges the segment count to 1 for this particular test. 

In practice, this isn't needed as the approximate nature of the
aggregation already means you could get different statistics per call,
but they are within an error bound set by the users configured sampling
probability.

closes: #105839
  • Loading branch information
benwtrent committed May 10, 2024
1 parent 5a824c5 commit ef12b99
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@

import static org.elasticsearch.search.aggregations.AggregationBuilders.avg;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -83,9 +84,11 @@ public void setupSuiteScopeCluster() throws Exception {
}
indexRandom(true, builders);
ensureSearchable();
// Force merge to ensure segment consistency as any segment merging can change which particular documents
// are sampled
assertNoFailures(indicesAdmin().prepareForceMerge("idx").setMaxNumSegments(1).get());
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/105839")
public void testRandomSamplerConsistentSeed() {
double[] sampleMonotonicValue = new double[1];
double[] sampleNumericValue = new double[1];
Expand Down

0 comments on commit ef12b99

Please sign in to comment.