diff --git a/src/jobs/models/jobManager.js b/src/jobs/models/jobManager.js index b2682735..ca4a6097 100644 --- a/src/jobs/models/jobManager.js +++ b/src/jobs/models/jobManager.js @@ -38,7 +38,7 @@ module.exports.reloadCronJobs = async () => { const configData = await configHandler.getConfig(); try { const jobs = await databaseConnector.getJobs(contextId); - jobs.forEach(function (job) { + jobs.forEach(async function (job) { if (job.cron_expression !== null) { addCron(job, job.cron_expression, configData); } diff --git a/tests/unit-tests/jobs/models/jobManager-test.js b/tests/unit-tests/jobs/models/jobManager-test.js index 793c0c4d..6418a7ae 100644 --- a/tests/unit-tests/jobs/models/jobManager-test.js +++ b/tests/unit-tests/jobs/models/jobManager-test.js @@ -175,7 +175,7 @@ describe('Manager jobs', function () { describe('Reload job experiments', function () { it('found future experiments to reload', async () => { - const timestamp = 7200000; + const timestamp = 500; const jobExperiment = { start_time: timestamp, job_id: '1234', experiment_id: '4321', id: '2468' }; const chaosExperiment = { kubeObject: { hello: 1 }, experiment_id: '4321' }; getFutureJobExperimentsStub.resolves([jobExperiment]); @@ -183,10 +183,9 @@ describe('Manager jobs', function () { runChaosExperimentStub.returns(); const clock = sinon.useFakeTimers(); - const promise = manager.reloadChaosExperiments(); - clock.tick(3600000); - await promise; - clock.tick(3600010); + clock.tick(1000); + await manager.reloadChaosExperiments(); + clock.tick(3000); sinon.assert.calledOnce(runChaosExperimentStub); sinon.assert.calledWith(runChaosExperimentStub, chaosExperiment.kubeObject); clock.restore();