mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[Synthetics/Uptime] Separate e2e tests by app (#152197)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ec7ba022e1
commit
0ea97e2e8c
66 changed files with 188 additions and 341 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
15
.buildkite/pipelines/pull_request/uptime_plugin.yml
Normal file
15
.buildkite/pipelines/pull_request/uptime_plugin.yml
Normal file
|
@ -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
|
|
@ -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:
|
||||
|
|
|
@ -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/])) {
|
||||
|
|
16
.buildkite/scripts/steps/functional/uptime_plugin.sh
Executable file
16
.buildkite/scripts/steps/functional/uptime_plugin.sh
Executable file
|
@ -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}\"}
|
|
@ -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',
|
||||
],
|
||||
});
|
||||
|
|
|
@ -6,4 +6,9 @@
|
|||
"outDir": "target/types",
|
||||
"types": [ "node"],
|
||||
},
|
||||
"kbn_references": [
|
||||
"@kbn/test",
|
||||
"@kbn/apm-plugin",
|
||||
"@kbn/es-archiver",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
@ -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 }) => {
|
|
@ -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],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
|
@ -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 }) => {
|
|
@ -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 }) => {
|
|
@ -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);
|
|
@ -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 }) => {
|
|
@ -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);
|
|
@ -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);
|
|
@ -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 }) => {
|
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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 }) => {
|
|
@ -26,7 +26,7 @@ export class SyntheticsServices {
|
|||
|
||||
async getMonitor(monitorId: string): Promise<SyntheticsMonitor | null> {
|
||||
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);
|
|
@ -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 }) => {
|
|
@ -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 }) => {
|
|
@ -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 }) => {
|
|
@ -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,
|
44
x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts
Normal file
44
x-pack/plugins/synthetics/e2e/synthetics/synthetics_run.ts
Normal file
|
@ -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;
|
|
@ -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);
|
||||
}
|
||||
};
|
|
@ -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":[]}
|
|
@ -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",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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);
|
|
@ -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';
|
|
@ -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';
|
|
@ -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);
|
|
@ -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;
|
|
@ -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 {
|
|
@ -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',
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ const path = require('path');
|
|||
|
||||
const e2eDir = path.join(__dirname, '../e2e');
|
||||
|
||||
executeSyntheticsRunner(e2eDir);
|
||||
executeSyntheticsRunner(e2eDir, './synthetics/synthetics_run.ts');
|
||||
|
|
|
@ -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');
|
|
@ -6,4 +6,9 @@
|
|||
"outDir": "target/types",
|
||||
"types": [ "node"],
|
||||
},
|
||||
"kbn_references": [
|
||||
"@kbn/test",
|
||||
"@kbn/apm-plugin",
|
||||
"@kbn/es-archiver",
|
||||
],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue