diff --git a/.buildkite/ftr_configs.yml b/.buildkite/ftr_configs.yml index e12d7110d12ad..4930707980a70 100644 --- a/.buildkite/ftr_configs.yml +++ b/.buildkite/ftr_configs.yml @@ -56,7 +56,8 @@ disabled: # Elastic Synthetics configs - x-pack/plugins/synthetics/e2e/config.ts - - x-pack/plugins/synthetics/e2e/synthetics_run.ts + - x-pack/plugins/synthetics/e2e/uptime/synthetics_run.ts + - x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts - x-pack/plugins/ux/e2e/synthetics_run.ts - x-pack/plugins/exploratory_view/e2e/synthetics_run.ts diff --git a/.buildkite/pipelines/pull_request/exploratory_view_plugin.yml b/.buildkite/pipelines/pull_request/exploratory_view_plugin.yml index ec4442b501a09..0f572a98cefb3 100644 --- a/.buildkite/pipelines/pull_request/exploratory_view_plugin.yml +++ b/.buildkite/pipelines/pull_request/exploratory_view_plugin.yml @@ -4,7 +4,7 @@ steps: agents: queue: n2-4-spot depends_on: build - timeout_in_minutes: 120 + timeout_in_minutes: 60 artifact_paths: - 'x-pack/plugins/exploratory_view/e2e/.journeys/**/*' retry: diff --git a/.buildkite/pipelines/pull_request/synthetics_plugin.yml b/.buildkite/pipelines/pull_request/synthetics_plugin.yml index a091dbf3682c6..bfa3caa62f177 100644 --- a/.buildkite/pipelines/pull_request/synthetics_plugin.yml +++ b/.buildkite/pipelines/pull_request/synthetics_plugin.yml @@ -4,7 +4,7 @@ steps: agents: queue: n2-4-spot depends_on: build - timeout_in_minutes: 120 + timeout_in_minutes: 60 artifact_paths: - 'x-pack/plugins/synthetics/e2e/.journeys/**/*' retry: diff --git a/.buildkite/pipelines/pull_request/uptime_plugin.yml b/.buildkite/pipelines/pull_request/uptime_plugin.yml new file mode 100644 index 0000000000000..cbd1c417fc852 --- /dev/null +++ b/.buildkite/pipelines/pull_request/uptime_plugin.yml @@ -0,0 +1,15 @@ +steps: + - command: .buildkite/scripts/steps/functional/uptime_plugin.sh + label: 'Uptime @elastic/synthetics Tests' + agents: + queue: n2-4-spot + depends_on: build + timeout_in_minutes: 60 + artifact_paths: + - 'x-pack/plugins/synthetics/e2e/.journeys/**/*' + retry: + automatic: + - exit_status: '-1' + limit: 3 + - exit_status: '*' + limit: 1 diff --git a/.buildkite/pipelines/pull_request/ux_plugin_e2e.yml b/.buildkite/pipelines/pull_request/ux_plugin_e2e.yml index 129baff36e6ef..7542373c0f437 100644 --- a/.buildkite/pipelines/pull_request/ux_plugin_e2e.yml +++ b/.buildkite/pipelines/pull_request/ux_plugin_e2e.yml @@ -4,7 +4,7 @@ steps: agents: queue: n2-4-spot depends_on: build - timeout_in_minutes: 120 + timeout_in_minutes: 60 artifact_paths: - 'x-pack/plugins/ux/e2e/.journeys/**/*' retry: diff --git a/.buildkite/scripts/pipelines/pull_request/pipeline.ts b/.buildkite/scripts/pipelines/pull_request/pipeline.ts index fb89575ad31df..263eae4ab4052 100644 --- a/.buildkite/scripts/pipelines/pull_request/pipeline.ts +++ b/.buildkite/scripts/pipelines/pull_request/pipeline.ts @@ -152,6 +152,7 @@ const uploadPipeline = (pipelineContent: string | object) => { ]) ) { pipeline.push(getPipeline('.buildkite/pipelines/pull_request/synthetics_plugin.yml')); + pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime_plugin.yml')); } if (await doAnyChangesMatch([/^x-pack\/plugins\/ux/, /^x-pack\/plugins\/exploratory_view/])) { diff --git a/.buildkite/scripts/steps/functional/uptime_plugin.sh b/.buildkite/scripts/steps/functional/uptime_plugin.sh new file mode 100755 index 0000000000000..aba449dfdbba4 --- /dev/null +++ b/.buildkite/scripts/steps/functional/uptime_plugin.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source .buildkite/scripts/common/util.sh + +.buildkite/scripts/bootstrap.sh +.buildkite/scripts/download_build_artifacts.sh + +export JOB=kibana-uptime-plugin + +echo "--- Uptime plugin @elastic/synthetics Tests" + +cd "$XPACK_DIR" + +node plugins/synthetics/scripts/uptime_e2e.js --kibana-install-dir "$KIBANA_BUILD_LOCATION" ${GREP:+--grep \"${GREP}\"} diff --git a/packages/kbn-ts-projects/ts_projects.ts b/packages/kbn-ts-projects/ts_projects.ts index 9eea1e2227ba5..94f485773b485 100644 --- a/packages/kbn-ts-projects/ts_projects.ts +++ b/packages/kbn-ts-projects/ts_projects.ts @@ -19,9 +19,6 @@ export const TS_PROJECTS = TsProject.loadAll({ // type check is explicitly disabled in this project for now '.buildkite/tsconfig.json', - 'x-pack/plugins/synthetics/e2e/tsconfig.json', - 'x-pack/plugins/ux/e2e/tsconfig.json', - 'x-pack/plugins/exploratory_view/e2e/tsconfig.json', 'x-pack/plugins/threat_intelligence/cypress/tsconfig.json', ], }); diff --git a/x-pack/plugins/exploratory_view/e2e/tsconfig.json b/x-pack/plugins/exploratory_view/e2e/tsconfig.json index df3428e1aa0bf..881ab4db9046c 100644 --- a/x-pack/plugins/exploratory_view/e2e/tsconfig.json +++ b/x-pack/plugins/exploratory_view/e2e/tsconfig.json @@ -6,4 +6,9 @@ "outDir": "target/types", "types": [ "node"], }, + "kbn_references": [ + "@kbn/test", + "@kbn/apm-plugin", + "@kbn/es-archiver", + ], } diff --git a/x-pack/plugins/exploratory_view/public/components/shared/exploratory_view/obsv_exploratory_view.tsx b/x-pack/plugins/exploratory_view/public/components/shared/exploratory_view/obsv_exploratory_view.tsx index 99112e46eece8..795f6aaaf45a1 100644 --- a/x-pack/plugins/exploratory_view/public/components/shared/exploratory_view/obsv_exploratory_view.tsx +++ b/x-pack/plugins/exploratory_view/public/components/shared/exploratory_view/obsv_exploratory_view.tsx @@ -46,6 +46,10 @@ export const dataTypes: Array<{ id: AppDataType; label: string }> = [ id: DataTypes.SYNTHETICS, label: DataTypesLabels[DataTypes.SYNTHETICS], }, + { + id: DataTypes.UPTIME, + label: DataTypesLabels[DataTypes.UPTIME], + }, { id: DataTypes.UX, label: DataTypesLabels[DataTypes.UX], diff --git a/x-pack/plugins/synthetics/e2e/README.md b/x-pack/plugins/synthetics/e2e/README.md index fa20275af977f..9a7617cd3d055 100644 --- a/x-pack/plugins/synthetics/e2e/README.md +++ b/x-pack/plugins/synthetics/e2e/README.md @@ -10,6 +10,23 @@ with an example run command when it finishes. ### Run the tests -From this directory, `~/x-pack/plugins/synthetics/e2e`, you can now run `node ../../../../scripts/functional_test_runner --config synthetics_run.ts`. +From the same directory you can now run `node node e2e.js --runner`. + +In addition to the usual flags like `--grep`, you can also specify `--no-headless` in order to view your tests as you debug/develop. + + +## Uptime App Tests + +These tests rely on the Kibana functional test runner. There is a Kibana config in this directory, and a dedicated +script for standing up the test server. + +### Start the server + +From `~/x-pack/plugins/synthetics/scripts`, run `node uptime_e2e.js --server`. Wait for the server to startup. It will provide you +with an example run command when it finishes. + +### Run the tests + +From the same directory you can now run `node node uptime_e2e.js --runner`. In addition to the usual flags like `--grep`, you can also specify `--no-headless` in order to view your tests as you debug/develop. diff --git a/x-pack/plugins/synthetics/e2e/config.ts b/x-pack/plugins/synthetics/e2e/config.ts index 458fbd4c2dccd..4e76ef26cef6e 100644 --- a/x-pack/plugins/synthetics/e2e/config.ts +++ b/x-pack/plugins/synthetics/e2e/config.ts @@ -7,14 +7,11 @@ import { FtrConfigProviderContext } from '@kbn/test'; import { CA_CERT_PATH } from '@kbn/dev-utils'; -import { argv } from './helpers/parse_args_params'; import { readKibanaConfig } from './tasks/read_kibana_config'; const MANIFEST_KEY = 'xpack.uptime.service.manifestUrl'; const SERVICE_PASSWORD = 'xpack.uptime.service.password'; const SERVICE_USERNAME = 'xpack.uptime.service.username'; -const { watch } = argv; - async function config({ readConfigFile }: FtrConfigProviderContext) { const kibanaCommonTestsConfig = await readConfigFile( require.resolve('../../../../test/common/config.js') @@ -44,7 +41,7 @@ async function config({ readConfigFile }: FtrConfigProviderContext) { kbnTestServer: { ...xpackFunctionalTestsConfig.get('kbnTestServer'), - sourceArgs: watch + sourceArgs: process.env.WATCH_ENABLED ? [] : [...xpackFunctionalTestsConfig.get('kbnTestServer.sourceArgs'), '--no-watch'], serverArgs: [ @@ -54,7 +51,7 @@ async function config({ readConfigFile }: FtrConfigProviderContext) { '--csp.warnLegacyBrowsers=false', // define custom kibana server args here `--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`, - `--elasticsearch.ignoreVersionMismatch=${process.env.CI ? 'false' : 'true'}`, + // `--elasticsearch.ignoreVersionMismatch=${process.env.CI ? 'false' : 'true'}`, `--elasticsearch.username=kibana_system`, `--elasticsearch.password=changeme`, '--xpack.reporting.enabled=false', diff --git a/x-pack/plugins/synthetics/e2e/helpers/parse_args_params.ts b/x-pack/plugins/synthetics/e2e/helpers/parse_args_params.ts index 41100ba2ec295..a69cae912dfee 100644 --- a/x-pack/plugins/synthetics/e2e/helpers/parse_args_params.ts +++ b/x-pack/plugins/synthetics/e2e/helpers/parse_args_params.ts @@ -18,11 +18,6 @@ const { argv } = yargs(process.argv.slice(2)) type: 'boolean', description: 'Pause on error', }) - .option('watch', { - default: false, - type: 'boolean', - description: 'Runs the server in watch mode, restarting on changes', - }) .option('grep', { default: undefined, type: 'string', diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/add_monitor.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/add_monitor.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/add_monitor.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/add_monitor.journey.ts index 38f0399243ec5..e18b5cac11e2f 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/add_monitor.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/add_monitor.journey.ts @@ -8,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid'; import { journey, step, expect, Page } from '@elastic/synthetics'; import { recordVideo } from '../../helpers/record_video'; import { FormMonitorType } from '../../../common/runtime_types'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; const customLocation = process.env.SYNTHETICS_TEST_LOCATION; diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/default_status_alert.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/default_status_alert.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/default_status_alert.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/default_status_alert.journey.ts index 2373b9712a753..72d9c63808914 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/default_status_alert.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/default_status_alert.journey.ts @@ -11,7 +11,7 @@ import { RetryService } from '@kbn/ftr-common-functional-services'; import { v4 as uuidv4 } from 'uuid'; import { recordVideo } from '../../../helpers/record_video'; import { getReasonMessage } from '../../../../server/legacy_uptime/lib/alerts/status_check'; -import { syntheticsAppPageProvider } from '../../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../../page_objects/synthetics_app'; import { SyntheticsServices } from '../services/synthetics_services'; journey(`DefaultStatusAlert`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/sample_docs/sample_docs.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/sample_docs/sample_docs.ts similarity index 57% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/sample_docs/sample_docs.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/sample_docs/sample_docs.ts index 21b7bd301214c..cdb1917d3026a 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alert_rules/sample_docs/sample_docs.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alert_rules/sample_docs/sample_docs.ts @@ -258,159 +258,3 @@ export const firstDownHit = ({ dataset: 'http', }, }); - -const sampleHits = { - took: 1, - timed_out: false, - _shards: { - total: 1, - successful: 1, - skipped: 0, - failed: 0, - }, - hits: { - total: { - value: 3, - relation: 'eq', - }, - max_score: null, - hits: [ - firstUpHit, - { - _index: '.ds-synthetics-http-default-2022.12.18-000001', - _id: 'TfCjJIUB1hhCUz-n3bWY', - _score: null, - _ignored: ['http.response.body.content'], - _source: firstDownHit, - sort: [1671356989976], - }, - { - _index: '.ds-synthetics-http-default-2022.12.18-000001', - _id: 'fPCiJIUB1hhCUz-nVbMK', - _score: null, - _source: { - summary: { - up: 1, - down: 0, - }, - tcp: { - rtt: { - connect: { - us: 26843, - }, - }, - }, - agent: { - name: 'docker-fleet-server', - id: 'dd39a87d-a1e5-45a1-8dd9-e78d6a1391c6', - ephemeral_id: '264bb432-93f6-4aa6-a14d-266c53b9e7c7', - type: 'heartbeat', - version: '8.7.0', - }, - resolve: { - rtt: { - us: 18153, - }, - ip: '142.250.181.196', - }, - elastic_agent: { - id: 'dd39a87d-a1e5-45a1-8dd9-e78d6a1391c6', - version: '8.7.0', - snapshot: true, - }, - monitor: { - duration: { - us: 179022, - }, - ip: '142.250.181.196', - origin: 'ui', - name: 'Test Monitor', - id: 'b9d9e146-746f-427f-bbf5-6e786b5b4e73', - timespan: { - lt: '2022-12-18T09:51:09.403Z', - gte: '2022-12-18T09:48:09.403Z', - }, - check_group: '144186b2-7eb9-11ed-8949-0242ac120006', - fleet_managed: true, - type: 'http', - status: 'up', - }, - url: { - scheme: 'https', - port: 443, - domain: 'www.google.com', - full: 'https://www.google.com', - }, - observer: { - geo: { - name: 'Test private location', - }, - name: 'Test private location', - }, - '@timestamp': '2022-12-18T09:48:09.224Z', - ecs: { - version: '8.0.0', - }, - config_id: 'b9d9e146-746f-427f-bbf5-6e786b5b4e73', - data_stream: { - namespace: 'default', - type: 'synthetics', - dataset: 'http', - }, - tls: { - cipher: 'TLS-AES-128-GCM-SHA256', - certificate_not_valid_before: '2022-11-28T08:19:01.000Z', - established: true, - server: { - x509: { - not_after: '2023-02-20T08:19:00.000Z', - subject: { - distinguished_name: 'CN=www.google.com', - common_name: 'www.google.com', - }, - not_before: '2022-11-28T08:19:01.000Z', - public_key_curve: 'P-256', - public_key_algorithm: 'ECDSA', - signature_algorithm: 'SHA256-RSA', - serial_number: '173037077033925240295268439311466214245', - issuer: { - distinguished_name: 'CN=GTS CA 1C3,O=Google Trust Services LLC,C=US', - common_name: 'GTS CA 1C3', - }, - }, - hash: { - sha1: 'ea1b44061b864526c45619230b3299117d11bf4e', - sha256: 'a5686448de09cc82b9cdad1e96357f919552ab14244da7948dd412ec0fc37d2b', - }, - }, - rtt: { - handshake: { - us: 34230, - }, - }, - version: '1.3', - certificate_not_valid_after: '2023-02-20T08:19:00.000Z', - version_protocol: 'tls', - }, - state: { - duration_ms: 0, - checks: 1, - ends: null, - started_at: '2022-12-18T09:48:15.335017193Z', - id: 'Test private location-18524a25067-0', - up: 1, - down: 0, - flap_history: [], - status: 'up', - }, - event: { - agent_id_status: 'verified', - ingested: '2022-12-18T09:48:16Z', - dataset: 'http', - }, - }, - sort: [1671356889224], - }, - ], - }, -}; diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alerting_default.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alerting_default.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/alerting_default.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/alerting_default.journey.ts index dc52772898174..96e91f81ff9fa 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/alerting_default.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/alerting_default.journey.ts @@ -6,9 +6,9 @@ */ import { journey, step, expect, before, after } from '@elastic/synthetics'; -import { byTestId } from '../../helpers/utils'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { byTestId } from '../../helpers/utils'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { cleanSettings } from './services/settings'; journey('AlertingDefaults', async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/data_retention.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/data_retention.journey.ts similarity index 97% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/data_retention.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/data_retention.journey.ts index bbbf6a7e48aa9..9487fb62ccf95 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/data_retention.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/data_retention.journey.ts @@ -7,9 +7,9 @@ import { journey, step, expect, Page } from '@elastic/synthetics'; import { RetryService } from '@kbn/ftr-common-functional-services'; -import { byTestId, assertText } from '../../helpers/utils'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; +import { byTestId, assertText } from '../../helpers/utils'; let page1: Page; journey(`DataRetentionPage`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/detail_flyout.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/detail_flyout.ts similarity index 95% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/detail_flyout.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/detail_flyout.ts index 2cd8c018e4032..4204e68099042 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/detail_flyout.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/detail_flyout.ts @@ -7,7 +7,7 @@ import { expect, journey, step } from '@elastic/synthetics'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey('TestMonitorDetailFlyout', async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/getting_started.journey.ts similarity index 95% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/getting_started.journey.ts index c52b2b5f1aa48..abb66db15d601 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/getting_started.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/getting_started.journey.ts @@ -7,7 +7,7 @@ import { journey, step, expect, before, Page } from '@elastic/synthetics'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { cleanTestMonitors } from './services/add_monitor'; journey(`Getting Started Page`, async ({ page, params }: { page: Page; params: any }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/global_parameters.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/global_parameters.journey.ts similarity index 97% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/global_parameters.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/global_parameters.journey.ts index 8af902caf07db..d5581e51b1833 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/global_parameters.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/global_parameters.journey.ts @@ -9,7 +9,7 @@ import { journey, step, before, after, expect } from '@elastic/synthetics'; import { byTestId } from '../../helpers/utils'; import { recordVideo } from '../../helpers/record_video'; import { cleanTestParams } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey(`GlobalParameters`, async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/index.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/index.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/index.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/index.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/management_list.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/management_list.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/management_list.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/management_list.journey.ts index d4110ca7508c3..04339190d7065 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/management_list.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/management_list.journey.ts @@ -13,7 +13,7 @@ import { cleanTestMonitors, enableMonitorManagedViaApi, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey(`MonitorManagementList`, async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_details_page/monitor_summary.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_details_page/monitor_summary.journey.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_details_page/monitor_summary.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_details_page/monitor_summary.journey.ts index b450bd7983ff7..94228e8c1404d 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_details_page/monitor_summary.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_details_page/monitor_summary.journey.ts @@ -10,7 +10,7 @@ import { byTestId } from '@kbn/ux-plugin/e2e/journeys/utils'; import { RetryService } from '@kbn/ftr-common-functional-services'; import moment from 'moment'; import { recordVideo } from '../../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../../page_objects/synthetics_app'; import { SyntheticsServices } from '../services/synthetics_services'; journey(`MonitorSummaryTab`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_selector.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_selector.journey.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_selector.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_selector.journey.ts index fe4a36ba6e9ba..35e4a8996d5b3 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/monitor_selector.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_selector.journey.ts @@ -13,7 +13,7 @@ import { cleanTestMonitors, enableMonitorManagedViaApi, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey(`MonitorSelector`, async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_scrolling.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_scrolling.journey.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_scrolling.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_scrolling.journey.ts index 29aeb474212c5..2936c33d8c44c 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_scrolling.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_scrolling.journey.ts @@ -13,7 +13,7 @@ import { cleanTestMonitors, enableMonitorManagedViaApi, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey('OverviewScrolling', async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_search.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_search.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_search.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_search.journey.ts index 49bacee80380e..a1729fca0faa3 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_search.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_search.journey.ts @@ -13,7 +13,7 @@ import { cleanTestMonitors, enableMonitorManagedViaApi, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey('Overview Search', async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_sorting.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_sorting.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_sorting.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_sorting.journey.ts index 45c63fb389ab2..018df450628ef 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/overview_sorting.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/overview_sorting.journey.ts @@ -12,7 +12,7 @@ import { cleanTestMonitors, enableMonitorManagedViaApi, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey('OverviewSorting', async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/private_locations.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/private_locations.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/private_locations.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/private_locations.journey.ts index a3ab5804db62c..970569b16307c 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/private_locations.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/private_locations.journey.ts @@ -15,7 +15,7 @@ import { cleanTestMonitors, getPrivateLocations, } from './services/add_monitor'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; journey(`PrivateLocationsSettings`, async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/project_api_keys.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/project_api_keys.journey.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/project_api_keys.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/project_api_keys.journey.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/project_monitor_read_only.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/project_monitor_read_only.journey.ts similarity index 97% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/project_monitor_read_only.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/project_monitor_read_only.journey.ts index d11ec61c39f8c..01d78fe21b5f3 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/project_monitor_read_only.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/project_monitor_read_only.journey.ts @@ -10,7 +10,7 @@ import { SyntheticsServices } from './services/synthetics_services'; import { recordVideo } from '../../helpers/record_video'; import { cleanTestMonitors, enableMonitorManagedViaApi } from './services/add_monitor'; import { addTestMonitorProject } from './services/add_monitor_project'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { SyntheticsMonitor } from '../../../common/runtime_types'; journey('ProjectMonitorReadOnly', async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/add_monitor.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/add_monitor.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor_project.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/add_monitor_project.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/add_monitor_project.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/add_monitor_project.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/data/browser_docs.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/data/browser_docs.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/data/browser_docs.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/data/browser_docs.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/data/sample_docs.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/data/sample_docs.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/data/sample_docs.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/data/sample_docs.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/settings.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/settings.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/settings.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/settings.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/synthetics_services.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/services/synthetics_services.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts index 8852a93a7952a..c29e1f7b5d7bc 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/services/synthetics_services.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts @@ -26,7 +26,7 @@ export class SyntheticsServices { async getMonitor(monitorId: string): Promise { try { - const { data } = await this.requester.request<{ attributes: SyntheticsMonitor }>({ + const { data } = await this.requester.request({ description: 'get monitor by id', path: API_URLS.GET_SYNTHETICS_MONITOR.replace('{monitorId}', monitorId), query: { @@ -34,7 +34,7 @@ export class SyntheticsServices { }, method: 'GET', }); - return data?.attributes; + return (data as { attributes: SyntheticsMonitor })?.attributes; } catch (e) { // eslint-disable-next-line no-console console.log(e); diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/step_details.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/step_details.journey.ts similarity index 94% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/step_details.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/step_details.journey.ts index c11515d0a44da..5d4c677b21718 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/step_details.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/step_details.journey.ts @@ -7,7 +7,7 @@ import { journey, step, before, after } from '@elastic/synthetics'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { SyntheticsServices } from './services/synthetics_services'; journey(`StepDetailsPage`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_now_mode.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/test_now_mode.journey.ts similarity index 98% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/test_now_mode.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/test_now_mode.journey.ts index 846f36f45542d..3c99b173f781f 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_now_mode.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/test_now_mode.journey.ts @@ -7,9 +7,9 @@ import { journey, step, before, after, expect } from '@elastic/synthetics'; import { RetryService } from '@kbn/ftr-common-functional-services'; -import { byTestId } from '../../helpers/utils'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { byTestId } from '../../helpers/utils'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { SyntheticsServices } from './services/synthetics_services'; journey(`TestNowMode`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts b/x-pack/plugins/synthetics/e2e/synthetics/journeys/test_run_details.journey.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts rename to x-pack/plugins/synthetics/e2e/synthetics/journeys/test_run_details.journey.ts index 5db5a55a4759d..433583a8ce3c8 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/synthetics/test_run_details.journey.ts +++ b/x-pack/plugins/synthetics/e2e/synthetics/journeys/test_run_details.journey.ts @@ -6,9 +6,9 @@ */ import { journey, step, before, after } from '@elastic/synthetics'; -import { byTestId } from '../../helpers/utils'; import { recordVideo } from '../../helpers/record_video'; -import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app'; +import { byTestId } from '../../helpers/utils'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; import { SyntheticsServices } from './services/synthetics_services'; journey(`TestRunDetailsPage`, async ({ page, params }) => { diff --git a/x-pack/plugins/synthetics/e2e/page_objects/synthetics/synthetics_app.tsx b/x-pack/plugins/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx similarity index 98% rename from x-pack/plugins/synthetics/e2e/page_objects/synthetics/synthetics_app.tsx rename to x-pack/plugins/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx index db5aeb25356b9..ebcd900c4c210 100644 --- a/x-pack/plugins/synthetics/e2e/page_objects/synthetics/synthetics_app.tsx +++ b/x-pack/plugins/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx @@ -6,8 +6,8 @@ */ import { expect, Page } from '@elastic/synthetics'; import { FormMonitorType } from '../../../common/runtime_types/monitor_management'; -import { loginPageProvider } from '../login'; -import { utilsPageProvider } from '../utils'; +import { loginPageProvider } from '../../page_objects/login'; +import { utilsPageProvider } from '../../page_objects/utils'; const SIXTY_SEC_TIMEOUT = { timeout: 60 * 1000, diff --git a/x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts b/x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts new file mode 100644 index 0000000000000..3624c03c5f1f0 --- /dev/null +++ b/x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts @@ -0,0 +1,44 @@ +/* + * 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 { FtrConfigProviderContext } from '@kbn/test'; +import path from 'path'; +import { argv } from '../helpers/parse_args_params'; +import { SyntheticsRunner } from '../helpers/synthetics_runner'; + +const { headless, grep, bail: pauseOnError } = argv; + +async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) { + const kibanaConfig = await readConfigFile(require.resolve('../config.ts')); + return { + ...kibanaConfig.getAll(), + testRunner: async ({ getService }: any) => { + const syntheticsRunner = new SyntheticsRunner(getService, { + headless, + match: grep, + pauseOnError, + }); + + await syntheticsRunner.setup(); + const fixturesDir = path.join(__dirname, '../fixtures/es_archiver/'); + + await syntheticsRunner.loadTestData(fixturesDir, [ + 'synthetics_data', + 'full_heartbeat', + 'browser', + ]); + + await syntheticsRunner.loadTestFiles(async () => { + require('./journeys'); + }); + + await syntheticsRunner.run(); + }, + }; +} + +// eslint-disable-next-line import/no-default-export +export default runE2ETests; diff --git a/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts b/x-pack/plugins/synthetics/e2e/tasks/import_monitors.ts deleted file mode 100644 index f7143ee5b89e8..0000000000000 --- a/x-pack/plugins/synthetics/e2e/tasks/import_monitors.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 axios from 'axios'; - -export const importMonitors = async ({ - kibanaUrl, - username, - password, -}: { - kibanaUrl: string; - username?: string; - password?: string; -}) => { - // eslint-disable-next-line no-console - console.log('Loading sample monitors'); - - const jsonData = { - type: 'browser', - enabled: true, - schedule: { unit: 'm', number: '10' }, - 'service.name': '', - tags: [], - timeout: null, - name: 'Browser monitor', - locations: [{ id: 'us_central', isServiceManaged: true }], - namespace: 'default', - origin: 'ui', - journey_id: '', - project_id: '', - playwright_options: '', - __ui: { - script_source: { is_generated_script: false, file_name: '' }, - is_tls_enabled: false, - }, - params: '', - 'url.port': null, - 'source.inline.script': - "const username = 'diawar.khan.shewani+conduit@gmail.com';\nconst password = 'aNL2sTGRbNYauc8';\n// Goto https://demo.realworld.io/ and sign up for username and password\n\nconst articleTitle = 'Artile No. ' + Math.ceil(Math.random() * 1000);\n\nstep(\"Goto home page\", async () => {\n await page.goto('https://demo.realworld.io/');\n});\n\nstep(\"Goto login page\", async () => {\n await page.click('text=Sign in');\n});\n\nstep(\"Enter login credentials\", async () => {\n await page.fill('[placeholder=\"Email\"]', username);\n await page.fill('[placeholder=\"Password\"]', password);\n});\n\nstep(\"Sign in\", async () => {\n await page.click('button[type=submit]');\n});\n\nstep(\"Create article\", async () => {\n const articleSubject = 'Test article subject';\n const articleBody = 'This ariticle is created with **synthetics** for purely testing purposes.';\n\n await page.click('text=New Article');\n await page.fill('[placeholder=\"Article Title\"]', articleTitle);\n await page.fill('[placeholder=\"What\\'s this article about?\"]', articleSubject);\n await page.fill('textarea', articleBody);\n});\n\nstep(\"Publish article\", async () => {\n await page.click('text=Publish Article');\n await page.waitForNavigation();\n\n // Fail about 30% of random times\n const passFailText = Math.random() * 10 > 7 ? 'non-existent-text' : articleTitle ;\n await page.waitForSelector('text=' + articleTitle);\n});\n\nstep(\"Post 1st comment\", async() => {\n const firstCommentText = 'First comment!';\n await page.fill('[placeholder=\"Write a comment...\"]', firstCommentText);\n await page.click('text=Post Comment');\n await page.waitForSelector('text=' + firstCommentText);\n});", - 'source.project.content': '', - urls: '', - screenshots: 'on', - synthetics_args: [], - 'filter_journeys.match': '', - 'filter_journeys.tags': [], - ignore_https_errors: false, - throttling: { - id: 'custom', - label: 'Custom', - value: { - download: '5', - upload: '3', - latency: '20', - }, - }, - }; - - const id = '1c215bd0-f580-11ec-89e5-694db461b7a5'; - - try { - axios - .request({ - method: 'post', - url: kibanaUrl + '/internal/uptime/service/monitors?id=' + id, - auth: { username: username ?? 'elastic', password: password ?? 'changeme' }, - headers: { 'kbn-xsrf': 'true' }, - data: jsonData, - }) - .then(({ data }) => { - if (data.id === id) { - // eslint-disable-next-line no-console - console.info('Successfully imported 1 monitor'); - } - }); - } catch (e) { - // eslint-disable-next-line no-console - console.error(e); - } -}; diff --git a/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson b/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson deleted file mode 100644 index 818bbfcefd579..0000000000000 --- a/x-pack/plugins/synthetics/e2e/tasks/uptime_monitor.ndjson +++ /dev/null @@ -1,2 +0,0 @@ -{"attributes":{"__ui":{"is_tls_enabled":false},"check.request.method":"GET","check.response.status":[],"enabled":true,"locations":[{"geo":{"lat":41.25,"lon":-95.86},"id":"us_central","label":"US Central","url":"https://us-central.synthetics.elastic.dev"}],"max_redirects":"0","name":"Test Monitor","proxy_url":"","response.include_body":"on_error","response.include_headers":true,"schedule":{"number":"3","unit":"m"},"service.name":"","tags":[],"timeout":"16","type":"http","urls":"https://www.google.com", "secrets": "{}"},"coreMigrationVersion":"8.1.0","id":"832b9980-7fba-11ec-b360-25a79ce3f496","references":[],"sort":[1643319958480,20371],"type":"synthetics-monitor","updated_at":"2022-01-27T21:45:58.480Z","version":"WzExOTg3ODYsMl0="} -{"excludedObjects":[],"excludedObjectsCount":0,"exportedCount":2,"missingRefCount":0,"missingReferences":[]} diff --git a/x-pack/plugins/synthetics/e2e/tsconfig.json b/x-pack/plugins/synthetics/e2e/tsconfig.json index df3428e1aa0bf..c00c388ec86e0 100644 --- a/x-pack/plugins/synthetics/e2e/tsconfig.json +++ b/x-pack/plugins/synthetics/e2e/tsconfig.json @@ -1,9 +1,20 @@ { "extends": "../../../../tsconfig.base.json", "exclude": ["tmp", "target/**/*"], - "include": ["./**/*"], + "include": ["**/*"], "compilerOptions": { "outDir": "target/types", "types": [ "node"], + "isolatedModules": false, }, + "kbn_references": [ + { "path": "../../../test/tsconfig.json" }, + { "path": "../../../../test/tsconfig.json" }, + "@kbn/test", + "@kbn/dev-utils", + "@kbn/ux-plugin/e2e", + "@kbn/ftr-common-functional-services", + "@kbn/apm-plugin", + "@kbn/es-archiver", + ] } diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/default_email_settings.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/default_email_settings.ts similarity index 90% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/default_email_settings.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/default_email_settings.ts index 17a6ee07aa1c7..2865084aa29e8 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/default_email_settings.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/default_email_settings.ts @@ -5,23 +5,16 @@ * 2.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 { journey, step, before } from '@elastic/synthetics'; - import { assertNotText, - byTestId, assertText, + byTestId, waitForLoadingToFinish, } from '../../../helpers/utils'; import { recordVideo } from '../../../helpers/record_video'; -import { settingsPageProvider } from '../../../page_objects/uptime/settings'; + +import { settingsPageProvider } from '../../page_objects/settings'; journey('DefaultEmailSettings', async ({ page, params }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/index.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/index.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/index.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/index.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/status_alert_flyouts_in_alerting_app.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/status_alert_flyouts_in_alerting_app.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/status_alert_flyouts_in_alerting_app.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/status_alert_flyouts_in_alerting_app.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/tls_alert_flyouts_in_alerting_app.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/tls_alert_flyouts_in_alerting_app.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/alerts/tls_alert_flyouts_in_alerting_app.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/alerts/tls_alert_flyouts_in_alerting_app.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/data_view_permissions.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/data_view_permissions.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/data_view_permissions.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/data_view_permissions.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/index.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/index.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/index.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/index.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/locations/index.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/locations/index.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/locations/index.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/locations/index.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/locations/locations.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/locations/locations.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/locations/locations.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/locations/locations.ts index fc307f10d0c00..afb5ebf0c04a1 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime/locations/locations.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/journeys/locations/locations.ts @@ -8,7 +8,7 @@ import { journey, step, before, Page } from '@elastic/synthetics'; import { recordVideo } from '../../../helpers/record_video'; import { makeChecksWithStatus } from '../../../helpers/make_checks'; -import { monitorDetailsPageProvider } from '../../../page_objects/uptime/monitor_details'; +import { monitorDetailsPageProvider } from '../../page_objects/monitor_details'; journey('Observer location', async ({ page, params }: { page: Page; params: any }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/index.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/index.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/index.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/index.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_alerts.journey.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_alerts.journey.ts similarity index 97% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_alerts.journey.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_alerts.journey.ts index 41c51a9bba00e..88a174f76cc59 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_alerts.journey.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_alerts.journey.ts @@ -9,7 +9,7 @@ import { journey, step, expect, before, Page } from '@elastic/synthetics'; import { noop } from 'lodash'; import { byTestId, delay } from '../../../helpers/utils'; import { recordVideo } from '../../../helpers/record_video'; -import { monitorDetailsPageProvider } from '../../../page_objects/uptime/monitor_details'; +import { monitorDetailsPageProvider } from '../../page_objects/monitor_details'; const dateRangeStart = '2019-09-10T12:40:08.078Z'; const dateRangeEnd = '2019-09-11T19:40:08.078Z'; diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_details.journey.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_details.journey.ts similarity index 95% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_details.journey.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_details.journey.ts index e395fdae45713..f46081c7b3823 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/monitor_details.journey.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/monitor_details.journey.ts @@ -8,7 +8,7 @@ import { journey, step, before, Page } from '@elastic/synthetics'; import { byTestId } from '../../../helpers/utils'; import { recordVideo } from '../../../helpers/record_video'; -import { monitorDetailsPageProvider } from '../../../page_objects/uptime/monitor_details'; +import { monitorDetailsPageProvider } from '../../page_objects/monitor_details'; const dateRangeStart = '2019-09-10T12:40:08.078Z'; const dateRangeEnd = '2019-09-11T19:40:08.078Z'; diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/ping_redirects.journey.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/ping_redirects.journey.ts similarity index 96% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/ping_redirects.journey.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/ping_redirects.journey.ts index af0d38de81775..502217721381d 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/uptime/monitor_details/ping_redirects.journey.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/journeys/monitor_details/ping_redirects.journey.ts @@ -9,7 +9,7 @@ import { journey, step, expect, before, Page } from '@elastic/synthetics'; import { byTestId, delay } from '../../../helpers/utils'; import { recordVideo } from '../../../helpers/record_video'; import { makeChecksWithStatus } from '../../../helpers/make_checks'; -import { monitorDetailsPageProvider } from '../../../page_objects/uptime/monitor_details'; +import { monitorDetailsPageProvider } from '../../page_objects/monitor_details'; journey('MonitorPingRedirects', async ({ page, params }: { page: Page; params: any }) => { recordVideo(page); diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/step_duration.journey.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/step_duration.journey.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/step_duration.journey.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/step_duration.journey.ts diff --git a/x-pack/plugins/synthetics/e2e/journeys/uptime/uptime.journey.ts b/x-pack/plugins/synthetics/e2e/uptime/journeys/uptime.journey.ts similarity index 100% rename from x-pack/plugins/synthetics/e2e/journeys/uptime/uptime.journey.ts rename to x-pack/plugins/synthetics/e2e/uptime/journeys/uptime.journey.ts diff --git a/x-pack/plugins/synthetics/e2e/page_objects/uptime/monitor_details.tsx b/x-pack/plugins/synthetics/e2e/uptime/page_objects/monitor_details.tsx similarity index 97% rename from x-pack/plugins/synthetics/e2e/page_objects/uptime/monitor_details.tsx rename to x-pack/plugins/synthetics/e2e/uptime/page_objects/monitor_details.tsx index a1d1add0bf147..db5e13e975267 100644 --- a/x-pack/plugins/synthetics/e2e/page_objects/uptime/monitor_details.tsx +++ b/x-pack/plugins/synthetics/e2e/uptime/page_objects/monitor_details.tsx @@ -6,9 +6,9 @@ */ import { Page } from '@elastic/synthetics'; -import { utilsPageProvider } from '../utils'; import { byTestId, delay, getQuerystring } from '../../helpers/utils'; -import { loginPageProvider } from '../login'; +import { loginPageProvider } from '../../page_objects/login'; +import { utilsPageProvider } from '../../page_objects/utils'; interface AlertType { id: string; diff --git a/x-pack/plugins/synthetics/e2e/page_objects/uptime/settings.tsx b/x-pack/plugins/synthetics/e2e/uptime/page_objects/settings.tsx similarity index 91% rename from x-pack/plugins/synthetics/e2e/page_objects/uptime/settings.tsx rename to x-pack/plugins/synthetics/e2e/uptime/page_objects/settings.tsx index a94f122e4f718..97f9843168ed9 100644 --- a/x-pack/plugins/synthetics/e2e/page_objects/uptime/settings.tsx +++ b/x-pack/plugins/synthetics/e2e/uptime/page_objects/settings.tsx @@ -7,8 +7,8 @@ import { expect, Page } from '@elastic/synthetics'; import { byTestId } from '../../helpers/utils'; -import { loginPageProvider } from '../login'; -import { utilsPageProvider } from '../utils'; +import { loginPageProvider } from '../../page_objects/login'; +import { utilsPageProvider } from '../../page_objects/utils'; export function settingsPageProvider({ page }: { page: Page; kibanaUrl: string }) { return { diff --git a/x-pack/plugins/synthetics/e2e/synthetics_run.ts b/x-pack/plugins/synthetics/e2e/uptime/synthetics_run.ts similarity index 83% rename from x-pack/plugins/synthetics/e2e/synthetics_run.ts rename to x-pack/plugins/synthetics/e2e/uptime/synthetics_run.ts index b03ff899fcf5f..b457a5b1e104f 100644 --- a/x-pack/plugins/synthetics/e2e/synthetics_run.ts +++ b/x-pack/plugins/synthetics/e2e/uptime/synthetics_run.ts @@ -6,13 +6,13 @@ */ import { FtrConfigProviderContext } from '@kbn/test'; import path from 'path'; -import { argv } from './helpers/parse_args_params'; -import { SyntheticsRunner } from './helpers/synthetics_runner'; +import { argv } from '../helpers/parse_args_params'; +import { SyntheticsRunner } from '../helpers/synthetics_runner'; const { headless, grep, bail: pauseOnError } = argv; async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) { - const kibanaConfig = await readConfigFile(require.resolve('./config.ts')); + const kibanaConfig = await readConfigFile(require.resolve('../config.ts')); return { ...kibanaConfig.getAll(), testRunner: async ({ getService }: any) => { @@ -23,7 +23,7 @@ async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) { }); await syntheticsRunner.setup(); - const fixturesDir = path.join(__dirname, '../e2e/fixtures/es_archiver/'); + const fixturesDir = path.join(__dirname, '../fixtures/es_archiver/'); await syntheticsRunner.loadTestData(fixturesDir, [ 'synthetics_data', diff --git a/x-pack/plugins/synthetics/scripts/base_e2e.js b/x-pack/plugins/synthetics/scripts/base_e2e.js index e65d214229c5d..99fb58cf81d6a 100644 --- a/x-pack/plugins/synthetics/scripts/base_e2e.js +++ b/x-pack/plugins/synthetics/scripts/base_e2e.js @@ -22,16 +22,6 @@ const { argv } = yargs(process.argv.slice(2)) description: 'Run all tests (an instance of Elasticsearch and kibana are needs to be available)', }) - .option('open', { - default: false, - type: 'boolean', - description: 'Opens the Synthetics Test Runner', - }) - .option('watch', { - default: false, - type: 'boolean', - description: 'Runs the server in watch mode, restarting on changes', - }) .option('pauseOnError', { default: false, type: 'boolean', @@ -63,35 +53,26 @@ if (server) { ftrScript = 'functional_test_runner'; } -const config = './synthetics_run.ts'; - -function executeSyntheticsRunner(dirPath) { +function executeSyntheticsRunner(dirPath, config = './synthetics_run.ts') { console.log(`Running ${ftrScript} in ${dirPath}`); + const grepArg = grep ? '--grep ' + grep : ''; + const kbnInstallDir = `--kibana-install-dir '${kibanaInstallDir}'`; + const options = { cwd: dirPath, stdio: 'inherit' }; + if (server) { childProcess.execSync( - `node ../../../../scripts/${ftrScript} --config ${config} --kibana-install-dir '${kibanaInstallDir}'`, - { - cwd: dirPath, - stdio: 'inherit', - } + `node ../../../../scripts/${ftrScript} --config ${config} ${kbnInstallDir}`, + options ); } else if (runner) { childProcess.execSync( - `node ../../../../scripts/${ftrScript} --config ${config} --kibana-install-dir '${kibanaInstallDir}' --headless ${headless} --bail ${pauseOnError} ${ - grep ? '--grep ' + grep : '' - }`, - { - cwd: dirPath, - stdio: 'inherit', - } + `node ../../../../scripts/${ftrScript} --config ${config} ${kbnInstallDir} --headless ${headless} --bail ${pauseOnError} ${grepArg}`, + options ); } else { childProcess.execSync( - `node ../../../../scripts/${ftrScript} --config ${config} --kibana-install-dir '${kibanaInstallDir}' --grep '${grep}'`, - { - cwd: dirPath, - stdio: 'inherit', - } + `node ../../../../scripts/${ftrScript} --config ${config} ${kbnInstallDir} ${grepArg}`, + options ); } } diff --git a/x-pack/plugins/synthetics/scripts/e2e.js b/x-pack/plugins/synthetics/scripts/e2e.js index 69a1f3319491e..f7db753124d4e 100644 --- a/x-pack/plugins/synthetics/scripts/e2e.js +++ b/x-pack/plugins/synthetics/scripts/e2e.js @@ -12,4 +12,4 @@ const path = require('path'); const e2eDir = path.join(__dirname, '../e2e'); -executeSyntheticsRunner(e2eDir); +executeSyntheticsRunner(e2eDir, './synthetics/synthetics_run.ts'); diff --git a/x-pack/plugins/synthetics/e2e/journeys/index.ts b/x-pack/plugins/synthetics/scripts/uptime_e2e.js similarity index 52% rename from x-pack/plugins/synthetics/e2e/journeys/index.ts rename to x-pack/plugins/synthetics/scripts/uptime_e2e.js index 28ea52cca8e65..10dd520b5335d 100644 --- a/x-pack/plugins/synthetics/e2e/journeys/index.ts +++ b/x-pack/plugins/synthetics/scripts/uptime_e2e.js @@ -5,5 +5,11 @@ * 2.0. */ -export * from './synthetics'; -export * from './uptime'; +/* eslint-disable no-console */ + +const { executeSyntheticsRunner } = require('./base_e2e'); +const path = require('path'); + +const e2eDir = path.join(__dirname, '../e2e'); + +executeSyntheticsRunner(e2eDir, './uptime/synthetics_run.ts'); diff --git a/x-pack/plugins/ux/e2e/tsconfig.json b/x-pack/plugins/ux/e2e/tsconfig.json index df3428e1aa0bf..881ab4db9046c 100644 --- a/x-pack/plugins/ux/e2e/tsconfig.json +++ b/x-pack/plugins/ux/e2e/tsconfig.json @@ -6,4 +6,9 @@ "outDir": "target/types", "types": [ "node"], }, + "kbn_references": [ + "@kbn/test", + "@kbn/apm-plugin", + "@kbn/es-archiver", + ], }