@elastic/synthetics 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/cli.js +139 -165
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +158 -34
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -6
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.d.ts +1 -1
- package/dist/core/browser-service.d.ts.map +1 -1
- package/dist/core/browser-service.js +7 -6
- package/dist/core/browser-service.js.map +1 -1
- package/dist/core/expect.d.ts +25 -25
- package/dist/core/expect.d.ts.map +1 -1
- package/dist/core/expect.js.map +1 -1
- package/dist/core/gatherer.d.ts +5 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +75 -17
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -11
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +10 -17
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +12 -63
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +159 -92
- package/dist/core/runner.js.map +1 -1
- package/dist/core/transform.d.ts +37 -0
- package/dist/core/transform.d.ts.map +1 -0
- package/dist/core/transform.js +148 -0
- package/dist/core/transform.js.map +1 -0
- package/dist/dsl/index.js +5 -1
- package/dist/dsl/index.js.map +1 -1
- package/dist/dsl/journey.d.ts +9 -7
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +32 -39
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +93 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +110 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/dsl/step.d.ts +3 -2
- package/dist/dsl/step.d.ts.map +1 -1
- package/dist/dsl/step.js +6 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +115 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +331 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +24 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +241 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +84 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +36 -9
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +170 -24
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +34 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +153 -0
- package/dist/loader.js.map +1 -0
- package/dist/locations/index.d.ts +45 -0
- package/dist/locations/index.d.ts.map +1 -0
- package/dist/locations/index.js +83 -0
- package/dist/locations/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
- package/dist/locations/public-locations.d.ts.map +1 -0
- package/dist/locations/public-locations.js +41 -0
- package/dist/locations/public-locations.js.map +1 -0
- package/dist/options.d.ts +42 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +146 -0
- package/dist/options.js.map +1 -0
- package/dist/plugins/browser-console.d.ts +5 -4
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +47 -24
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/network.d.ts +24 -31
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +226 -229
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +4 -19
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js +6 -5
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +9 -5
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +46 -30
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +6 -6
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +13 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +35 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +131 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/push/index.d.ts +10 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +235 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/kibana_api.d.ts +56 -0
- package/dist/push/kibana_api.d.ts.map +1 -0
- package/dist/push/kibana_api.js +135 -0
- package/dist/push/kibana_api.js.map +1 -0
- package/dist/push/monitor.d.ts +55 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +268 -0
- package/dist/push/monitor.js.map +1 -0
- package/dist/{parse_args.d.ts → push/plugin.d.ts} +9 -6
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +66 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +45 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +109 -0
- package/dist/push/request.js.map +1 -0
- package/dist/push/utils.d.ts +31 -0
- package/dist/push/utils.d.ts.map +1 -0
- package/dist/push/utils.js +64 -0
- package/dist/push/utils.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +58 -50
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +17 -62
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +147 -177
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +90 -95
- package/dist/reporters/junit.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +35 -9
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
- package/dist/sdk/lh-trace-processor.js +114 -53
- package/dist/sdk/lh-trace-processor.js.map +1 -1
- package/dist/sdk/trace-metrics.d.ts +4 -4
- package/dist/sdk/trace-metrics.d.ts.map +1 -1
- package/dist/sdk/trace-metrics.js +3 -4
- package/dist/sdk/trace-metrics.js.map +1 -1
- package/dist/sdk/trace-processor.d.ts +11 -3
- package/dist/sdk/trace-processor.d.ts.map +1 -1
- package/dist/sdk/trace-processor.js +17 -9
- package/dist/sdk/trace-processor.js.map +1 -1
- package/package.json +38 -30
- package/src/cli.ts +223 -158
- package/src/common_types.ts +191 -34
- package/src/config.ts +1 -1
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +92 -25
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +8 -12
- package/src/core/runner.ts +158 -148
- package/src/core/transform.ts +160 -0
- package/src/dsl/journey.ts +41 -21
- package/src/dsl/monitor.ts +152 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +414 -0
- package/src/generator/index.ts +308 -0
- package/src/generator/utils.ts +84 -0
- package/src/helpers.ts +182 -16
- package/src/index.ts +21 -22
- package/src/loader.ts +171 -0
- package/src/locations/index.ts +95 -0
- package/src/{reporters/reporter.ts → locations/public-locations.ts} +12 -9
- package/src/options.ts +175 -0
- package/src/plugins/browser-console.ts +33 -8
- package/src/plugins/network.ts +266 -284
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +11 -9
- package/src/push/bundler.ts +112 -0
- package/src/push/index.ts +291 -0
- package/src/push/kibana_api.ts +191 -0
- package/src/push/monitor.ts +307 -0
- package/src/push/plugin.ts +66 -0
- package/src/push/request.ts +141 -0
- package/src/push/utils.ts +77 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +181 -201
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +8 -4
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +27 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/lightweight/heartbeat.yml +9 -0
- package/templates/synthetics.config.ts +35 -0
- package/CHANGELOG.md +0 -181
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -98
- package/dist/parse_args.js.map +0 -1
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1895
- package/src/parse_args.ts +0 -146
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/synthetics",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Elastic synthetic monitoring agent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"clean": "rimraf dist",
|
|
9
9
|
"prepublish": "npm run clean && npm run build",
|
|
10
10
|
"build": "tsc",
|
|
11
|
+
"build:locations": "sh utils/update_locations.sh",
|
|
11
12
|
"watch": "tsc -w",
|
|
12
13
|
"lint": "eslint . --rulesdir utils/eslint-rules",
|
|
13
14
|
"lint:fix": "npm run lint -- --fix",
|
|
14
|
-
"pkg": "npm run clean && npm run build && npm-pack-all",
|
|
15
15
|
"test": "npm run test:unit && npm run test:browser-service",
|
|
16
16
|
"test:unit": "jest",
|
|
17
17
|
"test:browser-service": "WSENDPOINT=ws://localhost:9322 npm run test:unit",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
-
"src"
|
|
26
|
+
"src",
|
|
27
|
+
"templates"
|
|
27
28
|
],
|
|
28
29
|
"lint-staged": {
|
|
29
30
|
"*.{js,ts}": [
|
|
@@ -39,39 +40,46 @@
|
|
|
39
40
|
"author": "",
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"archiver": "^5.3.1",
|
|
44
|
+
"commander": "^10.0.1",
|
|
45
|
+
"deepmerge": "^4.3.1",
|
|
46
|
+
"enquirer": "^2.3.6",
|
|
47
|
+
"esbuild": "^0.16.10",
|
|
48
|
+
"expect": "^28.1.3",
|
|
45
49
|
"http-proxy": "^1.18.1",
|
|
46
|
-
"kleur": "^4.1.
|
|
47
|
-
"micromatch": "^4.0.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
50
|
+
"kleur": "^4.1.5",
|
|
51
|
+
"micromatch": "^4.0.5",
|
|
52
|
+
"pirates": "^4.0.5",
|
|
53
|
+
"playwright-chromium": "=1.32.3",
|
|
54
|
+
"playwright-core": "=1.32.3",
|
|
55
|
+
"semver": "^7.5.0",
|
|
56
|
+
"sharp": "^0.32.0",
|
|
57
|
+
"snakecase-keys": "^4.0.1",
|
|
58
|
+
"sonic-boom": "^3.3.0",
|
|
59
|
+
"source-map-support": "^0.5.21",
|
|
60
|
+
"typescript": "^4.8.4",
|
|
61
|
+
"undici": "^5.21.2",
|
|
62
|
+
"yaml": "^2.2.2"
|
|
55
63
|
},
|
|
56
64
|
"devDependencies": {
|
|
57
|
-
"@types/jest": "^
|
|
58
|
-
"@types/micromatch": "^4.0.
|
|
59
|
-
"@types/node": "^
|
|
60
|
-
"@types/sharp": "^0.28.
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
62
|
-
"@typescript-eslint/parser": "^
|
|
63
|
-
"eslint": "^
|
|
65
|
+
"@types/jest": "^28.1.8",
|
|
66
|
+
"@types/micromatch": "^4.0.2",
|
|
67
|
+
"@types/node": "^16.11.59",
|
|
68
|
+
"@types/sharp": "^0.28.6",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
70
|
+
"@typescript-eslint/parser": "^5.38.0",
|
|
71
|
+
"eslint": "^8.23.1",
|
|
64
72
|
"husky": "^4.3.6",
|
|
65
|
-
"
|
|
73
|
+
"is-positive": "3.1.0",
|
|
74
|
+
"jest": "^28.1.3",
|
|
75
|
+
"jest-junit": "^15.0.0",
|
|
66
76
|
"lint-staged": "^10.5.3",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"ts-jest": "^
|
|
70
|
-
"
|
|
77
|
+
"prettier": "^2.7.1",
|
|
78
|
+
"rimraf": "^3.0.2",
|
|
79
|
+
"ts-jest": "^28.0.8",
|
|
80
|
+
"unzipper": "^0.10.11"
|
|
71
81
|
},
|
|
72
|
-
"engineStrict": true,
|
|
73
82
|
"engines": {
|
|
74
|
-
"node": "12.
|
|
75
|
-
"npm": "6"
|
|
83
|
+
"node": ">=18.12.0"
|
|
76
84
|
}
|
|
77
85
|
}
|
package/src/cli.ts
CHANGED
|
@@ -25,177 +25,242 @@
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
32
|
-
import { log } from './core/logger';
|
|
33
|
-
import program, { options } from './parse_args';
|
|
28
|
+
import { program, Option } from 'commander';
|
|
29
|
+
import { cwd } from 'process';
|
|
30
|
+
import { CliArgs, PushOptions } from './common_types';
|
|
31
|
+
import { reporters } from './reporters';
|
|
34
32
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} from './
|
|
33
|
+
normalizeOptions,
|
|
34
|
+
parseThrottling,
|
|
35
|
+
getCommonCommandOpts,
|
|
36
|
+
} from './options';
|
|
37
|
+
import { globalSetup } from './loader';
|
|
40
38
|
import { run } from './';
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const chunks = [];
|
|
62
|
-
stdin.resume();
|
|
63
|
-
stdin.setEncoding('utf-8');
|
|
64
|
-
for await (const chunk of stdin) {
|
|
65
|
-
chunks.push(chunk);
|
|
66
|
-
}
|
|
67
|
-
return chunks.join();
|
|
68
|
-
}
|
|
39
|
+
import { runner } from './core';
|
|
40
|
+
import { SyntheticsLocations } from './dsl/monitor';
|
|
41
|
+
import {
|
|
42
|
+
push,
|
|
43
|
+
loadSettings,
|
|
44
|
+
validateSettings,
|
|
45
|
+
catchIncorrectSettings,
|
|
46
|
+
warnIfThrottled,
|
|
47
|
+
} from './push';
|
|
48
|
+
import {
|
|
49
|
+
formatLocations,
|
|
50
|
+
getLocations,
|
|
51
|
+
renderLocations,
|
|
52
|
+
LocationCmdOptions,
|
|
53
|
+
} from './locations';
|
|
54
|
+
import { resolve } from 'path';
|
|
55
|
+
import { Generator } from './generator';
|
|
56
|
+
import { error } from './helpers';
|
|
57
|
+
import { LocationsMap } from './locations/public-locations';
|
|
58
|
+
import { createLightweightMonitors } from './push/monitor';
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
require(suite);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
60
|
+
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
61
|
+
const { name, version } = require('../package.json');
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
* Handle both directory and files that are passed through TTY
|
|
78
|
-
* and add them to suites
|
|
79
|
-
*/
|
|
80
|
-
async function prepareSuites(inputs: string[]) {
|
|
81
|
-
const suites = new Set<string>();
|
|
82
|
-
const addSuite = absPath => {
|
|
83
|
-
log(`Processing file: ${absPath}`);
|
|
84
|
-
suites.add(require.resolve(absPath));
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Match all files inside the directory with the
|
|
88
|
-
* .journey.{mjs|cjs|js|ts) extensions
|
|
89
|
-
*/
|
|
90
|
-
const pattern = options.pattern
|
|
91
|
-
? new RegExp(options.pattern, 'i')
|
|
92
|
-
: /.+\.journey\.([mc]js|[jt]s?)$/;
|
|
93
|
-
/**
|
|
94
|
-
* Ignore node_modules by default when running suites
|
|
95
|
-
*/
|
|
96
|
-
const ignored = /node_modules/i;
|
|
63
|
+
const { params, pattern, tags, match, playwrightOpts } = getCommonCommandOpts();
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
65
|
+
program
|
|
66
|
+
.name(`npx ${name}`)
|
|
67
|
+
.usage('[options] [dir] [files] file')
|
|
68
|
+
.option(
|
|
69
|
+
'-c, --config <path>',
|
|
70
|
+
'configuration path (default: synthetics.config.js)'
|
|
71
|
+
)
|
|
72
|
+
.addOption(pattern)
|
|
73
|
+
.addOption(tags)
|
|
74
|
+
.addOption(match)
|
|
75
|
+
.addOption(params)
|
|
76
|
+
.addOption(
|
|
77
|
+
new Option('--reporter <value>', `output reporter format`).choices(
|
|
78
|
+
Object.keys(reporters)
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
.option('--inline', 'Run inline journeys from heartbeat')
|
|
82
|
+
.option('-r, --require <modules...>', 'module(s) to preload')
|
|
83
|
+
.option('--sandbox', 'enable chromium sandboxing')
|
|
84
|
+
.option('--rich-events', 'Mimics a heartbeat run')
|
|
85
|
+
.option(
|
|
86
|
+
'--capability <features...>',
|
|
87
|
+
'Enable capabilities through feature flags'
|
|
88
|
+
)
|
|
89
|
+
.addOption(
|
|
90
|
+
new Option('--screenshots [flag]', 'take screenshots at end of each step')
|
|
91
|
+
.choices(['on', 'off', 'only-on-failure'])
|
|
92
|
+
.default('on')
|
|
93
|
+
)
|
|
94
|
+
.option(
|
|
95
|
+
'--dry-run',
|
|
96
|
+
"don't actually execute anything, report only registered journeys"
|
|
97
|
+
)
|
|
98
|
+
.option(
|
|
99
|
+
'--outfd <fd>',
|
|
100
|
+
'specify a file descriptor for logs. Default is stdout',
|
|
101
|
+
parseInt
|
|
102
|
+
)
|
|
103
|
+
.option(
|
|
104
|
+
'--ws-endpoint <endpoint>',
|
|
105
|
+
'Browser WebSocket endpoint to connect to'
|
|
106
|
+
)
|
|
107
|
+
.option(
|
|
108
|
+
'--pause-on-error',
|
|
109
|
+
'pause on error until a keypress is made in the console. Useful during development'
|
|
110
|
+
)
|
|
111
|
+
.option(
|
|
112
|
+
'--ignore-https-errors',
|
|
113
|
+
'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!'
|
|
114
|
+
)
|
|
115
|
+
.option(
|
|
116
|
+
'--quiet-exit-code',
|
|
117
|
+
'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run'
|
|
118
|
+
)
|
|
119
|
+
.option(
|
|
120
|
+
'--throttling <config>',
|
|
121
|
+
'JSON object to throttle network conditions for download and upload throughput in megabits/second and latency in milliseconds. Ex: { "download": 10, "upload": 5, "latency": 200 }.',
|
|
122
|
+
parseThrottling
|
|
123
|
+
)
|
|
124
|
+
.option(
|
|
125
|
+
'--no-throttling',
|
|
126
|
+
'Turns off default network throttling.',
|
|
127
|
+
parseThrottling
|
|
128
|
+
)
|
|
129
|
+
.addOption(playwrightOpts)
|
|
130
|
+
.version(version)
|
|
131
|
+
.description('Run synthetic tests')
|
|
132
|
+
.action(async (cliArgs: CliArgs) => {
|
|
133
|
+
const tearDown = await globalSetup(cliArgs, program.args);
|
|
134
|
+
try {
|
|
135
|
+
const options = normalizeOptions(cliArgs);
|
|
136
|
+
const results = await run(options);
|
|
137
|
+
/**
|
|
138
|
+
* Exit with error status if any journey fails
|
|
139
|
+
*/
|
|
140
|
+
if (!options.quietExitCode) {
|
|
141
|
+
for (const result of Object.values(results)) {
|
|
142
|
+
if (result.status === 'failed') {
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
109
145
|
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
146
|
+
}
|
|
147
|
+
} catch (e) {
|
|
148
|
+
console.error(e);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
} finally {
|
|
151
|
+
tearDown();
|
|
113
152
|
}
|
|
114
|
-
}
|
|
115
|
-
return suites.values();
|
|
116
|
-
}
|
|
153
|
+
});
|
|
117
154
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
// Push command
|
|
156
|
+
program
|
|
157
|
+
.command('push')
|
|
158
|
+
.description(
|
|
159
|
+
'Push all journeys in the current directory to create monitors within the Kibana monitor management UI'
|
|
160
|
+
)
|
|
161
|
+
.addOption(
|
|
162
|
+
new Option(
|
|
163
|
+
'--auth <auth>',
|
|
164
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
165
|
+
)
|
|
166
|
+
.env('SYNTHETICS_API_KEY')
|
|
167
|
+
.makeOptionMandatory(true)
|
|
168
|
+
)
|
|
169
|
+
.option(
|
|
170
|
+
'--schedule <time-in-minutes>',
|
|
171
|
+
"schedule in minutes for the pushed monitors. Setting `10`, for example, configures monitors which don't have an interval defined to run every 10 minutes.",
|
|
172
|
+
parseInt
|
|
173
|
+
)
|
|
174
|
+
.addOption(
|
|
175
|
+
new Option(
|
|
176
|
+
'--locations <locations...>',
|
|
177
|
+
'default list of locations from which your monitors will run.'
|
|
178
|
+
).choices(SyntheticsLocations)
|
|
179
|
+
)
|
|
180
|
+
.option(
|
|
181
|
+
'--private-locations <locations...>',
|
|
182
|
+
'default list of private locations from which your monitors will run.'
|
|
183
|
+
)
|
|
184
|
+
.option('--url <url>', 'Kibana URL to upload the monitors')
|
|
185
|
+
.option(
|
|
186
|
+
'--id <id>',
|
|
187
|
+
'project id that will be used for logically grouping monitors'
|
|
188
|
+
)
|
|
189
|
+
.option(
|
|
190
|
+
'--space <space>',
|
|
191
|
+
'the target Kibana spaces for the pushed monitors — spaces help you organise pushed monitors.'
|
|
192
|
+
)
|
|
193
|
+
.option('-y, --yes', 'skip all questions and run non-interactively')
|
|
194
|
+
.addOption(pattern)
|
|
195
|
+
.addOption(tags)
|
|
196
|
+
.addOption(match)
|
|
197
|
+
.addOption(params)
|
|
198
|
+
.addOption(playwrightOpts)
|
|
199
|
+
.action(async (cmdOpts: PushOptions) => {
|
|
200
|
+
const workDir = cwd();
|
|
201
|
+
const tearDown = await globalSetup({ inline: false, ...program.opts() }, [
|
|
202
|
+
workDir,
|
|
203
|
+
]);
|
|
204
|
+
try {
|
|
205
|
+
const settings = await loadSettings();
|
|
206
|
+
const options = normalizeOptions({
|
|
207
|
+
...program.opts(),
|
|
208
|
+
...settings,
|
|
209
|
+
...cmdOpts,
|
|
210
|
+
}) as PushOptions;
|
|
211
|
+
validateSettings(options);
|
|
212
|
+
await catchIncorrectSettings(settings, options);
|
|
213
|
+
const monitors = runner.buildMonitors(options);
|
|
214
|
+
if ((options as CliArgs).throttling == null) {
|
|
215
|
+
warnIfThrottled(monitors);
|
|
132
216
|
}
|
|
217
|
+
monitors.push(...(await createLightweightMonitors(workDir, options)));
|
|
218
|
+
await push(monitors, options);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
e && console.error(e);
|
|
221
|
+
process.exit(1);
|
|
222
|
+
} finally {
|
|
223
|
+
tearDown();
|
|
133
224
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Transform `.ts` files out of the box by invoking
|
|
136
|
-
* the `ts-node` via `transpile-only` mode that compiles
|
|
137
|
-
* TS files without doing any extensive type checks
|
|
138
|
-
*/
|
|
139
|
-
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
140
|
-
require('ts-node').register({
|
|
141
|
-
transpileOnly: true,
|
|
142
|
-
compilerOptions: {
|
|
143
|
-
esModuleInterop: true,
|
|
144
|
-
allowJs: true,
|
|
145
|
-
target: 'es2018',
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
/**
|
|
149
|
-
* Handle piped files by reading the STDIN
|
|
150
|
-
* ex: ls example/suites/*.js | npx @elastic/synthetics
|
|
151
|
-
*/
|
|
152
|
-
const files =
|
|
153
|
-
program.args.length > 0
|
|
154
|
-
? program.args
|
|
155
|
-
: (await readStdin()).split('\n').filter(Boolean);
|
|
156
|
-
const suites = await prepareSuites(files);
|
|
157
|
-
requireSuites(suites);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Use the NODE_ENV variable to control the environment
|
|
162
|
-
*/
|
|
163
|
-
const environment = process.env['NODE_ENV'] || 'development';
|
|
164
|
-
/**
|
|
165
|
-
* Validate and handle configs
|
|
166
|
-
*/
|
|
167
|
-
const config = readConfig(environment, options.config);
|
|
168
|
-
const params = merge(
|
|
169
|
-
config.params,
|
|
170
|
-
options.suiteParams || {},
|
|
171
|
-
options.params || {}
|
|
172
|
-
);
|
|
173
|
-
const playwrightOptions = merge(config.playwrightOptions, {
|
|
174
|
-
headless: options.headless,
|
|
175
|
-
chromiumSandbox: options.sandbox,
|
|
176
225
|
});
|
|
177
|
-
/**
|
|
178
|
-
* use JSON reporter if json flag is enabled
|
|
179
|
-
*/
|
|
180
|
-
const reporter = options.json ? 'json' : options.reporter;
|
|
181
226
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
227
|
+
// Init command
|
|
228
|
+
program
|
|
229
|
+
.command('init [dir]')
|
|
230
|
+
.description('Initialize Elastic synthetics project')
|
|
231
|
+
.action(async (dir = '') => {
|
|
232
|
+
try {
|
|
233
|
+
const generator = await new Generator(resolve(process.cwd(), dir));
|
|
234
|
+
await generator.setup();
|
|
235
|
+
} catch (e) {
|
|
236
|
+
e && error(e);
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
188
239
|
});
|
|
189
240
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
241
|
+
// Locations command
|
|
242
|
+
program
|
|
243
|
+
.command('locations')
|
|
244
|
+
.description(
|
|
245
|
+
`List all locations to run the synthetics monitors. Pass optional '--url' and '--auth' to list private locations.`
|
|
246
|
+
)
|
|
247
|
+
.option('--url <url>', 'Kibana URL to fetch all public and private locations')
|
|
248
|
+
.option(
|
|
249
|
+
'--auth <auth>',
|
|
250
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
251
|
+
)
|
|
252
|
+
.action(async (cmdOpts: LocationCmdOptions) => {
|
|
253
|
+
try {
|
|
254
|
+
let locations = Object.keys(LocationsMap);
|
|
255
|
+
if (cmdOpts.auth && cmdOpts.url) {
|
|
256
|
+
const allLocations = await getLocations(cmdOpts);
|
|
257
|
+
locations = formatLocations(allLocations);
|
|
258
|
+
}
|
|
259
|
+
renderLocations(locations);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
e && error(e);
|
|
195
262
|
process.exit(1);
|
|
196
263
|
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
process.exit(1);
|
|
201
|
-
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
program.parse(process.argv);
|