-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Allow skipping ranges of versions #50014
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
Conversation
Multiple version ranges are allowed to be used in section skip in yml tests. This is useful when a bugfix was backported to latest versions and all previous releases contain a wire breaking bug. examples: 6.1.0 - 6.3.0, 6.6.0 - 6.7.9, 7.0 - - 7.2, 8.0.0 -
|
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
| this.lowerVersion = versions[0]; | ||
| this.upperVersion = versions[1]; | ||
| this.versionRanges = parseVersionRanges(versionRange); | ||
| assert versionRanges.size() >= 1; |
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.
Would this be clearer?
| assert versionRanges.size() >= 1; | |
| assert versionRanges.isEmpty() == false; |
| && currentVersion.onOrBefore(upperVersion); | ||
| boolean skip = false; | ||
| for (VersionRange versionRange : versionRanges) { | ||
| skip |= versionRange.contain(currentVersion); |
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.
What about:
boolean skip = versionRanges.stream().anyMatch(range -> range.contain(currentVersion));
return skip || Features.areAllSupported(features) == false;| String[] ranges = rawRanges.split(","); | ||
| List<VersionRange> versionRanges = new ArrayList<>(); | ||
| for (String rawRange : ranges) { | ||
| String[] skipVersions = wrapWithSpaces(rawRange).split("-"); |
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.
I don't understand why wrapWithSpaces is necessary here?
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.
Ah, it's to ensure you get two elements in the skipVersions array. That's a little subtle.
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.
yes, definitely not needed.
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.
@pugnascotia ok so I see why I put that there. I wanted to allow formats like
8.0.0 - where there is no additional space. Also didn't want to make it a special case.
how about using "8.0.0 -".split("-",-1) ? -1 there means that the length of array element can have any element. With 0 it means that trailing empty element will not be returned
| return upper; | ||
| } | ||
|
|
||
| public boolean contain(Version currentVersion) { |
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.
...I don't suppose you'd rename this to contains? It's just that I'm so used to Collection.contains 😅
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.
it is a good idea, will do
| this.upper = upper; | ||
| } | ||
|
|
||
| public Version lower() { |
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.
Do we not usually use bean-style naming, i.e. getLower and getUpper?
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.
you are right, will fix
| --- | ||
| "Test Index and Search locale dependent mappings / dates": | ||
| - skip: | ||
| version: " - 6.1.99" |
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.
Is this redundant 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.
so in master I think it is not needed. The - 6.1.99 is translated into 7.0.0 - 6.1.99 And master runs bwc tests from 7.0 - 8 range
| boolean skip = lowerVersion != null && upperVersion != null && currentVersion.onOrAfter(lowerVersion) | ||
| && currentVersion.onOrBefore(upperVersion); | ||
| boolean skip = versionRanges.stream().anyMatch(range -> range.contains(currentVersion)); | ||
| skip |= Features.areAllSupported(features) == false; |
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.
Do you think it's worth changing this to the following?
return skip || Features.areAllSupported(features) == false;| lower.isEmpty() ? VersionUtils.getFirstVersion() : Version.fromString(lower), | ||
| upper.isEmpty() ? Version.CURRENT : Version.fromString(upper) | ||
| }; | ||
| private static String wrapWithSpaces(String rawRange) { |
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.
Can we remove this now?
Multiple version ranges are allowed to be used in section skip in yml tests. This is useful when a bugfix was backported to latest versions and all previous releases contain a wire breaking bug. examples: 6.1.0 - 6.3.0, 6.6.0 - 6.7.9, 7.0 - - 7.2, 8.0.0 -
Multiple version ranges are allowed to be used in section skip in yml tests. This is useful when a bugfix was backported to latest versions and all previous releases contain a wire breaking bug. examples: 6.1.0 - 6.3.0, 6.6.0 - 6.7.9, 7.0 - - 7.2, 8.0.0 - backport #50014
Multiple version ranges are allowed to be used in section skip in yml tests. This is useful when a bugfix was backported to latest versions and all previous releases contain a wire breaking bug. examples: 6.1.0 - 6.3.0, 6.6.0 - 6.7.9, 7.0 - - 7.2, 8.0.0 -
Multiple version ranges are allowed to be used in section skip in yml
tests. This is useful when a bugfix was backported to latest versions
and all previous releases contain a wire breaking bug.
examples:
6.1.0 - 6.3.0, 6.6.0 - 6.7.9, 7.0 -- 7.2, 8.0.0 -