diff --git a/x-pack/plugins/task_manager/server/integration_tests/managed_configuration.test.ts b/x-pack/plugins/task_manager/server/integration_tests/managed_configuration.test.ts index e243d55363a57..aa945c74d71ff 100644 --- a/x-pack/plugins/task_manager/server/integration_tests/managed_configuration.test.ts +++ b/x-pack/plugins/task_manager/server/integration_tests/managed_configuration.test.ts @@ -13,8 +13,7 @@ import { TaskManagerPlugin, TaskManagerStartContract } from '../plugin'; import { coreMock } from '@kbn/core/server/mocks'; import { TaskManagerConfig } from '../config'; -// FAILING: https://github.com/elastic/kibana/issues/120269 -describe.skip('managed configuration', () => { +describe('managed configuration', () => { let taskManagerStart: TaskManagerStartContract; let logger: Logger; @@ -22,6 +21,19 @@ describe.skip('managed configuration', () => { const savedObjectsClient = savedObjectsRepositoryMock.create(); const esStart = elasticsearchServiceMock.createStart(); + const inlineScriptError = new Error('cannot execute [inline] scripts" error') as Error & { + meta: unknown; + }; + inlineScriptError.meta = { + body: { + error: { + caused_by: { + reason: 'cannot execute [inline] scripts', + }, + }, + }, + }; + beforeEach(async () => { jest.resetAllMocks(); clock = sinon.useFakeTimers(); @@ -132,16 +144,12 @@ describe.skip('managed configuration', () => { }); test('should lower max workers when Elasticsearch returns "cannot execute [inline] scripts" error', async () => { - esStart - .createClient('taskManager') - .asInternalUser.search.mockRejectedValueOnce( - elasticsearchServiceMock.createErrorTransportRequestPromise( - new Error('cannot execute [inline] scripts" error') - ) - ); + esStart.client.asInternalUser.search.mockImplementationOnce(async () => { + throw inlineScriptError; + }); await expect(taskManagerStart.fetch({})).rejects.toThrowErrorMatchingInlineSnapshot( - `"cannot execute [inline] scripts" error"` + `"cannot execute [inline] scripts\\" error"` ); clock.tick(ADJUST_THROUGHPUT_INTERVAL); @@ -155,16 +163,12 @@ describe.skip('managed configuration', () => { }); test('should increase poll interval when Elasticsearch returns "cannot execute [inline] scripts" error', async () => { - esStart - .createClient('taskManager') - .asInternalUser.search.mockRejectedValueOnce( - elasticsearchServiceMock.createErrorTransportRequestPromise( - new Error('cannot execute [inline] scripts" error') - ) - ); + esStart.client.asInternalUser.search.mockImplementationOnce(async () => { + throw inlineScriptError; + }); await expect(taskManagerStart.fetch({})).rejects.toThrowErrorMatchingInlineSnapshot( - `"cannot execute [inline] scripts" error"` + `"cannot execute [inline] scripts\\" error"` ); clock.tick(ADJUST_THROUGHPUT_INTERVAL);