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

[EventLog] Use performance.now() rather than Date.now() to calculate elapsed time in tests #158721

Merged
merged 3 commits into from
Jun 1, 2023
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
15 changes: 7 additions & 8 deletions x-pack/plugins/event_log/server/es/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ describe('parseIndexAliases', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/156061
describe.skip('retries', () => {
describe('retries', () => {
let esContext = contextMock.create();
// set up context APIs to return defaults indicating already created
beforeEach(() => {
Expand All @@ -472,9 +471,9 @@ describe.skip('retries', () => {
test('createIlmPolicyIfNotExists with 1 retry', async () => {
esContext.esAdapter.doesIlmPolicyExist.mockRejectedValueOnce(new Error('retry 1'));

const timeStart = Date.now();
const timeStart = performance.now();
await initializeEs(esContext);
const timeElapsed = Date.now() - timeStart;
const timeElapsed = performance.now() - timeStart;

expect(timeElapsed).toBeGreaterThanOrEqual(MOCK_RETRY_DELAY);

Expand All @@ -492,9 +491,9 @@ describe.skip('retries', () => {
esContext.esAdapter.doesIndexTemplateExist.mockRejectedValueOnce(new Error('retry 2a'));
esContext.esAdapter.doesIndexTemplateExist.mockRejectedValueOnce(new Error('retry 2b'));

const timeStart = Date.now();
const timeStart = performance.now();
await initializeEs(esContext);
const timeElapsed = Date.now() - timeStart;
const timeElapsed = performance.now() - timeStart;

expect(timeElapsed).toBeGreaterThanOrEqual(MOCK_RETRY_DELAY * (1 + 2));

Expand All @@ -518,9 +517,9 @@ describe.skip('retries', () => {
// make sure it only tries 5 times - this one should not be reported
esContext.esAdapter.doesAliasExist.mockRejectedValueOnce(new Error('retry 5f'));

const timeStart = Date.now();
const timeStart = performance.now();
await initializeEs(esContext);
const timeElapsed = Date.now() - timeStart;
const timeElapsed = performance.now() - timeStart;

expect(timeElapsed).toBeGreaterThanOrEqual(MOCK_RETRY_DELAY * (1 + 2 + 4 + 8));

Expand Down