Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void testMaybeSampleMaxSize() {
);
final ProjectId projectId = projectBuilder.getId();
ProjectMetadata projectMetadata = projectBuilder.build();
final IndexRequest indexRequest = new IndexRequest(indexName).id("_id").source(randomByteArrayOfLength(150), XContentType.JSON);
final IndexRequest indexRequest = new IndexRequest(indexName).id("_id").source(randomAsciiByteArrayOfLength(150), XContentType.JSON);
for (int i = 0; i < maxSamples; i++) {
samplingService.maybeSample(projectMetadata, indexRequest);
}
Expand Down Expand Up @@ -353,4 +353,15 @@ private SamplingService getTestSamplingService() {
final ProjectResolver projectResolver = TestProjectResolvers.singleProject(projectId);
return new SamplingService(scriptService, clusterService, projectResolver, System::currentTimeMillis);
}

/*
* Returns an array containing random bytes that correspond to valid ascii characters
*/
private static byte[] randomAsciiByteArrayOfLength(int size) {
byte[] bytes = new byte[size];
for (int i = 0; i < size; i++) {
bytes[i] = (byte) randomIntBetween(0, 127);
}
return bytes;
}
}