Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Mar 20, 2023
1 parent b530399 commit 0524509
Showing 1 changed file with 7 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 0524509

Please sign in to comment.