From 250e3f982e585d6831fdbe9d0d7adf81360241f3 Mon Sep 17 00:00:00 2001 From: Dominique Clarke Date: Tue, 19 Apr 2022 12:10:19 -0400 Subject: [PATCH] [Uptime] Unskip flaky tests (#130059) * 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 <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/uptime/e2e/journeys/index.ts | 1 + .../uptime/e2e/journeys/locations/index.ts | 8 ++ .../e2e/journeys/locations/locations.ts | 93 +++++++++++++ .../server/rest_api/uptime_route_wrapper.ts | 5 +- .../monitor_states_real_data.snap | 122 +++--------------- .../uptime/rest/monitor_states_real_data.ts | 22 +--- x-pack/test/functional/apps/uptime/index.ts | 1 - .../test/functional/apps/uptime/locations.ts | 83 ------------ .../functional/services/uptime/monitor.ts | 19 --- .../apps/uptime/alert_flyout.ts | 6 +- 10 files changed, 125 insertions(+), 235 deletions(-) create mode 100644 x-pack/plugins/uptime/e2e/journeys/locations/index.ts create mode 100644 x-pack/plugins/uptime/e2e/journeys/locations/locations.ts delete mode 100644 x-pack/test/functional/apps/uptime/locations.ts diff --git a/x-pack/plugins/uptime/e2e/journeys/index.ts b/x-pack/plugins/uptime/e2e/journeys/index.ts index 8430dfec98642..1fe02882fcd89 100644 --- a/x-pack/plugins/uptime/e2e/journeys/index.ts +++ b/x-pack/plugins/uptime/e2e/journeys/index.ts @@ -15,3 +15,4 @@ export * from './monitor_name.journey'; export * from './monitor_management.journey'; export * from './monitor_management_enablement.journey'; export * from './monitor_details'; +export * from './locations'; diff --git a/x-pack/plugins/uptime/e2e/journeys/locations/index.ts b/x-pack/plugins/uptime/e2e/journeys/locations/index.ts new file mode 100644 index 0000000000000..1ec4437601d57 --- /dev/null +++ b/x-pack/plugins/uptime/e2e/journeys/locations/index.ts @@ -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'; diff --git a/x-pack/plugins/uptime/e2e/journeys/locations/locations.ts b/x-pack/plugins/uptime/e2e/journeys/locations/locations.ts new file mode 100644 index 0000000000000..5f555dd6e5070 --- /dev/null +++ b/x-pack/plugins/uptime/e2e/journeys/locations/locations.ts @@ -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 %' }); + }); +}); diff --git a/x-pack/plugins/uptime/server/rest_api/uptime_route_wrapper.ts b/x-pack/plugins/uptime/server/rest_api/uptime_route_wrapper.ts index 916594beb38ea..6ad4e868a7fcb 100644 --- a/x-pack/plugins/uptime/server/rest_api/uptime_route_wrapper.ts +++ b/x-pack/plugins/uptime/server/rest_api/uptime_route_wrapper.ts @@ -47,7 +47,10 @@ export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute, server) => server.uptimeEsClient = uptimeEsClient; - if (isInspectorEnabled || server.isDev) { + if ( + (isInspectorEnabled || server.isDev) && + server.config.service?.username !== 'localKibanaIntegrationTestsUser' + ) { inspectableEsQueriesMap.set(request, []); } diff --git a/x-pack/test/api_integration/apis/uptime/rest/__snapshots__/monitor_states_real_data.snap b/x-pack/test/api_integration/apis/uptime/rest/__snapshots__/monitor_states_real_data.snap index f8c068005b862..81348cfa2bb28 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/__snapshots__/monitor_states_real_data.snap +++ b/x-pack/test/api_integration/apis/uptime/rest/__snapshots__/monitor_states_real_data.snap @@ -6,62 +6,17 @@ Object { "prevPagePagination": null, "summaries": Array [ Object { - "histogram": Object { - "points": Array [ - Object { - "down": 1, - "timestamp": 1568172624744, - }, - Object { - "down": 2, - "timestamp": 1568172677247, - }, - Object { - "down": 1, - "timestamp": 1568172729750, - }, - Object { - "down": 2, - "timestamp": 1568172782253, - }, - Object { - "down": 2, - "timestamp": 1568172834756, - }, - Object { - "down": 2, - "timestamp": 1568172887259, - }, - Object { - "down": 1, - "timestamp": 1568172939762, - }, - Object { - "down": 2, - "timestamp": 1568172992265, - }, - Object { - "down": 2, - "timestamp": 1568173044768, - }, - Object { - "down": 2, - "timestamp": 1568173097271, - }, - Object { - "down": 1, - "timestamp": 1568173149774, - }, - Object { - "down": 2, - "timestamp": 1568173202277, - }, - ], - }, - "minInterval": 52503, "monitor_id": "0010-down", "state": Object { + "error": Object { + "message": "400 Bad Request", + "type": "validate", + }, "monitor": Object { + "checkGroup": "d76f07d1-d445-11e9-88e3-3e80641b9c71", + "duration": Object { + "us": 37926, + }, "name": "", "type": "http", }, @@ -186,62 +141,17 @@ Object { }, }, Object { - "histogram": Object { - "points": Array [ - Object { - "down": 1, - "timestamp": 1568172624744, - }, - Object { - "down": 2, - "timestamp": 1568172677247, - }, - Object { - "down": 1, - "timestamp": 1568172729750, - }, - Object { - "down": 2, - "timestamp": 1568172782253, - }, - Object { - "down": 2, - "timestamp": 1568172834756, - }, - Object { - "down": 2, - "timestamp": 1568172887259, - }, - Object { - "down": 1, - "timestamp": 1568172939762, - }, - Object { - "down": 2, - "timestamp": 1568172992265, - }, - Object { - "down": 2, - "timestamp": 1568173044768, - }, - Object { - "down": 2, - "timestamp": 1568173097271, - }, - Object { - "down": 1, - "timestamp": 1568173149774, - }, - Object { - "down": 2, - "timestamp": 1568173202277, - }, - ], - }, - "minInterval": 52503, "monitor_id": "0020-down", "state": Object { + "error": Object { + "message": "400 Bad Request", + "type": "validate", + }, "monitor": Object { + "checkGroup": "d7712ecb-d445-11e9-88e3-3e80641b9c71", + "duration": Object { + "us": 14900, + }, "name": "", "type": "http", }, diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts index cef035eafb77e..0ca3d4d75b9bd 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts @@ -18,8 +18,6 @@ interface ExpectedMonitorStatesPage { response: any; statesIds: string[]; statuses: string[]; - absFrom: number; - absTo: number; size: number; prevPagination: null | string; nextPagination: null | string; @@ -34,8 +32,6 @@ const checkMonitorStatesResponse = ({ response, statesIds, statuses, - absFrom, - absTo, size, prevPagination, nextPagination, @@ -52,11 +48,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); @@ -65,12 +56,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'; @@ -84,8 +72,6 @@ export default function ({ getService }: FtrProviderContext) { response: apiResponse.body, statesIds: ['0002-up'], statuses: ['up'], - absFrom, - absTo, size: 1, prevPagination: null, nextPagination: null, @@ -480,8 +466,6 @@ export default function ({ getService }: FtrProviderContext) { checkMonitorStatesResponse({ response: nextData, ...expectedNextResults[page - 1], - absFrom, - absTo, size, }); @@ -493,8 +477,6 @@ export default function ({ getService }: FtrProviderContext) { checkMonitorStatesResponse({ response: prevData, ...expectedPrevResults[page - 2], - absFrom, - absTo, size, }); } @@ -521,8 +503,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: diff --git a/x-pack/test/functional/apps/uptime/index.ts b/x-pack/test/functional/apps/uptime/index.ts index 4970ccef7466b..68065129a28af 100644 --- a/x-pack/test/functional/apps/uptime/index.ts +++ b/x-pack/test/functional/apps/uptime/index.ts @@ -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')); }); diff --git a/x-pack/test/functional/apps/uptime/locations.ts b/x-pack/test/functional/apps/uptime/locations.ts deleted file mode 100644 index 1e71607845ea4..0000000000000 --- a/x-pack/test/functional/apps/uptime/locations.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 { makeChecksWithStatus } from '../../../api_integration/apis/uptime/rest/helper/make_checks'; -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default ({ getPageObjects, getService }: FtrProviderContext) => { - const { uptime: uptimePage } = getPageObjects(['uptime']); - const uptime = getService('uptime'); - const es = getService('es'); - - const monitor = () => uptime.monitor; - const MONITOR_ID = 'location-testing-id'; - - const LessAvailMonitor = '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(es, MONITOR_ID, 5, 2, 10000, {}, 'up', mogrifyNoLocation); - }; - - const addLessAvailMonitor = async () => { - await makeChecksWithStatus(es, LessAvailMonitor, 5, 2, 10000, {}, 'up'); - await makeChecksWithStatus(es, LessAvailMonitor, 5, 2, 10000, {}, 'down'); - }; - - // FLAKY: https://github.com/elastic/kibana/issues/85208 - describe.skip('Observer location', () => { - const start = '~ 15 minutes ago'; - const end = 'now'; - - before(async () => { - await addMonitorWithNoLocation(); - await addLessAvailMonitor(); - await uptime.navigation.goToUptime(); - await uptimePage.goToRoot(true); - }); - - beforeEach(async () => { - await addMonitorWithNoLocation(); - await addLessAvailMonitor(); - if (!(await uptime.navigation.isOnDetailsPage())) - await uptimePage.loadDataAndGoToMonitorPage(start, end, MONITOR_ID); - }); - - it('displays the overall availability', async () => { - await monitor().displayOverallAvailability('100.00 %'); - }); - - it('can change the view to map', async () => { - await monitor().toggleToMapView(); - }); - - it('renders the location panel and canvas', async () => { - await monitor().locationMapIsRendered(); - }); - - it('renders the location missing popover when monitor has location name, but no geo data', async () => { - await monitor().locationMissingExists(); - }); - - it('displays less monitor availability', async () => { - await uptime.navigation.goToHomeViaBreadCrumb(); - await uptimePage.loadDataAndGoToMonitorPage(start, end, LessAvailMonitor); - await monitor().displayOverallAvailability('50.00 %'); - }); - }); -}; diff --git a/x-pack/test/functional/services/uptime/monitor.ts b/x-pack/test/functional/services/uptime/monitor.ts index 583a37d7f4ef9..a8b8d96381747 100644 --- a/x-pack/test/functional/services/uptime/monitor.ts +++ b/x-pack/test/functional/services/uptime/monitor.ts @@ -11,16 +11,10 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export function UptimeMonitorProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); - const find = getService('find'); const PageObjects = getPageObjects(['header']); return { - async locationMissingExists() { - return await testSubjects.existOrFail('xpack.uptime.locationMap.locationMissing', { - timeout: 3000, - }); - }, async displayOverallAvailability(availabilityVal: string) { return retry.tryForTime(60 * 1000, async () => { await testSubjects.existOrFail('uptimeOverallAvailability'); @@ -28,16 +22,6 @@ export function UptimeMonitorProvider({ getService, getPageObjects }: FtrProvide expect(availability).to.be(availabilityVal); }); }, - async locationMapIsRendered() { - return retry.tryForTime(15000, async () => { - await testSubjects.existOrFail('xpack.uptime.locationMap.embeddedPanel', { - timeout: 3000, - }); - const mapPanel = await testSubjects.find('xpack.uptime.locationMap.embeddedPanel'); - - await find.descendantExistsByCssSelector('canvas.mapboxgl-canvas', mapPanel); - }); - }, async setPingListLocation(location: string) { await testSubjects.click('xpack.uptime.pingList.locationSelect', 5000); return testSubjects.click(`xpack.uptime.pingList.locationOptions.${location}`, 5000); @@ -56,9 +40,6 @@ export function UptimeMonitorProvider({ getService, getPageObjects }: FtrProvide ); }); }, - async toggleToMapView() { - await testSubjects.click('uptimeMonitorToggleMapBtn'); - }, async hasRedirectInfo() { return retry.tryForTime(30000, async () => { await testSubjects.existOrFail('uptimeMonitorRedirectInfo'); diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts index 2ad2da6d227c2..8cddb9b08a01b 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts @@ -16,8 +16,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const supertest = getService('supertest'); const retry = getService('retry'); - // FLAKY: https://github.com/elastic/kibana/issues/88177 - describe.skip('overview page alert flyout controls', function () { + describe('overview page alert flyout controls', function () { const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078'; const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078'; let alerts: any; @@ -142,8 +141,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/116865 - describe.skip('tls alert', function () { + describe('tls alert', function () { const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078'; const DEFAULT_DATE_END = 'Sep 11, 2019 @ 19:40:08.078'; let alerts: any;