diff --git a/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts b/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts index 9622715e87e55f..d7fe8dd0dedf3d 100644 --- a/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts +++ b/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts @@ -42,6 +42,9 @@ export const logEventRoute = (router: IRouter, eventLogger: IEventLogger, logger await context.core.savedObjects.client.create('event_log_test', {}, { id }); logger.info(`created saved object ${id}`); } + // mark now as start and end + eventLogger.startTiming(event); + eventLogger.stopTiming(event); eventLogger.logEvent(event); logger.info(`logged`); return res.ok({}); diff --git a/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts b/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts index f3a3d58336b1db..a2ae1659863402 100644 --- a/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts +++ b/x-pack/test/plugin_api_integration/test_suites/event_log/public_api_integration.ts @@ -19,9 +19,7 @@ export default function({ getService }: FtrProviderContext) { const log = getService('log'); const retry = getService('retry'); - // FLAKY: https://github.com/elastic/kibana/issues/64723 - // FLAKY: https://github.com/elastic/kibana/issues/64812 - describe.skip('Event Log public API', () => { + describe('Event Log public API', () => { it('should allow querying for events by Saved Object', async () => { const id = uuid.v4(); @@ -82,21 +80,15 @@ export default function({ getService }: FtrProviderContext) { it('should support sorting by event end', async () => { const id = uuid.v4(); - const [firstExpectedEvent, ...expectedEvents] = times(6, () => fakeEvent(id)); - // run one first to create the SO and avoid clashes - await logTestEvent(id, firstExpectedEvent); - await Promise.all(expectedEvents.map(event => logTestEvent(id, event))); + const expectedEvents = await logFakeEvents(id, 6); await retry.try(async () => { const { body: { data: foundEvents }, } = await findEvents(id, { sort_field: 'event.end', sort_order: 'desc' }); - expect(foundEvents.length).to.be(6); - assertEventsFromApiMatchCreatedEvents( - foundEvents, - [firstExpectedEvent, ...expectedEvents].reverse() - ); + expect(foundEvents.length).to.be(expectedEvents.length); + assertEventsFromApiMatchCreatedEvents(foundEvents, expectedEvents.reverse()); }); }); @@ -112,8 +104,7 @@ export default function({ getService }: FtrProviderContext) { const start = new Date().toISOString(); // write the documents that we should be found in the date range searches - const expectedEvents = times(6, () => fakeEvent(id)); - await Promise.all(expectedEvents.map(event => logTestEvent(id, event))); + const expectedEvents = await logFakeEvents(id, 6); // get the end time for the date range search const end = new Date().toISOString(); @@ -176,7 +167,9 @@ export default function({ getService }: FtrProviderContext) { ) { try { foundEvents.forEach((foundEvent: IValidatedEvent, index: number) => { - expect(foundEvent!.event).to.eql(expectedEvents[index]!.event); + expect(omit(foundEvent!.event ?? {}, 'start', 'end', 'duration')).to.eql( + expectedEvents[index]!.event + ); expect(omit(foundEvent!.kibana ?? {}, 'server_uuid')).to.eql(expectedEvents[index]!.kibana); expect(foundEvent!.message).to.eql(expectedEvents[index]!.message); }); @@ -217,4 +210,14 @@ export default function({ getService }: FtrProviderContext) { overrides ); } + + async function logFakeEvents(savedObjectId: string, eventsToLog: number): Promise { + const expectedEvents: IEvent[] = []; + for (let index = 0; index < eventsToLog; index++) { + const event = fakeEvent(savedObjectId); + await logTestEvent(savedObjectId, event); + expectedEvents.push(event); + } + return expectedEvents; + } }