Skip to content

Commit

Permalink
Fixes Failing test: Jest Integration Tests.x-pack/platform/plugins/sh…
Browse files Browse the repository at this point in the history
…ared/task_manager/server/integration_tests - unrecognized task types should be no workload aggregator errors when there are removed task types (elastic#210399)

Resolves elastic#208459

## Summary

The fix added in this
[PR](elastic#206598) to call the
`mark_removed_tasks_as_unrecognized` tasks sometimes throws an error if
the task is in the middle of running. This PR adds a try/catch and a
retry to the `runSoon` call.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 5500eab)
  • Loading branch information
ymao1 committed Feb 12, 2025
1 parent ccb00f4 commit bb8861f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jest.mock('../monitoring/workload_statistics', () => {
};
});

// FLAKY: https://github.com/elastic/kibana/issues/208459
describe.skip('unrecognized task types', () => {
describe('unrecognized task types', () => {
let esServer: TestElasticsearchUtils;
let kibanaServer: TestKibanaUtils;
let taskManagerPlugin: TaskManagerStartContract;
Expand Down Expand Up @@ -114,8 +113,16 @@ describe.skip('unrecognized task types', () => {
taskIdsToRemove.push(notRegisteredTypeId);

// To be sure that the background task that marks removed tasks as unrecognized has run after the tasks were created
const runSoonResponse = await taskManagerPlugin.runSoon('mark_removed_tasks_as_unrecognized');
expect(runSoonResponse).toEqual({ id: 'mark_removed_tasks_as_unrecognized' });
await retry(async () => {
try {
const runSoonResponse = await taskManagerPlugin.runSoon(
'mark_removed_tasks_as_unrecognized'
);
expect(runSoonResponse).toEqual({ id: 'mark_removed_tasks_as_unrecognized' });
} catch (err) {
// ignore errors and retry
}
});

await retry(async () => {
const task = await getTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser);
Expand Down

0 comments on commit bb8861f

Please sign in to comment.