From de5d12362d008d8cec9be63c27821ae638ea4456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 20 Jun 2022 11:44:41 +0200 Subject: [PATCH] Manager: add `sleep_repeats` parameter to `echo-sleep-test` job type This makes it convenient to create an arbitrary number of tasks. --- .../job_compilers/scripts/echo_sleep_test.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/manager/job_compilers/scripts/echo_sleep_test.js b/internal/manager/job_compilers/scripts/echo_sleep_test.js index 12056704..ee20a9d1 100644 --- a/internal/manager/job_compilers/scripts/echo_sleep_test.js +++ b/internal/manager/job_compilers/scripts/echo_sleep_test.js @@ -25,6 +25,7 @@ const JOB_TYPE = { settings: [ { key: "message", type: "string", required: true }, { key: "sleep_duration_seconds", type: "int32", default: 1 }, + { key: "sleep_repeats", type: "int32", default: 1 }, ] }; @@ -34,11 +35,12 @@ function compileJob(job) { const echoTask = author.Task("echo", "misc"); echoTask.addCommand(author.Command("echo", {message: settings.message})); - - const sleepTask = author.Task("sleep", "misc") - sleepTask.addCommand(author.Command("sleep", {duration_in_seconds: settings.sleep_duration_seconds})) - sleepTask.addDependency(echoTask); // Ensure sleeping happens after echo, and not at the same time. - job.addTask(echoTask); - job.addTask(sleepTask); + + for (let repeat=0; repeat < settings.sleep_repeats; repeat++) { + const sleepTask = author.Task("sleep", "misc") + sleepTask.addCommand(author.Command("sleep", {duration_in_seconds: settings.sleep_duration_seconds})) + sleepTask.addDependency(echoTask); // Ensure sleeping happens after echo, and not at the same time. + job.addTask(sleepTask); + } }