Fixes Failing test: Jest Integration Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests - unrecognized task types should be no workload aggregator errors when there are removed task types (#210399)

Resolves https://github.com/elastic/kibana/issues/208459

## Summary

The fix added in this
[PR](https://github.com/elastic/kibana/pull/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>
This commit is contained in:
Ying Mao 2025-02-12 09:30:38 -05:00 committed by GitHub
parent 6c257ab50c
commit 5500eab90c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
@ -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);