Skip to content

Commit f0b850f

Browse files
authored
fixing SamplingServiceTests.testClusterChanged() (#136489)
This makes two fixes to SamplingServiceTests.testClusterChanged(): 1. It prevents the test from running when the random sampling feature is not present 2. It avoids an edge case where the index request is larger than the maximum size of the entire sample Closes #136450
1 parent e21e7b8 commit f0b850f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/test/java/org/elasticsearch/ingest/SamplingServiceTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public void testMaybeSampleMaxSize() {
261261
}
262262

263263
public void testClusterChanged() {
264+
assumeTrue("Requires sampling feature flag", RANDOM_SAMPLING_FEATURE_FLAG);
264265
String indexName = randomIdentifier();
265266
SamplingService samplingService = getTestSamplingService();
266267
Map<String, Object> inputRawDocSource = randomMap(1, 100, () -> Tuple.tuple(randomAlphaOfLength(10), randomAlphaOfLength(10)));
@@ -276,7 +277,7 @@ public void testClusterChanged() {
276277
new SamplingConfiguration(
277278
1.0,
278279
randomIntBetween(1, 1000),
279-
ByteSizeValue.ofBytes(randomLongBetween(100, 1000000)),
280+
ByteSizeValue.ofBytes(randomLongBetween(indexRequest.source().length(), 1_000_000)),
280281
TimeValue.timeValueDays(randomIntBetween(1, 10)),
281282
null
282283
)
@@ -316,7 +317,7 @@ public void testClusterChanged() {
316317
new SamplingConfiguration(
317318
1.0,
318319
1001,
319-
ByteSizeValue.ofBytes(randomLongBetween(100, 1000000)),
320+
ByteSizeValue.ofBytes(randomLongBetween(indexRequest.source().length(), 1_000_000)),
320321
TimeValue.timeValueDays(randomIntBetween(1, 10)),
321322
null
322323
)

0 commit comments

Comments
 (0)