@elastic/synthetics 1.17.2 → 1.18.1
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.map +1 -1
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/globals.d.ts +1 -0
- package/dist/core/globals.d.ts.map +1 -1
- package/dist/core/globals.js +12 -1
- package/dist/core/globals.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +2 -7
- package/dist/core/logger.js.map +1 -1
- package/dist/core/mfa.d.ts.map +1 -1
- package/dist/core/mfa.js +1 -1
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +1 -0
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/monitor.d.ts +4 -0
- package/dist/dsl/monitor.d.ts.map +1 -1
- package/dist/dsl/monitor.js +6 -0
- package/dist/dsl/monitor.js.map +1 -1
- package/dist/formatter/javascript.d.ts.map +1 -1
- package/dist/formatter/javascript.js.map +1 -1
- package/dist/generator/utils.d.ts +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +2 -5
- package/dist/push/bundler.d.ts.map +1 -1
- package/dist/push/bundler.js +15 -30
- package/dist/push/bundler.js.map +1 -1
- package/dist/push/index.d.ts.map +1 -1
- package/dist/push/index.js +38 -15
- package/dist/push/index.js.map +1 -1
- package/dist/push/kibana_api.d.ts +2 -1
- package/dist/push/kibana_api.d.ts.map +1 -1
- package/dist/push/kibana_api.js +6 -4
- package/dist/push/kibana_api.js.map +1 -1
- package/dist/push/monitor.d.ts +5 -1
- package/dist/push/monitor.d.ts.map +1 -1
- package/dist/push/monitor.js +14 -2
- package/dist/push/monitor.js.map +1 -1
- package/dist/push/request.d.ts +2 -2
- package/dist/push/request.d.ts.map +1 -1
- package/dist/push/request.js +7 -6
- package/dist/push/request.js.map +1 -1
- package/dist/push/run-local.d.ts +27 -0
- package/dist/push/run-local.d.ts.map +1 -0
- package/dist/push/run-local.js +132 -0
- package/dist/push/run-local.js.map +1 -0
- package/dist/push/utils.d.ts +6 -1
- package/dist/push/utils.d.ts.map +1 -1
- package/dist/push/utils.js +61 -6
- package/dist/push/utils.js.map +1 -1
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/build_kite_cli.d.ts.map +1 -1
- package/dist/reporters/build_kite_cli.js.map +1 -1
- package/dist/reporters/json.d.ts +1 -1
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +6 -2
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js.map +1 -1
- package/package.json +13 -10
- package/src/cli.ts +8 -3
- package/src/common_types.ts +1 -1
- package/src/config.ts +3 -1
- package/src/core/globals.ts +12 -0
- package/src/core/logger.ts +2 -8
- package/src/core/mfa.ts +11 -11
- package/src/core/runner.ts +1 -0
- package/src/dsl/monitor.ts +7 -0
- package/src/formatter/javascript.ts +3 -1
- package/src/helpers.ts +3 -3
- package/src/loader.ts +1 -1
- package/src/plugins/tracing.ts +1 -1
- package/src/push/bundler.ts +16 -36
- package/src/push/index.ts +59 -24
- package/src/push/kibana_api.ts +7 -3
- package/src/push/monitor.ts +18 -5
- package/src/push/request.ts +26 -7
- package/src/push/run-local.ts +155 -0
- package/src/push/utils.ts +87 -9
- package/src/reporters/base.ts +8 -4
- package/src/reporters/build_kite_cli.ts +7 -6
- package/src/reporters/json.ts +10 -14
- package/src/reporters/junit.ts +4 -10
package/src/push/utils.ts
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import semver from 'semver';
|
|
27
27
|
import { progress, removeTrailingSlash } from '../helpers';
|
|
28
|
-
import { green, red, grey, yellow } from 'kleur/colors';
|
|
28
|
+
import { green, red, grey, yellow, Colorize, bold } from 'kleur/colors';
|
|
29
29
|
import { PushOptions } from '../common_types';
|
|
30
30
|
import { Monitor } from '../dsl/monitor';
|
|
31
31
|
|
|
@@ -37,19 +37,97 @@ export function logDiff<T extends Set<string>>(
|
|
|
37
37
|
) {
|
|
38
38
|
progress(
|
|
39
39
|
'Monitor Diff: ' +
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
green(`Added(${newIDs.size}) `) +
|
|
41
|
+
yellow(`Updated(${changedIDs.size}) `) +
|
|
42
|
+
red(`Removed(${removedIDs.size}) `) +
|
|
43
|
+
grey(`Unchanged(${unchangedIDs.size})`)
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export function
|
|
48
|
-
|
|
47
|
+
export function logGroups<T extends Set<string>>(
|
|
48
|
+
sizes: Map<string, number>,
|
|
49
|
+
newIDs: T,
|
|
50
|
+
changedIDs: T,
|
|
51
|
+
removedIDs: T,
|
|
52
|
+
unchangedIDs: T
|
|
53
|
+
) {
|
|
54
|
+
console.groupCollapsed();
|
|
55
|
+
logGroup(sizes, 'Added', newIDs, green);
|
|
56
|
+
logGroup(sizes, 'Updated', changedIDs, yellow);
|
|
57
|
+
logGroup(sizes, 'Removed', removedIDs, red);
|
|
58
|
+
logGroup(sizes, 'Unchanged', unchangedIDs, grey);
|
|
59
|
+
console.groupEnd();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function logGroup(
|
|
63
|
+
sizes: Map<string, number>,
|
|
64
|
+
name: string,
|
|
65
|
+
ids: Set<string>,
|
|
66
|
+
color: Colorize
|
|
67
|
+
) {
|
|
68
|
+
if (ids.size === 0) return;
|
|
69
|
+
// under collapsed group, so giving 2 space for padding
|
|
70
|
+
printLine(process.stdout.columns - 2);
|
|
71
|
+
console.groupCollapsed(color(bold(name)));
|
|
72
|
+
[...ids].forEach(id => {
|
|
73
|
+
console.log(grey(`- ${id} (${printBytes(sizes.get(id))})`));
|
|
74
|
+
});
|
|
75
|
+
console.groupEnd();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function printLine(length: number = process.stdout.columns) {
|
|
79
|
+
console.log(grey('-').repeat(length));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'];
|
|
83
|
+
export function printBytes(bytes: number) {
|
|
84
|
+
if (bytes <= 0) return '0 B';
|
|
85
|
+
const exponent = Math.min(
|
|
86
|
+
Math.floor(Math.log10(bytes) / 3),
|
|
87
|
+
BYTE_UNITS.length - 1
|
|
88
|
+
);
|
|
89
|
+
bytes /= 1000 ** exponent;
|
|
90
|
+
return `${bytes.toFixed(1)} ${BYTE_UNITS[exponent]}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getBatches(arr: string[], size: number): string[][] {
|
|
94
|
+
const batches = [];
|
|
49
95
|
for (let i = 0; i < arr.length; i += size) {
|
|
50
|
-
|
|
96
|
+
batches.push(arr.slice(i, i + size));
|
|
97
|
+
}
|
|
98
|
+
return batches;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function getSizedBatches<T extends { id?: string }>(
|
|
102
|
+
arr: Array<T>,
|
|
103
|
+
sizes: Map<string, number>,
|
|
104
|
+
maxBatchSizeKB: number,
|
|
105
|
+
maxBatchItems: number
|
|
106
|
+
): Array<T[]> {
|
|
107
|
+
const batches: Array<T[]> = [];
|
|
108
|
+
let currentBatch: T[] = [];
|
|
109
|
+
let currentSize = 0;
|
|
110
|
+
|
|
111
|
+
for (const item of arr) {
|
|
112
|
+
const sizeKB = item.id ? Math.round(sizes.get(item.id) / 1000) : 1;
|
|
113
|
+
// If adding the current item would exceed limits, create a new chunk
|
|
114
|
+
if (
|
|
115
|
+
currentBatch.length >= maxBatchItems ||
|
|
116
|
+
currentSize + sizeKB > maxBatchSizeKB
|
|
117
|
+
) {
|
|
118
|
+
batches.push(currentBatch);
|
|
119
|
+
currentBatch = [];
|
|
120
|
+
currentSize = 0;
|
|
121
|
+
}
|
|
122
|
+
currentBatch.push(item);
|
|
123
|
+
currentSize += sizeKB;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Push the last chunk if it contains any items
|
|
127
|
+
if (currentBatch.length > 0) {
|
|
128
|
+
batches.push(currentBatch);
|
|
51
129
|
}
|
|
52
|
-
return
|
|
130
|
+
return batches;
|
|
53
131
|
}
|
|
54
132
|
|
|
55
133
|
type Operation =
|
package/src/reporters/base.ts
CHANGED
|
@@ -29,7 +29,11 @@ import { renderError, serializeError } from './reporter-util';
|
|
|
29
29
|
import { symbols, indent, now } from '../helpers';
|
|
30
30
|
import { Reporter, ReporterOptions } from '.';
|
|
31
31
|
import { Journey, Step } from '../dsl';
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
JourneyEndResult,
|
|
34
|
+
JourneyStartResult,
|
|
35
|
+
StepResult,
|
|
36
|
+
} from '../common_types';
|
|
33
37
|
|
|
34
38
|
export function renderDuration(durationMs) {
|
|
35
39
|
return parseInt(durationMs);
|
|
@@ -62,11 +66,11 @@ export default class BaseReporter implements Reporter {
|
|
|
62
66
|
this.metrics.registered++;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
onJourneyStart(journey: Journey, {
|
|
69
|
+
onJourneyStart(journey: Journey, {}: JourneyStartResult) {
|
|
66
70
|
this.write(`\nJourney: ${journey.name}`);
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
onStepEnd(_: Journey, step: Step, {
|
|
73
|
+
onStepEnd(_: Journey, step: Step, {}: StepResult) {
|
|
70
74
|
const { status, error } = step;
|
|
71
75
|
const message = `${symbols[status]} Step: '${step.name}' ${status} ${gray(
|
|
72
76
|
'(' + renderDuration(step.duration * 1000) + ' ms)'
|
|
@@ -80,7 +84,7 @@ export default class BaseReporter implements Reporter {
|
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
83
|
-
onJourneyEnd(journey: Journey, {
|
|
87
|
+
onJourneyEnd(journey: Journey, {}: JourneyEndResult) {
|
|
84
88
|
const { failed, succeeded, skipped } = this.metrics;
|
|
85
89
|
const total = failed + succeeded + skipped;
|
|
86
90
|
/**
|
|
@@ -43,7 +43,7 @@ export default class BuildKiteCLIReporter extends BaseReporter {
|
|
|
43
43
|
super(options);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
override onJourneyStart(journey: Journey, {
|
|
46
|
+
override onJourneyStart(journey: Journey, {}: JourneyStartResult) {
|
|
47
47
|
this.write(`\n--- Journey: ${journey.name}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -57,7 +57,9 @@ export default class BuildKiteCLIReporter extends BaseReporter {
|
|
|
57
57
|
|
|
58
58
|
override async onJourneyEnd(journey: Journey, result: JourneyEndResult) {
|
|
59
59
|
super.onJourneyEnd(journey, result);
|
|
60
|
-
const message = `${symbols[journey.status]} Took (${renderDuration(
|
|
60
|
+
const message = `${symbols[journey.status]} Took (${renderDuration(
|
|
61
|
+
journey.duration
|
|
62
|
+
)} seconds)`;
|
|
61
63
|
this.write(message);
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -76,10 +78,9 @@ export default class BuildKiteCLIReporter extends BaseReporter {
|
|
|
76
78
|
const name = red(`Journey: ${journeyName} :slightly_frowning_face:`);
|
|
77
79
|
this.write(`\n+++ ${name}`);
|
|
78
80
|
steps.forEach(step => {
|
|
79
|
-
const message = `${symbols[step.status]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
)} ms)`;
|
|
81
|
+
const message = `${symbols[step.status]} Step: '${step.name}' ${
|
|
82
|
+
step.status
|
|
83
|
+
} (${renderDuration(step.duration * 1000)} ms)`;
|
|
83
84
|
this.write(indent(message));
|
|
84
85
|
if (step.error) {
|
|
85
86
|
this.write(renderError(serializeError(step.error)));
|
package/src/reporters/json.ts
CHANGED
|
@@ -253,14 +253,15 @@ function formatJSONError(error: Error | any) {
|
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
function journeyInfo(
|
|
257
|
-
journey: Partial<Journey>,
|
|
258
|
-
type: OutputFields['type'],
|
|
259
|
-
) {
|
|
256
|
+
function journeyInfo(journey: Partial<Journey>, type: OutputFields['type']) {
|
|
260
257
|
if (!journey) {
|
|
261
258
|
return;
|
|
262
259
|
}
|
|
263
|
-
const info: JourneyInfo = {
|
|
260
|
+
const info: JourneyInfo = {
|
|
261
|
+
name: journey.name,
|
|
262
|
+
id: journey.id,
|
|
263
|
+
tags: journey.tags,
|
|
264
|
+
};
|
|
264
265
|
const isEnd = type === 'journey/end';
|
|
265
266
|
if (isEnd) {
|
|
266
267
|
info.status = journey.status;
|
|
@@ -271,7 +272,7 @@ function journeyInfo(
|
|
|
271
272
|
|
|
272
273
|
function stepInfo(
|
|
273
274
|
step: Partial<Step>,
|
|
274
|
-
type: OutputFields['type']
|
|
275
|
+
type: OutputFields['type']
|
|
275
276
|
): Omit<Partial<Step>, 'duration'> & Duration {
|
|
276
277
|
if (!step) {
|
|
277
278
|
return;
|
|
@@ -375,8 +376,8 @@ export default class JSONReporter extends BaseReporter {
|
|
|
375
376
|
},
|
|
376
377
|
payload: event.networkConditions
|
|
377
378
|
? {
|
|
378
|
-
|
|
379
|
-
|
|
379
|
+
network_conditions: event.networkConditions,
|
|
380
|
+
}
|
|
380
381
|
: undefined,
|
|
381
382
|
});
|
|
382
383
|
}
|
|
@@ -400,12 +401,7 @@ export default class JSONReporter extends BaseReporter {
|
|
|
400
401
|
override onStepEnd(
|
|
401
402
|
journey: Journey,
|
|
402
403
|
step: Step,
|
|
403
|
-
{
|
|
404
|
-
pagemetrics,
|
|
405
|
-
traces,
|
|
406
|
-
metrics,
|
|
407
|
-
filmstrips,
|
|
408
|
-
}: StepEndResult
|
|
404
|
+
{ pagemetrics, traces, metrics, filmstrips }: StepEndResult
|
|
409
405
|
) {
|
|
410
406
|
this.writeMetrics(journey, step, 'relative_trace', traces);
|
|
411
407
|
this.writeMetrics(journey, step, 'experience', metrics);
|
package/src/reporters/junit.ts
CHANGED
|
@@ -25,10 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import { mkdir, writeFile } from 'fs/promises';
|
|
27
27
|
import { dirname } from 'path';
|
|
28
|
-
import {
|
|
29
|
-
JourneyEndResult,
|
|
30
|
-
JourneyStartResult,
|
|
31
|
-
} from '../common_types';
|
|
28
|
+
import { JourneyEndResult, JourneyStartResult } from '../common_types';
|
|
32
29
|
import { Journey, Step } from '../dsl';
|
|
33
30
|
import { indent, now } from '../helpers';
|
|
34
31
|
import BaseReporter from './base';
|
|
@@ -59,7 +56,7 @@ export default class JUnitReporter extends BaseReporter {
|
|
|
59
56
|
private totalSkipped = 0;
|
|
60
57
|
#journeyMap = new Map<string, XMLEntry>();
|
|
61
58
|
|
|
62
|
-
override onJourneyStart(journey: Journey, {
|
|
59
|
+
override onJourneyStart(journey: Journey, {}: JourneyStartResult) {
|
|
63
60
|
if (!this.#journeyMap.has(journey.name)) {
|
|
64
61
|
const entry = {
|
|
65
62
|
name: 'testsuite',
|
|
@@ -76,10 +73,7 @@ export default class JUnitReporter extends BaseReporter {
|
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
override onStepEnd(
|
|
80
|
-
journey: Journey,
|
|
81
|
-
step: Step,
|
|
82
|
-
) {
|
|
76
|
+
override onStepEnd(journey: Journey, step: Step) {
|
|
83
77
|
if (!this.#journeyMap.has(journey.name)) {
|
|
84
78
|
return;
|
|
85
79
|
}
|
|
@@ -117,7 +111,7 @@ export default class JUnitReporter extends BaseReporter {
|
|
|
117
111
|
entry.children.push(caseEntry);
|
|
118
112
|
}
|
|
119
113
|
|
|
120
|
-
override onJourneyEnd(journey: Journey, {
|
|
114
|
+
override onJourneyEnd(journey: Journey, {}: JourneyEndResult) {
|
|
121
115
|
if (!this.#journeyMap.has(journey.name)) {
|
|
122
116
|
return;
|
|
123
117
|
}
|