diff --git a/x-pack/plugins/uptime/e2e/journeys/index.ts b/x-pack/plugins/uptime/e2e/journeys/index.ts index 69e0ff15ec88d..a75ae04f9fbdb 100644 --- a/x-pack/plugins/uptime/e2e/journeys/index.ts +++ b/x-pack/plugins/uptime/e2e/journeys/index.ts @@ -8,3 +8,4 @@ export * from './uptime.journey'; export * from './alerts'; 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 ddde993cc9c70..941a78c0d099c 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 @@ -12,7 +12,7 @@ import { createUptimeESClient, inspectableEsQueriesMap } from '../lib/lib'; import { KibanaResponse } from '../../../../../src/core/server/http/router'; import { enableInspectEsQueries } from '../../../observability/common'; -export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute) => ({ +export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute, server) => ({ ...uptimeRoute, options: { tags: ['access:uptime-read', ...(uptimeRoute?.writeAccess ? ['access:uptime-write'] : [])], @@ -30,7 +30,11 @@ export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute) => ({ savedObjectsClient, esClient: esClient.asCurrentUser, }); - if (isInspectorEnabled) { + + if ( + isInspectorEnabled && + 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..a5d714c7fc62b 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,59 +6,6 @@ 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 { "monitor": Object { @@ -186,59 +133,6 @@ 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 { "monitor": Object { 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 909a485057f85..d248a7d418613 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 @@ -15,8 +15,6 @@ interface ExpectedMonitorStatesPage { response: any; statesIds: string[]; statuses: string[]; - absFrom: number; - absTo: number; size: number; prevPagination: null | string; nextPagination: null | string; @@ -31,8 +29,6 @@ const checkMonitorStatesResponse = ({ response, statesIds, statuses, - absFrom, - absTo, size, prevPagination, nextPagination, @@ -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); @@ -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'; @@ -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, @@ -476,8 +462,6 @@ export default function ({ getService }: FtrProviderContext) { checkMonitorStatesResponse({ response: nextData, ...expectedNextResults[page - 1], - absFrom, - absTo, size, }); @@ -489,8 +473,6 @@ export default function ({ getService }: FtrProviderContext) { checkMonitorStatesResponse({ response: prevData, ...expectedPrevResults[page - 2], - absFrom, - absTo, size, }); } @@ -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: diff --git a/x-pack/test/functional/apps/uptime/index.ts b/x-pack/test/functional/apps/uptime/index.ts index 997ac87a80e8c..8082dd62889e5 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')); loadTestFile(require.resolve('./synthetics_integration')); 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 4510e81462420..bcdb75717f26e 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 @@ -143,8 +143,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;