From 05245098a1b1d7af9a5da84ddfd87467eff36508 Mon Sep 17 00:00:00 2001 From: Mike Cote Date: Mon, 20 Mar 2023 17:17:29 -0400 Subject: [PATCH] Fix failing test --- .../task_manager/task_management.ts | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts index 6cc68282ac1dac..acf21f68612ada 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts @@ -563,12 +563,12 @@ export default function ({ getService }: FtrProviderContext) { params: { throwOnMarkAsRunning: true }, }); - await delay(DEFAULT_POLL_INTERVAL * 3); + expect(originalTask.attempts).to.eql(0); + // Wait for task manager to attempt running the task a second time await retry.try(async () => { const task = await currentTask(originalTask.id); - expect(task.attempts).to.eql(3); - expect(task.status).to.eql('failed'); + expect(task.attempts).to.eql(2); }); }); @@ -769,17 +769,15 @@ export default function ({ getService }: FtrProviderContext) { }); }); - it('should mark non-recurring task as failed if task is still running but maxAttempts has been reached', async () => { - const task = await scheduleTask({ + it('should flag non-recurring task as failed and delete the task if it is still running but maxAttempts has been reached', async () => { + await scheduleTask({ taskType: 'sampleOneTimeTaskThrowingError', params: {}, }); await retry.try(async () => { - const [scheduledTask] = (await currentTasks()).docs; - expect(scheduledTask.id).to.eql(task.id); - expect(scheduledTask.status).to.eql('failed'); - expect(scheduledTask.attempts).to.eql(3); + const results = (await currentTasks()).docs; + expect(results.length).to.eql(0); }); }); @@ -894,38 +892,6 @@ export default function ({ getService }: FtrProviderContext) { }); }); - it('should allow a failed task to be rerun using runSoon', async () => { - const taskThatFailsBeforeRunNow = await scheduleTask({ - taskType: 'singleAttemptSampleTask', - params: { - waitForParams: true, - }, - }); - // tell the task to fail on its next run - await provideParamsToTasksWaitingForParams(taskThatFailsBeforeRunNow.id, { - failWith: 'error on first run', - }); - - // wait for task to fail - await retry.try(async () => { - const tasks = (await currentTasks()).docs; - expect(getTaskById(tasks, taskThatFailsBeforeRunNow.id).status).to.eql('failed'); - }); - - // run the task again - await runTaskSoon({ - id: taskThatFailsBeforeRunNow.id, - }); - - // runTaskSoon should successfully update the runAt property of the task - await retry.try(async () => { - const tasks = (await currentTasks()).docs; - expect( - Date.parse(getTaskById(tasks, taskThatFailsBeforeRunNow.id).runAt) - ).to.be.greaterThan(Date.parse(taskThatFailsBeforeRunNow.runAt)); - }); - }); - // TODO: Add this back in with https://github.com/elastic/kibana/issues/106139 // it('should return the resulting task state when asked to run an ephemeral task now', async () => { // const ephemeralTask = await runEphemeralTaskNow({