Allow skipping ranges of versions#50014
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.
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.
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.
I don't understand why wrapWithSpaces is necessary here?
There was a problem hiding this comment.
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.
yes, definitely not needed.
There was a problem hiding this comment.
@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.
...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.
it is a good idea, will do
| this.upper = upper; | ||
| } | ||
|
|
||
| public Version lower() { |
There was a problem hiding this comment.
Do we not usually use bean-style naming, i.e. getLower and getUpper?
There was a problem hiding this comment.
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.
Is this redundant now?
There was a problem hiding this comment.
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.
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.
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 -