-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix byte size value equals/hash code test #29643
Fix byte size value equals/hash code test #29643
Conversation
This commit fixes two issues with the byte size value equals/hash code test. The first problem is due to a test failure when the original instance is zero bytes and we pick the mutation branch where we preserve the size but change the unit. The mutation should result in a different byte size value but changing the unit on zero bytes still leaves us with zero bytes. During the course of fixing this test I discovered another problem. When we need to randomize size, we could randomly select a size that would lead to an overflow of Long.MAX_VALUE. This commit fixes both of these issues.
if (instanceSize == 0 || instanceSize >= Long.MAX_VALUE / newUnitBytes) { | ||
mutateSize = randomValueOtherThanMany( | ||
v -> v == instanceSize && v >= Long.MAX_VALUE / newUnitBytes, () -> randomNonNegativeLong() / newUnitBytes); | ||
} else { |
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.
The crux of the change is this if
block. I added a condition that we need to randomize size of the input size is zero (otherwise we would end up with zero bytes equals zero bytes but the mutation is suppose to have a different value). Additionally, I added a condition to not randomly select a value whose bytes representation would exceed Long.MAX_VALUE
.
run the sample packaging tests |
I should mention, this is the reproduction that fails prior to this fix and passes now:
|
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.
LGTM
Pinging @elastic/es-core-infra |
This commit fixes two issues with the byte size value equals/hash code test. The first problem is due to a test failure when the original instance is zero bytes and we pick the mutation branch where we preserve the size but change the unit. The mutation should result in a different byte size value but changing the unit on zero bytes still leaves us with zero bytes. During the course of fixing this test I discovered another problem. When we need to randomize size, we could randomly select a size that would lead to an overflow of Long.MAX_VALUE. This commit fixes both of these issues.
This commit fixes two issues with the byte size value equals/hash code test. The first problem is due to a test failure when the original instance is zero bytes and we pick the mutation branch where we preserve the size but change the unit. The mutation should result in a different byte size value but changing the unit on zero bytes still leaves us with zero bytes. During the course of fixing this test I discovered another problem. When we need to randomize size, we could randomly select a size that would lead to an overflow of Long.MAX_VALUE. This commit fixes both of these issues.
This commit fixes two issues with the byte size value equals/hash code test. The first problem is due to a test failure when the original instance is zero bytes and we pick the mutation branch where we preserve the size but change the unit. The mutation should result in a different byte size value but changing the unit on zero bytes still leaves us with zero bytes. During the course of fixing this test I discovered another problem. When we need to randomize size, we could randomly select a size that would lead to an overflow of Long.MAX_VALUE. This commit fixes both of these issues.
* master: [Test] Fix docs check for DEB package in packaging tests (elastic#30126) Painless: Docs Clean Up (elastic#29592) Fixes Eclipse build for sql jdbc project (elastic#30114) Remove reference to `not_analyzed`. [Docs] Add community analysis plugin (elastic#29612) Remove the suggest metric from stats APIs (elastic#29635) Fix byte size value equals/hash code test (elastic#29643) Upgrade to Gradle 4.7 (elastic#29644)
* master: [Test] Fix docs check for DEB package in packaging tests (elastic#30126) Painless: Docs Clean Up (elastic#29592) Fixes Eclipse build for sql jdbc project (elastic#30114) Remove reference to `not_analyzed`. [Docs] Add community analysis plugin (elastic#29612) Remove the suggest metric from stats APIs (elastic#29635) Fix byte size value equals/hash code test (elastic#29643) Upgrade to Gradle 4.7 (elastic#29644)
This commit fixes two issues with the byte size value equals/hash code test.
The first problem is due to a test failure when the original instance is zero bytes and we pick the mutation branch where we preserve the size but change the unit. The mutation should result in a different byte size value but changing the unit on zero bytes still leaves us with zero bytes.
During the course of fixing this test I discovered another problem. When we need to randomize size, we could randomly select a size that would lead to an overflow of Long.MAX_VALUE.
This commit fixes both of these issues.