Skip to content

Commit

Permalink
Merge branch 'main' into rcs2-reload
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Dec 7, 2023
2 parents d8307a5 + a245fdc commit 4cf9b4c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,8 @@ private RangeMissingHandler writerWithOffset(RangeMissingHandler writer, CacheFi
return (channel, channelPos, relativePos, len, progressUpdater) -> {
assert assertValidRegionAndLength(fileRegion, channelPos, len);
adjustedWriter.fillCacheRange(channel, channelPos, relativePos, len, progressUpdater);
assert regionOwners.get(fileRegion.io) == fileRegion
: "File chunk [" + fileRegion.regionKey + "] no longer owns IO [" + fileRegion.io + "]";
};
}
return adjustedWriter;
Expand All @@ -932,7 +934,10 @@ private RangeAvailableHandler readerWithOffset(RangeAvailableHandler reader, Cac
if (Assertions.ENABLED) {
return (channel, channelPos, relativePos, len) -> {
assert assertValidRegionAndLength(fileRegion, channelPos, len);
return adjustedReader.onRangeAvailable(channel, channelPos, relativePos, len);
final int bytesRead = adjustedReader.onRangeAvailable(channel, channelPos, relativePos, len);
assert regionOwners.get(fileRegion.io) == fileRegion
: "File chunk [" + fileRegion.regionKey + "] no longer owns IO [" + fileRegion.io + "]";
return bytesRead;
};
}
return adjustedReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,15 @@ public ActionRequestValidationException validate() {
validationException
);
}
// we don't do downsampling when a custom index is provided
if (sampleSize != null) {
validationException = addValidationError(
"[" + SAMPLE_SIZE_FIELD.getPreferredName() + "] must not be set",
validationException
);
}
} else {
if (stackTraceIds != null) {
validationException = addValidationError(
"[" + STACKTRACE_IDS_FIELD.getPreferredName() + "] must not be set",
validationException
);
}
validationException = requirePositive(SAMPLE_SIZE_FIELD, sampleSize, validationException);
}
validationException = requirePositive(SAMPLE_SIZE_FIELD, sampleSize, validationException);
validationException = requirePositive(REQUESTED_DURATION_FIELD, requestedDuration, validationException);
validationException = requirePositive(AWS_COST_FACTOR_FIELD, awsCostFactor, validationException);
validationException = requirePositive(CUSTOM_CO2_PER_KWH, customCO2PerKWH, validationException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ public void testValidateWrongSampleSize() {
assertTrue(validationErrors.get(0).contains("[sample_size] must be greater than 0,"));
}

public void testValidateSampleSizeIsValidWithCustomIndices() {
GetStackTracesRequest request = new GetStackTracesRequest(
10,
1.0d,
1.0d,
null,
randomAlphaOfLength(7),
randomAlphaOfLength(3),
null,
null,
null,
null,
null
);
assertNull("Expecting no validation errors", request.validate());
}

public void testValidateStacktraceWithoutIndices() {
GetStackTracesRequest request = new GetStackTracesRequest(
1,
Expand Down

0 comments on commit 4cf9b4c

Please sign in to comment.