@elastic/synthetics 1.1.0 → 1.3.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/dist/cli.js +7 -12
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +4 -12
- package/dist/common_types.d.ts.map +1 -1
- package/dist/core/runner.d.ts +2 -2
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +3 -3
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/monitor.d.ts +9 -5
- package/dist/dsl/monitor.d.ts.map +1 -1
- package/dist/dsl/monitor.js +4 -1
- package/dist/dsl/monitor.js.map +1 -1
- package/dist/options.d.ts +5 -4
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +33 -12
- package/dist/options.js.map +1 -1
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +3 -3
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/push/index.d.ts +1 -0
- package/dist/push/index.d.ts.map +1 -1
- package/dist/push/index.js +6 -1
- package/dist/push/index.js.map +1 -1
- package/dist/push/monitor.d.ts +4 -5
- package/dist/push/monitor.d.ts.map +1 -1
- package/dist/push/monitor.js +45 -17
- package/dist/push/monitor.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +21 -23
- package/src/common_types.ts +10 -16
- package/src/core/runner.ts +5 -4
- package/src/dsl/monitor.ts +14 -6
- package/src/options.ts +38 -20
- package/src/plugins/browser-console.ts +4 -3
- package/src/push/index.ts +8 -0
- package/src/push/monitor.ts +59 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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ED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,kDA+B7C"}
|
package/dist/push/monitor.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.parseSchedule = exports.parseAlertConfig = exports.buildMonitorFromYaml = exports.createLightweightMonitors = exports.buildMonitorSchema = exports.getLocalMonitors = exports.diffMonitors = void 0;
|
|
27
|
+
exports.parseSchedule = exports.getAlertKeyValue = exports.parseAlertConfig = exports.buildMonitorFromYaml = exports.createLightweightMonitors = exports.buildMonitorSchema = exports.getLocalMonitors = exports.diffMonitors = void 0;
|
|
28
28
|
const promises_1 = require("fs/promises");
|
|
29
29
|
const path_1 = require("path");
|
|
30
30
|
const yaml_1 = require("yaml");
|
|
@@ -166,10 +166,6 @@ async function createLightweightMonitors(workDir, options) {
|
|
|
166
166
|
continue;
|
|
167
167
|
}
|
|
168
168
|
const config = monNode.toJSON();
|
|
169
|
-
// Filter based on matched tags and name
|
|
170
|
-
if (!(0, helpers_1.isMatch)(config.tags, config.name, options.tags, options.match)) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
169
|
const { line, col } = lineCounter.linePos(monNode.srcToken.offset);
|
|
174
170
|
try {
|
|
175
171
|
const mon = buildMonitorFromYaml(config, options);
|
|
@@ -195,11 +191,14 @@ function buildMonitorFromYaml(config, options) {
|
|
|
195
191
|
}
|
|
196
192
|
}
|
|
197
193
|
const schedule = config.schedule && parseSchedule(String(config.schedule));
|
|
198
|
-
const privateLocations = config['private_locations'] ||
|
|
194
|
+
const privateLocations = config['private_locations'] ||
|
|
195
|
+
config.privateLocations ||
|
|
196
|
+
options.privateLocations;
|
|
199
197
|
delete config['private_locations'];
|
|
200
|
-
const alertConfig = (0, exports.parseAlertConfig)(config);
|
|
198
|
+
const alertConfig = (0, exports.parseAlertConfig)(config, options.alert);
|
|
201
199
|
const mon = new monitor_1.Monitor({
|
|
202
200
|
locations: options.locations,
|
|
201
|
+
tags: options.tags,
|
|
203
202
|
...config,
|
|
204
203
|
privateLocations,
|
|
205
204
|
schedule: schedule || options.schedule,
|
|
@@ -215,19 +214,48 @@ function buildMonitorFromYaml(config, options) {
|
|
|
215
214
|
return mon;
|
|
216
215
|
}
|
|
217
216
|
exports.buildMonitorFromYaml = buildMonitorFromYaml;
|
|
218
|
-
const parseAlertConfig = (config) => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
},
|
|
226
|
-
};
|
|
217
|
+
const parseAlertConfig = (config, gConfig) => {
|
|
218
|
+
// If the user has provided a global alert config, merge it with the monitor alert config
|
|
219
|
+
const status = getAlertKeyValue('status', config, gConfig);
|
|
220
|
+
const tls = getAlertKeyValue('tls', config, gConfig);
|
|
221
|
+
const result = {};
|
|
222
|
+
if (status) {
|
|
223
|
+
result['status'] = status;
|
|
227
224
|
}
|
|
228
|
-
|
|
225
|
+
if (tls) {
|
|
226
|
+
result['tls'] = tls;
|
|
227
|
+
}
|
|
228
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
229
229
|
};
|
|
230
230
|
exports.parseAlertConfig = parseAlertConfig;
|
|
231
|
+
function getAlertKeyValue(key, config, alertConfig) {
|
|
232
|
+
const value = config.alert;
|
|
233
|
+
if (value?.[key]?.enabled !== undefined) {
|
|
234
|
+
return {
|
|
235
|
+
enabled: value[key].enabled,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (value?.[`${key}.enabled`] !== undefined) {
|
|
239
|
+
const val = value?.[`${key}.enabled`];
|
|
240
|
+
delete value?.[`${key}.enabled`];
|
|
241
|
+
if (Object.keys(value).length === 0) {
|
|
242
|
+
delete config.alert;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
enabled: val,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const rootKey = `alert.${key}.enabled`;
|
|
249
|
+
if (config[rootKey] !== undefined) {
|
|
250
|
+
const enabled = config[rootKey];
|
|
251
|
+
delete config[rootKey];
|
|
252
|
+
return {
|
|
253
|
+
enabled,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return alertConfig?.[key];
|
|
257
|
+
}
|
|
258
|
+
exports.getAlertKeyValue = getAlertKeyValue;
|
|
231
259
|
function parseSchedule(schedule) {
|
|
232
260
|
const EVERY_SYNTAX = '@every';
|
|
233
261
|
if (!(schedule + '').startsWith(EVERY_SYNTAX)) {
|
package/dist/push/monitor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,0CAAkD;AAClD,+BAAqC;AACrC,+BAAoE;AACpE,yCAAyC;AACzC,uCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,0CAAkD;AAClD,+BAAqC;AACrC,+BAAoE;AACpE,yCAAyC;AACzC,uCAAoC;AACpC,wCAAqE;AACrE,oEAA6D;AAC7D,4CAKwB;AAExB,mCAAiD;AAEjD,mDAAmD;AACnD,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAgBhD,SAAS,iBAAiB,CAAC,SAAsC;IAC/D,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,+BAAY,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,gBAAgB;IACpB,8CAA8C;IAC9C,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3B,uDA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AC9B,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,IAAI,aAAa,GAAG,EAAE,GAAG,EAAE,CAAC;gBACnC,MAAM;SACT;KACF;IACD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AA/BD,sCA+BC;AAED,8DAA8D;AAC9D,iCAAiC;AACjC,SAAS,eAAe,CAAC,OAAO;IAC9B,IAAI,OAAO,GAAqC,2BAAiB,CAAC,CAAC,CAAC,CAAC;IACrE,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,2BAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,2BAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;QACtD,IAAI,IAAI,IAAI,IAAI,EAAE;YAChB,OAAO,GAAG,2BAAiB,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,GAAG,IAAI,CAAC;SACb;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/synthetics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Elastic synthetic monitoring agent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"kleur": "^4.1.5",
|
|
51
51
|
"micromatch": "^4.0.5",
|
|
52
52
|
"pirates": "^4.0.5",
|
|
53
|
-
"playwright-chromium": "=1.
|
|
54
|
-
"playwright-core": "=1.
|
|
55
|
-
"semver": "^7.5.
|
|
53
|
+
"playwright-chromium": "=1.35.0",
|
|
54
|
+
"playwright-core": "=1.35.0",
|
|
55
|
+
"semver": "^7.5.2",
|
|
56
56
|
"sharp": "^0.32.0",
|
|
57
57
|
"snakecase-keys": "^4.0.1",
|
|
58
58
|
"sonic-boom": "^3.3.0",
|
package/src/cli.ts
CHANGED
|
@@ -38,13 +38,7 @@ import { globalSetup } from './loader';
|
|
|
38
38
|
import { run } from './';
|
|
39
39
|
import { runner } from './core';
|
|
40
40
|
import { SyntheticsLocations } from './dsl/monitor';
|
|
41
|
-
import {
|
|
42
|
-
push,
|
|
43
|
-
loadSettings,
|
|
44
|
-
validateSettings,
|
|
45
|
-
catchIncorrectSettings,
|
|
46
|
-
warnIfThrottled,
|
|
47
|
-
} from './push';
|
|
41
|
+
import { push, loadSettings, validatePush, warnIfThrottled } from './push';
|
|
48
42
|
import {
|
|
49
43
|
formatLocations,
|
|
50
44
|
getLocations,
|
|
@@ -61,7 +55,7 @@ import { getVersion } from './push/kibana_api';
|
|
|
61
55
|
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
62
56
|
const { name, version } = require('../package.json');
|
|
63
57
|
|
|
64
|
-
const { params, pattern,
|
|
58
|
+
const { params, pattern, playwrightOpts } = getCommonCommandOpts();
|
|
65
59
|
|
|
66
60
|
program
|
|
67
61
|
.name(`npx ${name}`)
|
|
@@ -71,9 +65,12 @@ program
|
|
|
71
65
|
'configuration path (default: synthetics.config.js)'
|
|
72
66
|
)
|
|
73
67
|
.addOption(pattern)
|
|
74
|
-
.addOption(tags)
|
|
75
|
-
.addOption(match)
|
|
76
68
|
.addOption(params)
|
|
69
|
+
.option('--tags <name...>', 'run tests with a tag that matches the glob')
|
|
70
|
+
.option(
|
|
71
|
+
'--match <name>',
|
|
72
|
+
'run tests with a name or tags that matches the glob'
|
|
73
|
+
)
|
|
77
74
|
.addOption(
|
|
78
75
|
new Option('--reporter <value>', `output reporter format`).choices(
|
|
79
76
|
Object.keys(reporters)
|
|
@@ -88,9 +85,10 @@ program
|
|
|
88
85
|
'Enable capabilities through feature flags'
|
|
89
86
|
)
|
|
90
87
|
.addOption(
|
|
91
|
-
new Option(
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
new Option(
|
|
89
|
+
'--screenshots [flag]',
|
|
90
|
+
'take screenshots at end of each step'
|
|
91
|
+
).choices(['on', 'off', 'only-on-failure'])
|
|
94
92
|
)
|
|
95
93
|
.option(
|
|
96
94
|
'--dry-run',
|
|
@@ -133,7 +131,7 @@ program
|
|
|
133
131
|
.action(async (cliArgs: CliArgs) => {
|
|
134
132
|
const tearDown = await globalSetup(cliArgs, program.args);
|
|
135
133
|
try {
|
|
136
|
-
const options = normalizeOptions(cliArgs);
|
|
134
|
+
const options = normalizeOptions(cliArgs, 'run');
|
|
137
135
|
const results = await run(options);
|
|
138
136
|
/**
|
|
139
137
|
* Exit with error status if any journey fails
|
|
@@ -193,8 +191,6 @@ program
|
|
|
193
191
|
)
|
|
194
192
|
.option('-y, --yes', 'skip all questions and run non-interactively')
|
|
195
193
|
.addOption(pattern)
|
|
196
|
-
.addOption(tags)
|
|
197
|
-
.addOption(match)
|
|
198
194
|
.addOption(params)
|
|
199
195
|
.addOption(playwrightOpts)
|
|
200
196
|
.action(async (cmdOpts: PushOptions) => {
|
|
@@ -204,13 +200,15 @@ program
|
|
|
204
200
|
]);
|
|
205
201
|
try {
|
|
206
202
|
const settings = await loadSettings();
|
|
207
|
-
const options = normalizeOptions(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
203
|
+
const options = normalizeOptions(
|
|
204
|
+
{
|
|
205
|
+
...program.opts(),
|
|
206
|
+
...settings,
|
|
207
|
+
...cmdOpts,
|
|
208
|
+
},
|
|
209
|
+
'push'
|
|
210
|
+
) as PushOptions;
|
|
211
|
+
await validatePush(options, settings);
|
|
214
212
|
const monitors = runner.buildMonitors(options);
|
|
215
213
|
if ((options as CliArgs).throttling == null) {
|
|
216
214
|
warnIfThrottled(monitors);
|
package/src/common_types.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from 'playwright-chromium';
|
|
35
35
|
import { Step } from './dsl';
|
|
36
36
|
import { BuiltInReporterName, ReporterInstance } from './reporters';
|
|
37
|
-
import { MonitorConfig } from './dsl/monitor';
|
|
37
|
+
import { AlertConfig, MonitorConfig } from './dsl/monitor';
|
|
38
38
|
|
|
39
39
|
export type VoidCallback = () => void;
|
|
40
40
|
export type Location = {
|
|
@@ -201,24 +201,24 @@ type BaseArgs = {
|
|
|
201
201
|
params?: Params;
|
|
202
202
|
screenshots?: ScreenshotOptions;
|
|
203
203
|
dryRun?: boolean;
|
|
204
|
+
pattern?: string;
|
|
204
205
|
match?: string;
|
|
205
206
|
tags?: Array<string>;
|
|
206
207
|
outfd?: number;
|
|
207
208
|
wsEndpoint?: string;
|
|
208
209
|
pauseOnError?: boolean;
|
|
209
|
-
ignoreHttpsErrors?: boolean;
|
|
210
210
|
playwrightOptions?: PlaywrightOptions;
|
|
211
211
|
quietExitCode?: boolean;
|
|
212
212
|
throttling?: MonitorConfig['throttling'];
|
|
213
213
|
schedule?: MonitorConfig['schedule'];
|
|
214
214
|
locations?: MonitorConfig['locations'];
|
|
215
215
|
privateLocations?: MonitorConfig['privateLocations'];
|
|
216
|
+
alert?: AlertConfig;
|
|
216
217
|
};
|
|
217
218
|
|
|
218
219
|
export type CliArgs = BaseArgs & {
|
|
219
220
|
config?: string;
|
|
220
221
|
reporter?: BuiltInReporterName;
|
|
221
|
-
pattern?: string;
|
|
222
222
|
inline?: boolean;
|
|
223
223
|
require?: Array<string>;
|
|
224
224
|
sandbox?: boolean;
|
|
@@ -234,23 +234,16 @@ export type RunOptions = BaseArgs & {
|
|
|
234
234
|
trace?: boolean;
|
|
235
235
|
filmstrips?: boolean;
|
|
236
236
|
environment?: string;
|
|
237
|
-
playwrightOptions?: PlaywrightOptions;
|
|
238
237
|
networkConditions?: NetworkConditions;
|
|
239
238
|
reporter?: BuiltInReporterName | ReporterInstance;
|
|
240
239
|
};
|
|
241
240
|
|
|
242
|
-
export type PushOptions = Partial<ProjectSettings> &
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
kibanaVersion?: number;
|
|
249
|
-
yes?: boolean;
|
|
250
|
-
pattern?: string;
|
|
251
|
-
match?: string;
|
|
252
|
-
tags?: Array<string>;
|
|
253
|
-
};
|
|
241
|
+
export type PushOptions = Partial<ProjectSettings> &
|
|
242
|
+
Partial<BaseArgs> & {
|
|
243
|
+
auth: string;
|
|
244
|
+
kibanaVersion?: number;
|
|
245
|
+
yes?: boolean;
|
|
246
|
+
};
|
|
254
247
|
|
|
255
248
|
export type ProjectSettings = {
|
|
256
249
|
id: string;
|
|
@@ -264,6 +257,7 @@ export type PlaywrightOptions = LaunchOptions &
|
|
|
264
257
|
actionTimeout?: number;
|
|
265
258
|
navigationTimeout?: number;
|
|
266
259
|
};
|
|
260
|
+
|
|
267
261
|
export type SyntheticsConfig = {
|
|
268
262
|
params?: Params;
|
|
269
263
|
playwrightOptions?: PlaywrightOptions;
|
package/src/core/runner.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
RunOptions,
|
|
45
45
|
JourneyResult,
|
|
46
46
|
StepResult,
|
|
47
|
+
PushOptions,
|
|
47
48
|
} from '../common_types';
|
|
48
49
|
import { PluginManager } from '../plugins';
|
|
49
50
|
import { PerformanceManager } from '../plugins';
|
|
@@ -383,7 +384,7 @@ export default class Runner {
|
|
|
383
384
|
await mkdir(CACHE_PATH, { recursive: true });
|
|
384
385
|
}
|
|
385
386
|
|
|
386
|
-
buildMonitors(options:
|
|
387
|
+
buildMonitors(options: PushOptions) {
|
|
387
388
|
/**
|
|
388
389
|
* Update the global monitor configuration required for
|
|
389
390
|
* setting defaults
|
|
@@ -395,13 +396,13 @@ export default class Runner {
|
|
|
395
396
|
privateLocations: options.privateLocations,
|
|
396
397
|
params: options.params,
|
|
397
398
|
playwrightOptions: options.playwrightOptions,
|
|
399
|
+
screenshot: options.screenshots,
|
|
400
|
+
tags: options.tags,
|
|
401
|
+
alert: options.alert,
|
|
398
402
|
});
|
|
399
403
|
|
|
400
404
|
const monitors: Monitor[] = [];
|
|
401
405
|
for (const journey of this.journeys) {
|
|
402
|
-
if (!journey.isMatch(options.match, options.tags)) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
406
|
this.#currentJourney = journey;
|
|
406
407
|
/**
|
|
407
408
|
* Execute dummy callback to get all monitor specific
|
package/src/dsl/monitor.ts
CHANGED
|
@@ -44,6 +44,15 @@ export const ALLOWED_SCHEDULES = [
|
|
|
44
44
|
1, 3, 5, 10, 15, 20, 30, 60, 120, 240,
|
|
45
45
|
] as const;
|
|
46
46
|
|
|
47
|
+
export interface AlertConfig {
|
|
48
|
+
status?: {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
};
|
|
51
|
+
tls?: {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
export type MonitorConfig = {
|
|
48
57
|
id?: string;
|
|
49
58
|
name?: string;
|
|
@@ -62,11 +71,7 @@ export type MonitorConfig = {
|
|
|
62
71
|
screenshot?: ScreenshotOptions;
|
|
63
72
|
params?: Params;
|
|
64
73
|
playwrightOptions?: PlaywrightOptions;
|
|
65
|
-
alert?:
|
|
66
|
-
status: {
|
|
67
|
-
enabled: boolean;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
74
|
+
alert?: AlertConfig;
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
type MonitorFilter = {
|
|
@@ -86,7 +91,10 @@ export class Monitor {
|
|
|
86
91
|
update(globalOpts: MonitorConfig = {}) {
|
|
87
92
|
this.config = merge(globalOpts, this.config, {
|
|
88
93
|
arrayMerge(target, source) {
|
|
89
|
-
|
|
94
|
+
if (source && source.length > 0) {
|
|
95
|
+
return [...new Set(source)];
|
|
96
|
+
}
|
|
97
|
+
return target;
|
|
90
98
|
},
|
|
91
99
|
});
|
|
92
100
|
}
|
package/src/options.ts
CHANGED
|
@@ -26,10 +26,15 @@
|
|
|
26
26
|
import merge from 'deepmerge';
|
|
27
27
|
import { createOption } from 'commander';
|
|
28
28
|
import { readConfig } from './config';
|
|
29
|
-
import type { CliArgs, RunOptions } from './common_types';
|
|
30
|
-
import { THROTTLING_WARNING_MSG, warn } from './helpers';
|
|
29
|
+
import type { CliArgs, PushOptions, RunOptions } from './common_types';
|
|
30
|
+
import { THROTTLING_WARNING_MSG, error, warn } from './helpers';
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
type Mode = 'run' | 'push';
|
|
33
|
+
|
|
34
|
+
export function normalizeOptions(
|
|
35
|
+
cliArgs: CliArgs,
|
|
36
|
+
mode: Mode = 'run'
|
|
37
|
+
): RunOptions {
|
|
33
38
|
const options: RunOptions = {
|
|
34
39
|
...cliArgs,
|
|
35
40
|
environment: process.env['NODE_ENV'] || 'development',
|
|
@@ -107,16 +112,39 @@ export function normalizeOptions(cliArgs: CliArgs): RunOptions {
|
|
|
107
112
|
};
|
|
108
113
|
|
|
109
114
|
/**
|
|
110
|
-
*
|
|
115
|
+
* Merge default options based on the mode of operation whether we are running tests locally
|
|
116
|
+
* or pushing the project monitors
|
|
111
117
|
*/
|
|
112
|
-
|
|
118
|
+
switch (mode) {
|
|
119
|
+
case 'run':
|
|
120
|
+
options.screenshots = cliArgs.screenshots ?? 'on';
|
|
121
|
+
break;
|
|
122
|
+
case 'push':
|
|
123
|
+
validatePushOptions(options as PushOptions);
|
|
124
|
+
/**
|
|
125
|
+
* Merge the default monitor config from synthetics.config.ts file
|
|
126
|
+
* with the CLI options passed via push command
|
|
127
|
+
*/
|
|
128
|
+
const monitor = config.monitor;
|
|
129
|
+
for (const key of Object.keys(monitor || {})) {
|
|
130
|
+
// screenshots require special handling as the flags are different
|
|
131
|
+
if (key === 'screenshot') {
|
|
132
|
+
options.screenshots = options.screenshots ?? monitor[key];
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
options[key] = options[key] ?? monitor[key];
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
return options;
|
|
140
|
+
}
|
|
113
141
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
cliArgs.privateLocations ?? monitor?.privateLocations;
|
|
142
|
+
export function validatePushOptions(opts: PushOptions) {
|
|
143
|
+
if (opts.tags || opts.match) {
|
|
144
|
+
throw error(`Aborted. Invalid CLI flags.
|
|
118
145
|
|
|
119
|
-
|
|
146
|
+
Tags and Match are not supported in push command.`);
|
|
147
|
+
}
|
|
120
148
|
}
|
|
121
149
|
|
|
122
150
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
@@ -156,20 +184,10 @@ export function getCommonCommandOpts() {
|
|
|
156
184
|
'--pattern <pattern>',
|
|
157
185
|
'RegExp pattern to match journey/monitor files that are different from the default (ex: /*.journey.(ts|js)$/)'
|
|
158
186
|
);
|
|
159
|
-
const tags = createOption(
|
|
160
|
-
'--tags <name...>',
|
|
161
|
-
'run/push tests with a tag that matches the glob'
|
|
162
|
-
);
|
|
163
|
-
const match = createOption(
|
|
164
|
-
'--match <name>',
|
|
165
|
-
'run/push tests with a name or tags that matches the glob'
|
|
166
|
-
);
|
|
167
187
|
|
|
168
188
|
return {
|
|
169
189
|
params,
|
|
170
190
|
playwrightOpts,
|
|
171
191
|
pattern,
|
|
172
|
-
tags,
|
|
173
|
-
match,
|
|
174
192
|
};
|
|
175
193
|
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import type { ConsoleMessage } from 'playwright-core';
|
|
26
27
|
import { BrowserMessage, Driver } from '../common_types';
|
|
27
28
|
import { log } from '../core/logger';
|
|
28
29
|
import { Step } from '../dsl';
|
|
@@ -36,7 +37,7 @@ export class BrowserConsole {
|
|
|
36
37
|
|
|
37
38
|
constructor(private driver: Driver) {}
|
|
38
39
|
|
|
39
|
-
private consoleEventListener = msg => {
|
|
40
|
+
private consoleEventListener = (msg: ConsoleMessage) => {
|
|
40
41
|
if (!this._currentStep) {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
@@ -78,12 +79,12 @@ export class BrowserConsole {
|
|
|
78
79
|
|
|
79
80
|
start() {
|
|
80
81
|
log(`Plugins: started collecting console events`);
|
|
81
|
-
this.driver.
|
|
82
|
+
this.driver.context.on('console', this.consoleEventListener);
|
|
82
83
|
this.driver.page.on('pageerror', this.pageErrorEventListener);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
stop() {
|
|
86
|
-
this.driver.
|
|
87
|
+
this.driver.context.off('console', this.consoleEventListener);
|
|
87
88
|
this.driver.page.off('pageerror', this.pageErrorEventListener);
|
|
88
89
|
log(`Plugins: stopped collecting console events`);
|
|
89
90
|
return this.messages;
|
package/src/push/index.ts
CHANGED
|
@@ -174,6 +174,14 @@ ${INSTALLATION_HELP}`);
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
export async function validatePush(
|
|
178
|
+
opts: PushOptions,
|
|
179
|
+
settings: ProjectSettings
|
|
180
|
+
) {
|
|
181
|
+
validateSettings(opts);
|
|
182
|
+
await catchIncorrectSettings(settings, opts);
|
|
183
|
+
}
|
|
184
|
+
|
|
177
185
|
export function validateSettings(opts: PushOptions) {
|
|
178
186
|
const INVALID = 'Aborted. Invalid synthetics project settings.';
|
|
179
187
|
|
package/src/push/monitor.ts
CHANGED
|
@@ -28,9 +28,14 @@ import { extname, join } from 'path';
|
|
|
28
28
|
import { LineCounter, parseDocument, YAMLSeq, YAMLMap } from 'yaml';
|
|
29
29
|
import { bold, red } from 'kleur/colors';
|
|
30
30
|
import { Bundler } from './bundler';
|
|
31
|
-
import { SYNTHETICS_PATH, totalist, indent, warn
|
|
31
|
+
import { SYNTHETICS_PATH, totalist, indent, warn } from '../helpers';
|
|
32
32
|
import { LocationsMap } from '../locations/public-locations';
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
AlertConfig,
|
|
35
|
+
ALLOWED_SCHEDULES,
|
|
36
|
+
Monitor,
|
|
37
|
+
MonitorConfig,
|
|
38
|
+
} from '../dsl/monitor';
|
|
34
39
|
import { PushOptions } from '../common_types';
|
|
35
40
|
import { isParamOptionSupported } from './utils';
|
|
36
41
|
|
|
@@ -198,10 +203,6 @@ export async function createLightweightMonitors(
|
|
|
198
203
|
continue;
|
|
199
204
|
}
|
|
200
205
|
const config = monNode.toJSON();
|
|
201
|
-
// Filter based on matched tags and name
|
|
202
|
-
if (!isMatch(config.tags, config.name, options.tags, options.match)) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
206
|
const { line, col } = lineCounter.linePos(monNode.srcToken.offset);
|
|
206
207
|
try {
|
|
207
208
|
const mon = buildMonitorFromYaml(config, options);
|
|
@@ -232,12 +233,14 @@ export function buildMonitorFromYaml(
|
|
|
232
233
|
}
|
|
233
234
|
const schedule = config.schedule && parseSchedule(String(config.schedule));
|
|
234
235
|
const privateLocations =
|
|
235
|
-
config['private_locations'] ||
|
|
236
|
+
config['private_locations'] ||
|
|
237
|
+
config.privateLocations ||
|
|
238
|
+
options.privateLocations;
|
|
236
239
|
delete config['private_locations'];
|
|
237
|
-
|
|
238
|
-
const alertConfig = parseAlertConfig(config);
|
|
240
|
+
const alertConfig = parseAlertConfig(config, options.alert);
|
|
239
241
|
const mon = new Monitor({
|
|
240
242
|
locations: options.locations,
|
|
243
|
+
tags: options.tags,
|
|
241
244
|
...config,
|
|
242
245
|
privateLocations,
|
|
243
246
|
schedule: schedule || options.schedule,
|
|
@@ -254,18 +257,56 @@ export function buildMonitorFromYaml(
|
|
|
254
257
|
return mon;
|
|
255
258
|
}
|
|
256
259
|
|
|
257
|
-
export const parseAlertConfig = (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
export const parseAlertConfig = (
|
|
261
|
+
config: MonitorConfig,
|
|
262
|
+
gConfig?: AlertConfig
|
|
263
|
+
) => {
|
|
264
|
+
// If the user has provided a global alert config, merge it with the monitor alert config
|
|
265
|
+
const status = getAlertKeyValue('status', config, gConfig);
|
|
266
|
+
const tls = getAlertKeyValue('tls', config, gConfig);
|
|
267
|
+
const result = {};
|
|
268
|
+
if (status) {
|
|
269
|
+
result['status'] = status;
|
|
270
|
+
}
|
|
271
|
+
if (tls) {
|
|
272
|
+
result['tls'] = tls;
|
|
273
|
+
}
|
|
274
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export function getAlertKeyValue(
|
|
278
|
+
key: 'status' | 'tls',
|
|
279
|
+
config: MonitorConfig,
|
|
280
|
+
alertConfig?: AlertConfig
|
|
281
|
+
): { enabled: boolean } {
|
|
282
|
+
const value = config.alert;
|
|
283
|
+
if (value?.[key]?.enabled !== undefined) {
|
|
261
284
|
return {
|
|
262
|
-
|
|
263
|
-
enabled: value,
|
|
264
|
-
},
|
|
285
|
+
enabled: value[key].enabled,
|
|
265
286
|
};
|
|
266
287
|
}
|
|
267
|
-
|
|
268
|
-
}
|
|
288
|
+
|
|
289
|
+
if (value?.[`${key}.enabled`] !== undefined) {
|
|
290
|
+
const val = value?.[`${key}.enabled`];
|
|
291
|
+
delete value?.[`${key}.enabled`];
|
|
292
|
+
if (Object.keys(value).length === 0) {
|
|
293
|
+
delete config.alert;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
enabled: val,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const rootKey = `alert.${key}.enabled`;
|
|
300
|
+
if (config[rootKey] !== undefined) {
|
|
301
|
+
const enabled = config[rootKey];
|
|
302
|
+
delete config[rootKey];
|
|
303
|
+
return {
|
|
304
|
+
enabled,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return alertConfig?.[key];
|
|
309
|
+
}
|
|
269
310
|
|
|
270
311
|
export function parseSchedule(schedule: string) {
|
|
271
312
|
const EVERY_SYNTAX = '@every';
|