From 2d547383397c8639a02b8dc0cd80f522c69ee620 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 21 Apr 2015 10:03:36 -0700 Subject: [PATCH] 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. closes #10702 --- .../test/cluster.put_settings/10_basic.yaml | 2 +- .../indices.put_settings/all_path_options.yaml | 2 +- rest-api-spec/test/update/85_fields_meta.yaml | 2 +- .../test/rest/section/SkipSection.java | 3 +++ .../test/rest/test/SkipSectionParserTests.java | 17 +++++++++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/rest-api-spec/test/cluster.put_settings/10_basic.yaml b/rest-api-spec/test/cluster.put_settings/10_basic.yaml index bb1256efecd..9955f4519d6 100644 --- a/rest-api-spec/test/cluster.put_settings/10_basic.yaml +++ b/rest-api-spec/test/cluster.put_settings/10_basic.yaml @@ -1,7 +1,7 @@ --- setup: - skip: - version: " - " + version: "all" reason: leaves transient metadata behind, need to fix it --- "Test put settings": diff --git a/rest-api-spec/test/indices.put_settings/all_path_options.yaml b/rest-api-spec/test/indices.put_settings/all_path_options.yaml index bd64d57ff17..07f1956f0fc 100644 --- a/rest-api-spec/test/indices.put_settings/all_path_options.yaml +++ b/rest-api-spec/test/indices.put_settings/all_path_options.yaml @@ -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: diff --git a/rest-api-spec/test/update/85_fields_meta.yaml b/rest-api-spec/test/update/85_fields_meta.yaml index ab38d5c1315..d10ac83f46b 100644 --- a/rest-api-spec/test/update/85_fields_meta.yaml +++ b/rest-api-spec/test/update/85_fields_meta.yaml @@ -2,7 +2,7 @@ "Metadata Fields": - skip: - version: " - " + version: "all" reason: "Update doesn't return metadata fields, waiting for #3259" - do: diff --git a/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java b/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java index bf8fe82a2c1..e7ab4555776 100644 --- a/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java +++ b/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java @@ -97,6 +97,9 @@ public class SkipSection { 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); diff --git a/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java b/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java index 5d940a10b56..1e71ae9181c 100644 --- a/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java +++ b/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java @@ -49,6 +49,23 @@ public class SkipSectionParserTests extends AbstractParserTests { 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(