From 4cccb695aff2089a53c0d1d480d7c84dc5d7d26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Mon, 18 Apr 2022 11:46:12 -0400 Subject: [PATCH] Unskip managed configuration integration test (#130331) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../managed_configuration.test.ts | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) 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);