Block use of current version feature in yaml tests (#112737)

Using the current version as a condition is not compatible with Serverless, as the version doesn't change between commits. Cluster features should be used instead.
This commit is contained in:
Simon Cooper 2024-09-12 09:55:23 +01:00 committed by GitHub
parent 0ab2afb395
commit 0bed668a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 0 deletions

View File

@ -95,6 +95,27 @@ class ESRestTestFeatureService implements TestFeatureService {
Matcher matcher = VERSION_FEATURE_PATTERN.matcher(featureId);
if (matcher.matches()) {
Version extractedVersion = Version.fromString(matcher.group(1));
if (extractedVersion.after(Version.CURRENT)) {
throw new IllegalArgumentException(
Strings.format(
"Cannot use a synthetic feature [%s] for a version after the current version [%s]",
featureId,
Version.CURRENT
)
);
}
if (extractedVersion.equals(Version.CURRENT)) {
throw new IllegalArgumentException(
Strings.format(
"Cannot use a synthetic feature [%s] for the current version [%s]; "
+ "please define a test cluster feature alongside the corresponding code change instead",
featureId,
Version.CURRENT
)
);
}
return checkCollection(nodeVersions, v -> v.onOrAfter(extractedVersion), any);
}