Skip to content

Commit

Permalink
Tests: Add shortcut "all" to skip version ranges in rest tests
Browse files Browse the repository at this point in the history
This was suggested on elastic#10656 as cleaner than " - " to indicate all
versions should be skipped.

closes elastic#10702
  • Loading branch information
rjernst committed Apr 22, 2015
1 parent a4f98e7 commit 2d54738
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rest-api-spec/test/cluster.put_settings/10_basic.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
setup:
- skip:
version: " - "
version: "all"
reason: leaves transient metadata behind, need to fix it
---
"Test put settings":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ setup:
---
"put settings in list of indices":
- skip:
version: " - "
version: "all"
reason: list of indices not implemented yet
- do:
indices.put_settings:
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/test/update/85_fields_meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Metadata Fields":

- skip:
version: " - "
version: "all"
reason: "Update doesn't return metadata fields, waiting for #3259"

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ private Version[] parseVersionRange(String versionRange) {
if (versionRange == null) {
return new Version[] { null, null };
}
if (versionRange.trim().equals("all")) {
return new Version[]{VersionUtils.getFirstVersion(), Version.CURRENT};
}
String[] skipVersions = versionRange.split("-");
if (skipVersions.length > 2) {
throw new IllegalArgumentException("version range malformed: " + versionRange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ public void testParseSkipSectionVersionNoFeature() throws Exception {
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
}

public void testParseSkipSectionAllVersions() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
"version: \" all \"\n" +
"reason: Delete ignores the parent param"
);

SkipSectionParser skipSectionParser = new SkipSectionParser();

SkipSection skipSection = skipSectionParser.parse(new RestTestSuiteParseContext("api", "suite", parser));

assertThat(skipSection, notNullValue());
assertThat(skipSection.getLowerVersion(), equalTo(VersionUtils.getFirstVersion()));
assertThat(skipSection.getUpperVersion(), equalTo(Version.CURRENT));
assertThat(skipSection.getFeatures().size(), equalTo(0));
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
}

@Test
public void testParseSkipSectionFeatureNoVersion() throws Exception {
parser = YamlXContent.yamlXContent.createParser(
Expand Down

0 comments on commit 2d54738

Please sign in to comment.