From fb27f98b8c07ee59d084bfc6fc17e9c207df7426 Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Wed, 28 Feb 2018 14:14:41 -0800 Subject: [PATCH 1/2] Fix #147 `jobs unschedule` disables execution --- .../rundeck/client/tool/commands/Jobs.java | 2 +- .../client/tool/commands/JobsSpec.groovy | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rundeck/client/tool/commands/Jobs.java b/src/main/java/org/rundeck/client/tool/commands/Jobs.java index 5a347d64..e6f408c2 100644 --- a/src/main/java/org/rundeck/client/tool/commands/Jobs.java +++ b/src/main/java/org/rundeck/client/tool/commands/Jobs.java @@ -328,7 +328,7 @@ public boolean reschedule(EnableSchedOpts options, CommandOutput output) throws @Command(description = "Disable schedule for a job") public boolean unschedule(DisableSchedOpts options, CommandOutput output) throws IOException, InputError { - return simpleJobApiCall(RundeckApi::jobExecutionDisable, options, output, "Disabled Schedule for Job %s"); + return simpleJobApiCall(RundeckApi::jobScheduleDisable, options, output, "Disabled Schedule for Job %s"); } private boolean simpleJobApiCall( diff --git a/src/test/groovy/org/rundeck/client/tool/commands/JobsSpec.groovy b/src/test/groovy/org/rundeck/client/tool/commands/JobsSpec.groovy index d7ed15ec..7d9cf8c1 100644 --- a/src/test/groovy/org/rundeck/client/tool/commands/JobsSpec.groovy +++ b/src/test/groovy/org/rundeck/client/tool/commands/JobsSpec.groovy @@ -118,6 +118,60 @@ class JobsSpec extends Specification { null | null | 'a' | 'b/c' } + @Unroll + def "jobs #action behavior"() { + given: + def api = Mock(RundeckApi) + def deets = [ + enable : [ + opt : Jobs.EnableOpts, + call: "jobExecutionEnable" + ], + + disable : [ + opt : Jobs.DisableOpts, + call: "jobExecutionDisable" + ], + + reschedule: [ + opt : Jobs.EnableSchedOpts, + call: "jobScheduleEnable" + ], + + unschedule: [ + opt : Jobs.DisableSchedOpts, + call: "jobScheduleDisable" + ] + ] + Class optClass = deets[action].opt + def apiCall = deets[action].call + def opts = Mock(optClass) { + isId() >> true + getId() >> '123' + getProject() >> 'testProj' + } + def retrofit = new Retrofit.Builder().baseUrl('http://example.com/fake/').build() + def client = new Client(api, retrofit, null, null, 17, true, null) + def hasclient = Mock(RdApp) { + getClient() >> client + } + Jobs jobs = new Jobs(hasclient) + def out = Mock(CommandOutput) + when: + jobs."$action"(opts, out) + + then: + 1 * api."$apiCall"('123') >> Calls.response(new Simple(success: true)) + 0 * api._(*_) + + where: + action | _ + 'enable' | _ + 'disable' | _ + 'unschedule' | _ + 'reschedule' | _ + } + @Unroll def "job purge with job #job group #group jobexact #jobexact groupexact #groupexact"() { From 759c5bd7b71fc285519b1a19a6da90f3ffe0ad7f Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Wed, 28 Feb 2018 14:15:45 -0800 Subject: [PATCH 2/2] Fix usage text for jbos reschedule/unschedule --- src/main/java/org/rundeck/client/tool/commands/Jobs.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/rundeck/client/tool/commands/Jobs.java b/src/main/java/org/rundeck/client/tool/commands/Jobs.java index e6f408c2..3fc0bfeb 100644 --- a/src/main/java/org/rundeck/client/tool/commands/Jobs.java +++ b/src/main/java/org/rundeck/client/tool/commands/Jobs.java @@ -315,7 +315,7 @@ public boolean disable(DisableOpts options, CommandOutput output) throws IOExcep return simpleJobApiCall(RundeckApi::jobExecutionDisable, options, output, "Disabled Job %s"); } - @CommandLineInterface(application = "enableSchedule") interface EnableSchedOpts extends ToggleOpts { + @CommandLineInterface(application = "reschedule") interface EnableSchedOpts extends ToggleOpts { } @Command(description = "Enable schedule for a job") @@ -323,7 +323,7 @@ public boolean reschedule(EnableSchedOpts options, CommandOutput output) throws return simpleJobApiCall(RundeckApi::jobScheduleEnable, options, output, "Enabled Schedule for Job %s"); } - @CommandLineInterface(application = "disableSchedule") interface DisableSchedOpts extends ToggleOpts { + @CommandLineInterface(application = "unschedule") interface DisableSchedOpts extends ToggleOpts { } @Command(description = "Disable schedule for a job")