Skip to content

Commit 0bed668

Browse files
authored
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.
1 parent 0ab2afb commit 0bed668

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestFeatureService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ public boolean clusterHasFeature(String featureId, boolean any) {
9595
Matcher matcher = VERSION_FEATURE_PATTERN.matcher(featureId);
9696
if (matcher.matches()) {
9797
Version extractedVersion = Version.fromString(matcher.group(1));
98+
if (extractedVersion.after(Version.CURRENT)) {
99+
throw new IllegalArgumentException(
100+
Strings.format(
101+
"Cannot use a synthetic feature [%s] for a version after the current version [%s]",
102+
featureId,
103+
Version.CURRENT
104+
)
105+
);
106+
}
107+
108+
if (extractedVersion.equals(Version.CURRENT)) {
109+
throw new IllegalArgumentException(
110+
Strings.format(
111+
"Cannot use a synthetic feature [%s] for the current version [%s]; "
112+
+ "please define a test cluster feature alongside the corresponding code change instead",
113+
featureId,
114+
Version.CURRENT
115+
)
116+
);
117+
}
118+
98119
return checkCollection(nodeVersions, v -> v.onOrAfter(extractedVersion), any);
99120
}
100121

0 commit comments

Comments
 (0)