From 387b5524095254efd215a662f0e98c63a5eeaee4 Mon Sep 17 00:00:00 2001 From: Daniel Hermon Date: Sat, 26 Dec 2020 18:47:48 +0200 Subject: [PATCH] fix(runner): stop runner if test time exceeds the duration given (#53) --- app/app.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/app.js b/app/app.js index e23304f1..2ce91283 100644 --- a/app/app.js +++ b/app/app.js @@ -11,6 +11,8 @@ const runner = require('./models/runner'), errorHandler = require('./handler/errorHandler'), { version: PREDATOR_RUNNER_VERSION } = require('../package.json'); +const RUNNER_TIMEOUT_GRACE_MS = 300; + const getContainerId = () => { let containerId = uuid(); if (process.env.MARATHON_APP_ID) { @@ -45,7 +47,18 @@ let start = async () => { }); process.exit(1); }); + process.on('SIGUSR1', async function() { + logger.info('Runner exceeded test duration, sending DONE status and existing'); + await reporterConnector.postStats(jobConfig, { + phase_status: 'done', + data: JSON.stringify({ message: 'Test Finished' }) + }); + process.exit(1); + }); verifyPredatorVersion(); + setTimeout(function() { + process.kill(process.pid, 'SIGUSR1'); + }, (jobConfig.duration * 1000) + jobConfig.delayRunnerMs + RUNNER_TIMEOUT_GRACE_MS); await runner.runTest(jobConfig); logger.info('Finished running test successfully'); process.exit(0);