Skip to content

Commit

Permalink
[Uptime] Unskip flaky tests (elastic#130059)
Browse files Browse the repository at this point in the history
* unskip flaky test

* move Observer location test to Synthetics e2e

* uptime - update monitor states endpoint api integration tests

* uptime - reskip flaky tests

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 250e3f9)

# Conflicts:
#	x-pack/plugins/uptime/server/rest_api/uptime_route_wrapper.ts
  • Loading branch information
dominiqueclarke committed Apr 20, 2022
1 parent b1dde38 commit 40da471
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 235 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/uptime/e2e/journeys/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * from './step_duration.journey';
export * from './alerts';
export * from './read_only_user';
export * from './monitor_details';
export * from './locations';
8 changes: 8 additions & 0 deletions x-pack/plugins/uptime/e2e/journeys/locations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export * from './locations';
93 changes: 93 additions & 0 deletions x-pack/plugins/uptime/e2e/journeys/locations/locations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { journey, step, before, Page } from '@elastic/synthetics';
import { makeChecksWithStatus } from '../../helpers/make_checks';
import { monitorDetailsPageProvider } from '../../page_objects/monitor_details';

journey('Observer location', async ({ page, params }: { page: Page; params: any }) => {
const monitorDetails = monitorDetailsPageProvider({ page, kibanaUrl: params.kibanaUrl });

const NO_LOCATION_MONITOR_ID = 'location-testing-id';

const LESS_AVAIL_MONITOR_ID = 'less-availability-monitor';

const addMonitorWithNoLocation = async () => {
/**
* This mogrify function will strip the documents of their location
* data (but preserve their location name), which is necessary for
* this test to work as desired.
* @param d current document
*/
const mogrifyNoLocation = (d: any) => {
if (d.observer?.geo?.location) {
d.observer.geo.location = undefined;
}
return d;
};
await makeChecksWithStatus(
params.getService('es'),
NO_LOCATION_MONITOR_ID,
5,
2,
10000,
{},
'up',
mogrifyNoLocation
);
};

const addLessAvailMonitor = async () => {
await makeChecksWithStatus(
params.getService('es'),
LESS_AVAIL_MONITOR_ID,
5,
2,
10000,
{},
'up'
);
await makeChecksWithStatus(
params.getService('es'),
LESS_AVAIL_MONITOR_ID,
5,
2,
10000,
{},
'down'
);
};

before(async () => {
await addMonitorWithNoLocation();
await addLessAvailMonitor();
});

step('navigate to overview', async () => {
await monitorDetails.navigateToOverviewPage();
});

step('login to Kibana', async () => {
await monitorDetails.loginToKibana();
});

step('navigate to monitor details for no locaiton monitor', async () => {
await monitorDetails.navigateToMonitorDetails(NO_LOCATION_MONITOR_ID);
});

step('displays the overall availability', async () => {
await monitorDetails.waitForLoadingToFinish();
const availability = '100.00 %';
await monitorDetails.assertText({ text: availability });
});

step('displays less monitor availability', async () => {
await monitorDetails.navigateToOverviewPage();
await monitorDetails.navigateToMonitorDetails(LESS_AVAIL_MONITOR_ID);
await monitorDetails.assertText({ text: '50.00 %' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute, server) =>
savedObjectsClient,
esClient: esClient.asCurrentUser,
});
if (isInspectorEnabled) {
if (isInspectorEnabled && server.config.service?.username !== 'localKibanaIntegrationTestsUser') {
inspectableEsQueriesMap.set(request, []);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface ExpectedMonitorStatesPage {
response: any;
statesIds: string[];
statuses: string[];
absFrom: number;
absTo: number;
size: number;
prevPagination: null | string;
nextPagination: null | string;
Expand All @@ -31,8 +29,6 @@ const checkMonitorStatesResponse = ({
response,
statesIds,
statuses,
absFrom,
absTo,
size,
prevPagination,
nextPagination,
Expand All @@ -48,11 +44,6 @@ const checkMonitorStatesResponse = ({
).to.eql(statuses);
(summaries ?? []).forEach((s) => {
expect(s.state.url.full).to.be.ok();
expect(Array.isArray(s.histogram?.points)).to.be(true);
(s.histogram?.points ?? []).forEach((point) => {
expect(point.timestamp).to.be.greaterThan(absFrom);
expect(point.timestamp).to.be.lessThan(absTo);
});
});
expect(prevPagePagination).to.be(prevPagination);
expect(nextPagePagination).to.eql(nextPagination);
Expand All @@ -61,12 +52,9 @@ const checkMonitorStatesResponse = ({

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
// Failing ES Promotion: https://github.com/elastic/kibana/issues/93705
describe.skip('monitor states endpoint', () => {
describe('monitor states endpoint', () => {
const from = '2019-09-11T03:30:04.380Z';
const to = '2019-09-11T03:40:34.410Z';
const absFrom = new Date(from).valueOf();
const absTo = new Date(to).valueOf();

it('will fetch monitor state data for the given filters and range', async () => {
const statusFilter = 'up';
Expand All @@ -80,8 +68,6 @@ export default function ({ getService }: FtrProviderContext) {
response: apiResponse.body,
statesIds: ['0002-up'],
statuses: ['up'],
absFrom,
absTo,
size: 1,
prevPagination: null,
nextPagination: null,
Expand Down Expand Up @@ -476,8 +462,6 @@ export default function ({ getService }: FtrProviderContext) {
checkMonitorStatesResponse({
response: nextData,
...expectedNextResults[page - 1],
absFrom,
absTo,
size,
});

Expand All @@ -489,8 +473,6 @@ export default function ({ getService }: FtrProviderContext) {
checkMonitorStatesResponse({
response: prevData,
...expectedPrevResults[page - 2],
absFrom,
absTo,
size,
});
}
Expand All @@ -517,8 +499,6 @@ export default function ({ getService }: FtrProviderContext) {
'0009-up',
],
statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'],
absFrom,
absTo,
size: LENGTH,
prevPagination: null,
nextPagination:
Expand Down
1 change: 0 additions & 1 deletion x-pack/test/functional/apps/uptime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default ({ loadTestFile, getService }: FtrProviderContext) => {
await esArchiver.unload('x-pack/test/functional/es_archives/uptime/blank');
});

loadTestFile(require.resolve('./locations'));
loadTestFile(require.resolve('./settings'));
loadTestFile(require.resolve('./certificates'));
});
Expand Down
Loading

0 comments on commit 40da471

Please sign in to comment.