Fix byte size value equals/hash code test#29643
Merged
jasontedor merged 2 commits intoelastic:masterfrom Apr 24, 2018
Merged
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.
jasontedor
commented
Apr 20, 2018
| if (instanceSize == 0 || instanceSize >= Long.MAX_VALUE / newUnitBytes) { | ||
| mutateSize = randomValueOtherThanMany( | ||
| v -> v == instanceSize && v >= Long.MAX_VALUE / newUnitBytes, () -> randomNonNegativeLong() / newUnitBytes); | ||
| } else { |
Member
Author
There was a problem hiding this comment.
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.
Member
Author
|
run the sample packaging tests |
Member
Author
|
I should mention, this is the reproduction that fails prior to this fix and passes now: |
Collaborator
|
Pinging @elastic/es-core-infra |
jasontedor
added a commit
that referenced
this pull request
Apr 24, 2018
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.
jasontedor
added a commit
that referenced
this pull request
Apr 24, 2018
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.
jasontedor
added a commit
that referenced
this pull request
Apr 24, 2018
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.
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Apr 25, 2018
* 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)
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Apr 25, 2018
* 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 file contains hidden or 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
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.
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.