Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Task Manager's managed configuration integration jest test #130331

Merged
merged 2 commits into from
Apr 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,27 @@ 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;

let clock: sinon.SinonFakeTimers;
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();
Expand Down Expand Up @@ -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);

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