Skip to content

Commit

Permalink
ensure end field is actually set
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Apr 30, 2020
1 parent 0af086c commit 471fe08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
// mark now as start and end
eventLogger.startTiming(event);
eventLogger.stopTiming(event);
eventLogger.logEvent(event);
logger.info(`logged`);
return res.ok({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,20 @@ 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);
// stagger the API calls to ensure the creation order is as expected
for (let index = 0; index < expectedEvents.length; index++) {
await logTestEvent(id, expectedEvents[index]);
const expectedEvents: IEvent[] = [];
for (let index = 0; index < 6; index++) {
const event = fakeEvent(id);
await logTestEvent(id, event);
expectedEvents.push(event);
}

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());
});
});

Expand Down Expand Up @@ -177,7 +173,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);
});
Expand Down

0 comments on commit 471fe08

Please sign in to comment.