Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,6 @@ tests:
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
method: test
issue: https://github.com/elastic/elasticsearch/issues/135787
- class: org.elasticsearch.ingest.SamplingServiceTests
method: testMaybeSampleWithLowRate
issue: https://github.com/elastic/elasticsearch/issues/135808
- class: org.elasticsearch.ingest.SamplingServiceTests
method: testMaybeSample
issue: https://github.com/elastic/elasticsearch/issues/135809
- class: org.elasticsearch.ingest.SamplingServiceTests
method: testMaybeSampleWithCondition
issue: https://github.com/elastic/elasticsearch/issues/135810
- class: org.elasticsearch.ingest.SamplingServiceTests
method: testMaybeSampleMaxSamples
issue: https://github.com/elastic/elasticsearch/issues/135811
- class: org.elasticsearch.xpack.esql.expression.function.aggregate.IrateTests
method: testGroupingAggregate {TestCase=<positive ints>}
issue: https://github.com/elastic/elasticsearch/issues/135814
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public List<RawDocument> getLocalSample(ProjectId projectId, String index) {
*/
public SampleStats getLocalSampleStats(ProjectId projectId, String index) {
SoftReference<SampleInfo> sampleInfoReference = samples.get(new ProjectIndex(projectId, index));
if (sampleInfoReference == null) {
return new SampleStats();
}
SampleInfo sampleInfo = sampleInfoReference.get();
return sampleInfo == null ? new SampleStats() : sampleInfo.stats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@
import java.util.List;
import java.util.Map;

import static org.elasticsearch.ingest.SamplingService.RANDOM_SAMPLING_FEATURE_FLAG;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assume.assumeTrue;

public class SamplingServiceTests extends ESTestCase {

private static final String TEST_CONDITIONAL_SCRIPT = "ctx?.foo == 'bar'";

public void testMaybeSample() {
assumeTrue("Requires sampling feature flag", RANDOM_SAMPLING_FEATURE_FLAG);
SamplingService samplingService = getTestSamplingService();

// First, test with a project that has no sampling config:
Expand Down Expand Up @@ -101,6 +104,7 @@ public void testMaybeSample() {
}

public void testMaybeSampleWithCondition() {
assumeTrue("Requires sampling feature flag", RANDOM_SAMPLING_FEATURE_FLAG);
SamplingService samplingService = getTestSamplingService();
String indexName = randomIdentifier();
ProjectMetadata.Builder projectBuilder = ProjectMetadata.builder(ProjectId.DEFAULT)
Expand Down Expand Up @@ -147,6 +151,7 @@ public void testMaybeSampleWithCondition() {
}

public void testMaybeSampleWithLowRate() {
assumeTrue("Requires sampling feature flag", RANDOM_SAMPLING_FEATURE_FLAG);
SamplingService samplingService = getTestSamplingService();
String indexName = randomIdentifier();
ProjectMetadata.Builder projectBuilder = ProjectMetadata.builder(ProjectId.DEFAULT)
Expand Down Expand Up @@ -185,6 +190,7 @@ public void testMaybeSampleWithLowRate() {
}

public void testMaybeSampleMaxSamples() {
assumeTrue("Requires sampling feature flag", RANDOM_SAMPLING_FEATURE_FLAG);
SamplingService samplingService = getTestSamplingService();
String indexName = randomIdentifier();
int maxSamples = randomIntBetween(1, 1000);
Expand Down