From 434b84bf7c2a8e618ed25bbff13d786fd3121a62 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 28 May 2019 09:26:17 -0400 Subject: [PATCH] --test_seconds option --- config.js | 2 ++ libs/Task.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/config.js b/config.js index 36b4968..95b6beb 100644 --- a/config.js +++ b/config.js @@ -39,6 +39,7 @@ Options: --test_skip_dems If test mode is enabled, skip dems results when generating assets. (default: false) --test_drop_uploads If test mode is enabled, drop /task/new/upload requests with 50% probability. (default: false) --test_fail_tasks If test mode is enabled, mark tasks as failed. (default: false) + --test_seconds If test mode is enabled, sleep these many seconds before finishing processing a test task. (default: 0) --powercycle When set, the application exits immediately after powering up. Useful for testing launch and compilation issues. --token Sets a token that needs to be passed for every request. This can be used to limit access to the node only to token holders. (default: none) --max_images Specify the maximum number of images that this processing node supports. (default: unlimited) @@ -99,6 +100,7 @@ config.testSkipOrthophotos = argv.test_skip_orthophotos || fromConfigFile("testS config.testSkipDems = argv.test_skip_dems || fromConfigFile("testSkipDems", false); config.testDropUploads = argv.test_drop_uploads || fromConfigFile("testDropUploads", false); config.testFailTasks = argv.test_fail_tasks || fromConfigFile("testFailTasks", false); +config.testSeconds = parseInt(argv.test_seconds || fromConfigFile("testSeconds", 0)); config.powercycle = argv.powercycle || fromConfigFile("powercycle", false); config.token = argv.token || fromConfigFile("token", ""); config.maxImages = parseInt(argv.max_images || fromConfigFile("maxImages", "")) || null; diff --git a/libs/Task.js b/libs/Task.js index 0021879..7f6fbe5 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -367,10 +367,16 @@ module.exports = class Task{ }); } + if (config.testSeconds){ + logger.info(`Test mode will sleep for ${config.testSeconds} seconds before finishing processing`); + tasks.push(done => setTimeout(done, config.testSeconds * 1000)); + } + if (config.testFailTasks){ logger.info("Test mode will fail the task"); tasks.push(done => done(new Error("Test fail"))); } + } if (!this.skipPostProcessing) tasks.push(runPostProcessingScript());