From 82a34c4d21b7153b278d1b247858a72048e4606d Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 21 Dec 2016 10:12:24 -0800 Subject: [PATCH] concourse: Add support docs and tests for 'attempts' attribute --- .../vscode/concourse/PipelineYmlSchema.java | 4 ++++ .../src/main/resources/desc/Step/attempts.md | 19 +++++++++++++++++++ .../concourse/PipelineYamlEditorTest.java | 11 ++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Step/attempts.md diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java index fbbfedd88..d5d9a0bd5 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -45,6 +45,9 @@ public class PipelineYmlSchema implements YamlSchema { YAtomicType t_boolean = f.yenum("boolean", "true", "false"); YAtomicType t_pos_integer = f.yatomic("Positive Integer"); t_pos_integer.parseWith(ValueParsers.POS_INTEGER); + YAtomicType t_strictly_pos_integer = f.yatomic("Strictly Positive Integer"); + t_strictly_pos_integer.parseWith(ValueParsers.integerAtLeast(1)); + YType t_any = f.yany("Object"); YType t_params = f.ymap(t_string, t_any); YType t_string_params = f.ymap(t_string, t_string); @@ -130,6 +133,7 @@ public class PipelineYmlSchema implements YamlSchema { // shared properties applicable for any type of Step: prop(step, "on_success", step); prop(step, "on_failure", step); + prop(step, "attempts", t_strictly_pos_integer); YBeanType resource = f.ybean("Resource"); prop(resource, "name", t_ne_string); diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Step/attempts.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Step/attempts.md new file mode 100644 index 000000000..a1c033c08 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Step/attempts.md @@ -0,0 +1,19 @@ +Retry a step: + +Any step can set the number of times it should be attempted by attaching an `attempts` parameter with the number of times it should be tried. + + attempts: integer + +The total number of times a step should be tried should it fail, e.g. `5` will try the step up to 5 times before giving up. + +When the number of attempts is reached and the step has still not succeeded then the step will fail. + +Attempts will retry on a Concourse error as well as build failure. + +The following will run the task, and retry it 9 times (for a total of 10 attempts) if it fails: + + plan: + - get: foo + - task: unit + file: foo/unit.yml + attempts: 10 \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java index c4a0de784..585f0a6dc 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java @@ -182,6 +182,7 @@ public class PipelineYamlEditorTest { " params:\n" + " some_param: some_value\n" + " trigger: true\n" + + " attempts: 10\n" + " on_failure:\n" + " - bogus: bad\n" + " on_success:\n" + @@ -191,10 +192,11 @@ public class PipelineYamlEditorTest { editor.assertHoverContains("version", "The version of the resource to fetch"); editor.assertHoverContains("params", "A map of arbitrary configuration"); editor.assertHoverContains("trigger", "Set to `true` to auto-trigger"); + editor.assertHoverContains("attempts", "Any step can set the number of times it should be attempted"); editor.assertHoverContains("on_failure", "Any step can have `on_failure` tacked onto it"); editor.assertHoverContains("on_success", "Any step can have `on_success` tacked onto it"); } - + @Test public void taskStepHovers() throws Exception { Editor editor = harness.newEditor( @@ -212,6 +214,7 @@ public class PipelineYamlEditorTest { " output_mapping:\n" + " map: of-stuff\n" + " config: some-config\n" + + " attempts: 10\n" + " ensure:\n" + " bogus: bad\n" + " on_failure:\n" + @@ -255,13 +258,15 @@ public class PipelineYamlEditorTest { " max_in_flight: -1\n" + " plan:\n" + " - get: git\n" + - " trigger: yohoho" + " trigger: yohoho\n" + + " attempts: 0\n" ); editor.assertProblems( "boohoo|boolean", "-1|must be positive", "git|resource does not exist", - "yohoho|boolean" + "yohoho|boolean", + "0|must be at least 1" ); //check that correct values are indeed accepted