Skip to content

Commit d91fd35

Browse files
committed
Tests: Add shortcut "all" to skip version ranges in rest tests
This was suggested on #10656 as cleaner than " - " to indicate all versions should be skipped.
1 parent daa25d1 commit d91fd35

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

rest-api-spec/test/cluster.put_settings/10_basic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
setup:
33
- skip:
4-
version: " - "
4+
version: "all"
55
reason: leaves transient metadata behind, need to fix it
66
---
77
"Test put settings":

rest-api-spec/test/indices.put_settings/all_path_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ setup:
8181
---
8282
"put settings in list of indices":
8383
- skip:
84-
version: " - "
84+
version: "all"
8585
reason: list of indices not implemented yet
8686
- do:
8787
indices.put_settings:

rest-api-spec/test/update/85_fields_meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Metadata Fields":
33

44
- skip:
5-
version: " - "
5+
version: "all"
66
reason: "Update doesn't return metadata fields, waiting for #3259"
77

88
- do:

src/test/java/org/elasticsearch/test/rest/section/SkipSection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ private Version[] parseVersionRange(String versionRange) {
9797
if (versionRange == null) {
9898
return new Version[] { null, null };
9999
}
100+
if (versionRange.trim().equals("all")) {
101+
return new Version[]{VersionUtils.getFirstVersion(), Version.CURRENT};
102+
}
100103
String[] skipVersions = versionRange.split("-");
101104
if (skipVersions.length > 2) {
102105
throw new IllegalArgumentException("version range malformed: " + versionRange);

src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ public void testParseSkipSectionVersionNoFeature() throws Exception {
4949
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
5050
}
5151

52+
public void testParseSkipSectionAllVersions() throws Exception {
53+
parser = YamlXContent.yamlXContent.createParser(
54+
"version: \" all \"\n" +
55+
"reason: Delete ignores the parent param"
56+
);
57+
58+
SkipSectionParser skipSectionParser = new SkipSectionParser();
59+
60+
SkipSection skipSection = skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));
61+
62+
assertThat(skipSection, notNullValue());
63+
assertThat(skipSection.getLowerVersion(), equalTo(VersionUtils.getFirstVersion()));
64+
assertThat(skipSection.getUpperVersion(), equalTo(Version.CURRENT));
65+
assertThat(skipSection.getFeatures().size(), equalTo(0));
66+
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
67+
}
68+
5269
@Test
5370
public void testParseSkipSectionFeatureNoVersion() throws Exception {
5471
parser = YamlXContent.yamlXContent.createParser(

0 commit comments

Comments
 (0)