-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed flaky circuitBreaker unit test. #893
Merged
nhtruong
merged 4 commits into
opensearch-project:main
from
nhtruong:fix_flaky_circuit_breakter_test
Oct 31, 2024
Merged
Fixed flaky circuitBreaker unit test. #893
nhtruong
merged 4 commits into
opensearch-project:main
from
nhtruong:fix_flaky_circuit_breakter_test
Oct 31, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Theo Truong <[email protected]>
Signed-off-by: Theo Truong <[email protected]>
nhtruong
requested review from
ananzh,
kavilla,
dblock,
VachaShah,
harshavamsi and
timursaurus
as code owners
October 30, 2024 19:52
Signed-off-by: Theo Truong <[email protected]>
nhtruong
commented
Oct 30, 2024
Comment on lines
-1044
to
-1060
const contentLength = buffer.constants.MAX_STRING_LENGTH - 1; | ||
const percentage = 0.01; | ||
const HEAP_SIZE_LIMIT = require('v8').getHeapStatistics().heap_size_limit; | ||
const contentLength = Math.round(HEAP_SIZE_LIMIT * percentage + 1); | ||
const memoryCircuitBreaker = { | ||
enabled: true, | ||
maxPercentage: percentage, | ||
}; | ||
// Simulate allocation of bytes | ||
const memoryAllocations = []; | ||
while (process.memoryUsage().heapUsed + contentLength <= HEAP_SIZE_LIMIT_WITH_BUFFER) { | ||
const allocation = 50 * 1024 * 1024; // 50MB | ||
const numbers = allocation / 8; | ||
const arr = []; | ||
arr.length = numbers; | ||
for (let i = 0; i < numbers; i++) { | ||
arr[i] = i; | ||
} | ||
memoryAllocations.push(arr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this block of code because memoryAllocations
is not being used anywhere.
dblock
approved these changes
Oct 30, 2024
dblock
reviewed
Oct 30, 2024
Signed-off-by: Theo Truong <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's the actual code in Transport.js:
However the current unit test sets the contentLength off of
MAX_STRING_LENGTH
instead ofHEAP_SIZE_LIMIT
. This results in the test failing on earlier versions of node.js whereheapUsed
is smaller and doesn't causecontentLength + heapUsed > HEAP_SIZE_LIMIT * maxPercentage
to return true.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.