playwright-performance-regression 1.0.1 → 1.1.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/CHANGELOG.md +100 -0
- package/README.md +11 -4
- package/dist/chunk-JS7SBYOF.js +11226 -0
- package/dist/{chunk-ZHJQFWES.js → chunk-PTQWKPHU.js} +276 -11
- package/dist/{chunk-5Y34Q4DR.js → chunk-Q73KMM6D.js} +95 -30
- package/dist/{chunk-CTE5EY35.cjs → chunk-VBNIFMNE.cjs} +298 -32
- package/dist/{chunk-LEIBG5A4.cjs → chunk-VXGTC6DB.cjs} +25 -6
- package/dist/{chunk-W7NEFS5V.cjs → chunk-VYODYUEL.cjs} +95 -29
- package/dist/{chunk-ORWOFAZ5.js → chunk-ZEQ2IGDC.js} +108 -11
- package/dist/cli.js +380 -15
- package/dist/config.cjs +16 -16
- package/dist/config.js +3 -4
- package/dist/fixture.cjs +6 -6
- package/dist/fixture.js +3 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +1 -1
- package/dist/reporter.cjs +1831 -621
- package/dist/reporter.js +7 -8154
- package/dist/test.cjs +4 -4
- package/dist/test.js +3 -4
- package/package.json +3 -3
- package/schemas/config.schema.json +91 -0
- package/schemas/run-report.schema.json +162 -7
- package/schemas/samples.schema.json +12 -3
- package/schemas/thresholds.schema.json +29 -1
- package/dist/chunk-BA37V6SL.js +0 -1803
- package/dist/chunk-S6UH6QPK.js +0 -68
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { wrappedTests, trackedContexts, activeCollector, getRegistered, setActiveCollector, wrappedRequestContexts } from './chunk-
|
|
2
|
-
import {
|
|
3
|
-
import { perfDefaults } from './chunk-5Y34Q4DR.js';
|
|
1
|
+
import { ABORT_FAILURE_TEXTS, CONTEXT_CLOSED_FAILURE_TEXT, wrappedTests, trackedContexts, activeCollector, getRegistered, setActiveCollector, readModeState, ConfigError, wrappedRequestContexts, DEFAULT_MAX_TESTS, version, SAMPLES_ATTACHMENT_NAME, checkStateFileName } from './chunk-ZEQ2IGDC.js';
|
|
2
|
+
import { perfDefaults, matchOperationEntry } from './chunk-Q73KMM6D.js';
|
|
4
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
5
4
|
import { tmpdir } from 'os';
|
|
6
5
|
import { join } from 'path';
|
|
@@ -102,7 +101,7 @@ function wrapRequestContext(context, source, baseURL, recorder) {
|
|
|
102
101
|
depth -= 1;
|
|
103
102
|
}
|
|
104
103
|
if (described === void 0 || !isPromise(result)) return result;
|
|
105
|
-
return active.observeApiCall(described, source, result);
|
|
104
|
+
return active.observeApiCall(described, source, result, args[1]);
|
|
106
105
|
};
|
|
107
106
|
Object.defineProperty(target, name, {
|
|
108
107
|
value: wrapper,
|
|
@@ -113,6 +112,29 @@ function wrapRequestContext(context, source, baseURL, recorder) {
|
|
|
113
112
|
}
|
|
114
113
|
return true;
|
|
115
114
|
}
|
|
115
|
+
function isPlainRecord(value) {
|
|
116
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
117
|
+
}
|
|
118
|
+
function urlWithParams(url, options) {
|
|
119
|
+
const params = isPlainRecord(options) ? options.params : void 0;
|
|
120
|
+
if (params === void 0 || params === null) return url;
|
|
121
|
+
try {
|
|
122
|
+
const out = new URL(url);
|
|
123
|
+
const extra = typeof params === "string" || params instanceof URLSearchParams ? new URLSearchParams(params) : isPlainRecord(params) ? Object.entries(params).map(([name, value]) => [name, String(value)]) : [];
|
|
124
|
+
for (const [name, value] of extra) out.searchParams.set(name, value);
|
|
125
|
+
return out.toString();
|
|
126
|
+
} catch {
|
|
127
|
+
return url;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function apiOperationBody(options) {
|
|
131
|
+
if (!isPlainRecord(options)) return null;
|
|
132
|
+
const { data, multipart } = options;
|
|
133
|
+
if (typeof data === "string") return { text: data };
|
|
134
|
+
if (isPlainRecord(data) || Array.isArray(data)) return { value: data };
|
|
135
|
+
if (isPlainRecord(multipart)) return { multipartOperations: multipart.operations };
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
116
138
|
|
|
117
139
|
// src/collector/perf-api.ts
|
|
118
140
|
function createPerfApi(track, trackRequestContext2 = () => {
|
|
@@ -156,6 +178,7 @@ var KNOWN_THIRD_PARTY_HOSTS = Object.freeze([
|
|
|
156
178
|
var PENDING_RESERVE_MS = 1e3;
|
|
157
179
|
var SAMPLE_LIMIT_PER_TEST = 2e4;
|
|
158
180
|
var COLLECTOR_NAME = "playwright-js";
|
|
181
|
+
var OPERATION_BODY_LIMIT = 65536;
|
|
159
182
|
|
|
160
183
|
// src/collector/diagnostics.ts
|
|
161
184
|
function createDiagnostics() {
|
|
@@ -179,6 +202,185 @@ function errorText(error) {
|
|
|
179
202
|
if (error instanceof Error) return error.message;
|
|
180
203
|
return String(error);
|
|
181
204
|
}
|
|
205
|
+
function operationUnknown(method, pattern, reason) {
|
|
206
|
+
const entry = pattern === null ? "keys.operations" : `the keys.operations entry ${patternText(pattern)}`;
|
|
207
|
+
return {
|
|
208
|
+
code: "COLLECTOR_OPERATION_UNKNOWN",
|
|
209
|
+
message: `collector: a ${method} request matching ${entry} has no readable operation name, so it keeps the key without an operation${reason === void 0 ? "" : ` (${reason})`}`,
|
|
210
|
+
hint: "GraphQL clients send operationName or a named operation in a JSON body (read up to 64 KB) or in the query parameters; tRPC clients put procedure names in the path. If the endpoint is neither, narrow the match of the entry."
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function patternText(pattern) {
|
|
214
|
+
return typeof pattern === "string" ? JSON.stringify(pattern) : String(pattern);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/collector/operations.ts
|
|
218
|
+
var GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]{0,99}$/u;
|
|
219
|
+
var PROCEDURE_NAME = /^[A-Za-z0-9_.-]{1,100}$/u;
|
|
220
|
+
var NAMED_OPERATION = /\b(?:query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]*)/u;
|
|
221
|
+
var OPERATION_NAME_FIELD = /"operationName"\s*:\s*"([^"\\]*)"/u;
|
|
222
|
+
var ANONYMOUS_OPERATION = "anonymous";
|
|
223
|
+
var PERSISTED_OPERATION = "persisted";
|
|
224
|
+
function isRecord(value) {
|
|
225
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
226
|
+
}
|
|
227
|
+
function stripGraphqlNoise(query) {
|
|
228
|
+
let out = "";
|
|
229
|
+
let i = 0;
|
|
230
|
+
while (i < query.length) {
|
|
231
|
+
const c = query[i];
|
|
232
|
+
if (c === "#") {
|
|
233
|
+
while (i < query.length && query[i] !== "\n" && query[i] !== "\r") i++;
|
|
234
|
+
out += " ";
|
|
235
|
+
} else if (query.startsWith('"""', i)) {
|
|
236
|
+
i += 3;
|
|
237
|
+
while (i < query.length && !query.startsWith('"""', i)) {
|
|
238
|
+
i += query.startsWith('\\"""', i) ? 4 : 1;
|
|
239
|
+
}
|
|
240
|
+
i += 3;
|
|
241
|
+
out += " ";
|
|
242
|
+
} else if (c === '"') {
|
|
243
|
+
i++;
|
|
244
|
+
while (i < query.length && query[i] !== '"' && query[i] !== "\n") {
|
|
245
|
+
i += query[i] === "\\" ? 2 : 1;
|
|
246
|
+
}
|
|
247
|
+
i++;
|
|
248
|
+
out += " ";
|
|
249
|
+
} else {
|
|
250
|
+
out += c;
|
|
251
|
+
i++;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
function firstNamedOperation(query) {
|
|
257
|
+
const found = NAMED_OPERATION.exec(stripGraphqlNoise(query));
|
|
258
|
+
if (found === null) return ANONYMOUS_OPERATION;
|
|
259
|
+
const name = found[1] ?? "";
|
|
260
|
+
return GRAPHQL_NAME.test(name) ? name : null;
|
|
261
|
+
}
|
|
262
|
+
function operationName(operation) {
|
|
263
|
+
if (!isRecord(operation)) return null;
|
|
264
|
+
const given = operation.operationName;
|
|
265
|
+
if (typeof given === "string" && GRAPHQL_NAME.test(given)) return given;
|
|
266
|
+
const rejected = typeof given === "string" && given !== "";
|
|
267
|
+
if (typeof operation.query === "string") return firstNamedOperation(operation.query);
|
|
268
|
+
const extensions = operation.extensions;
|
|
269
|
+
if (isRecord(extensions) && isRecord(extensions.persistedQuery)) {
|
|
270
|
+
return rejected ? null : PERSISTED_OPERATION;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
function graphqlNamesFromValue(value) {
|
|
275
|
+
if (Array.isArray(value)) {
|
|
276
|
+
if (value.length === 0) return null;
|
|
277
|
+
const names = [];
|
|
278
|
+
for (const item of value) {
|
|
279
|
+
const name2 = operationName(item);
|
|
280
|
+
if (name2 === null) return null;
|
|
281
|
+
names.push(name2);
|
|
282
|
+
}
|
|
283
|
+
return names;
|
|
284
|
+
}
|
|
285
|
+
const name = operationName(value);
|
|
286
|
+
return name === null ? null : [name];
|
|
287
|
+
}
|
|
288
|
+
function parseJson(text) {
|
|
289
|
+
try {
|
|
290
|
+
return { ok: true, value: JSON.parse(text) };
|
|
291
|
+
} catch {
|
|
292
|
+
return { ok: false };
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function multipartOperations(text) {
|
|
296
|
+
const header = /content-disposition:[^\r\n]*\bname="operations"[^\r\n]*\r?\n/iu.exec(text);
|
|
297
|
+
if (header === null) return null;
|
|
298
|
+
let start = header.index + header[0].length;
|
|
299
|
+
const blank = /\r?\n\r?\n/u.exec(text.slice(header.index));
|
|
300
|
+
if (blank === null) return null;
|
|
301
|
+
start = Math.max(start, header.index + blank.index + blank[0].length);
|
|
302
|
+
const end = text.indexOf("\n--", start);
|
|
303
|
+
if (end < 0) return null;
|
|
304
|
+
return text.slice(start, text[end - 1] === "\r" ? end - 1 : end);
|
|
305
|
+
}
|
|
306
|
+
function graphqlNamesFromText(text) {
|
|
307
|
+
const truncated = text.length > OPERATION_BODY_LIMIT;
|
|
308
|
+
const head = truncated ? text.slice(0, OPERATION_BODY_LIMIT) : text;
|
|
309
|
+
if (!truncated) {
|
|
310
|
+
const parsed = parseJson(head);
|
|
311
|
+
if (parsed.ok) return graphqlNamesFromValue(parsed.value);
|
|
312
|
+
}
|
|
313
|
+
const part = multipartOperations(head);
|
|
314
|
+
if (part !== null) {
|
|
315
|
+
const parsed = parseJson(part);
|
|
316
|
+
return parsed.ok ? graphqlNamesFromValue(parsed.value) : null;
|
|
317
|
+
}
|
|
318
|
+
if (truncated && head.trimStart().startsWith("{")) {
|
|
319
|
+
const name = OPERATION_NAME_FIELD.exec(head)?.[1];
|
|
320
|
+
return name !== void 0 && GRAPHQL_NAME.test(name) ? [name] : null;
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
function graphqlNamesFromParams(params) {
|
|
325
|
+
const query = params.get("query");
|
|
326
|
+
const name = params.get("operationName");
|
|
327
|
+
const extensionsText = params.get("extensions");
|
|
328
|
+
if (query === null && name === null && extensionsText === null) return null;
|
|
329
|
+
let extensions;
|
|
330
|
+
if (extensionsText !== null) {
|
|
331
|
+
const parsed = parseJson(extensionsText);
|
|
332
|
+
extensions = parsed.ok ? parsed.value : void 0;
|
|
333
|
+
}
|
|
334
|
+
return graphqlNamesFromValue({
|
|
335
|
+
...query === null ? {} : { query },
|
|
336
|
+
...name === null ? {} : { operationName: name },
|
|
337
|
+
...extensions === void 0 ? {} : { extensions }
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function graphqlNamesFromBody(body) {
|
|
341
|
+
if (body === null) return null;
|
|
342
|
+
if ("text" in body) return graphqlNamesFromText(body.text);
|
|
343
|
+
if ("value" in body) {
|
|
344
|
+
return typeof body.value === "string" ? graphqlNamesFromText(body.value) : graphqlNamesFromValue(body.value);
|
|
345
|
+
}
|
|
346
|
+
const operations = body.multipartOperations;
|
|
347
|
+
if (typeof operations !== "string") return null;
|
|
348
|
+
const parsed = parseJson(operations.slice(0, OPERATION_BODY_LIMIT));
|
|
349
|
+
return parsed.ok ? graphqlNamesFromValue(parsed.value) : null;
|
|
350
|
+
}
|
|
351
|
+
function trpcNamesFromPath(path, end) {
|
|
352
|
+
let rest = path.slice(end);
|
|
353
|
+
if (rest.startsWith("/")) rest = rest.slice(1);
|
|
354
|
+
const segment = rest.split("/", 1)[0] ?? "";
|
|
355
|
+
let decoded;
|
|
356
|
+
try {
|
|
357
|
+
decoded = decodeURIComponent(segment);
|
|
358
|
+
} catch {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
const names = decoded.split(",");
|
|
362
|
+
return names.every((name) => PROCEDURE_NAME.test(name)) ? names : null;
|
|
363
|
+
}
|
|
364
|
+
function readOperation(entries, request) {
|
|
365
|
+
if (entries.length === 0) return { matched: false };
|
|
366
|
+
let url;
|
|
367
|
+
try {
|
|
368
|
+
url = new URL(request.url);
|
|
369
|
+
} catch {
|
|
370
|
+
return { matched: false };
|
|
371
|
+
}
|
|
372
|
+
const found = matchOperationEntry(entries, url.pathname);
|
|
373
|
+
if (found === null) return { matched: false };
|
|
374
|
+
const { entry } = found;
|
|
375
|
+
let names = null;
|
|
376
|
+
if (entry.type === "trpc") names = trpcNamesFromPath(url.pathname, found.end);
|
|
377
|
+
else if (request.method === "GET") names = graphqlNamesFromParams(url.searchParams);
|
|
378
|
+
else if (request.method === "POST") names = graphqlNamesFromBody(request.body());
|
|
379
|
+
return { matched: true, entry, names: isNonEmpty(names) ? names : null };
|
|
380
|
+
}
|
|
381
|
+
function isNonEmpty(names) {
|
|
382
|
+
return names !== null && names.length > 0;
|
|
383
|
+
}
|
|
182
384
|
|
|
183
385
|
// src/collector/filters.ts
|
|
184
386
|
function isKnownThirdPartyHost(host, hosts = KNOWN_THIRD_PARTY_HOSTS) {
|
|
@@ -349,9 +551,36 @@ var RequestTracker = class {
|
|
|
349
551
|
startedAtWall: this.#opts.wallNow(),
|
|
350
552
|
page: pageOf(request),
|
|
351
553
|
response: null,
|
|
352
|
-
settling: false
|
|
554
|
+
settling: false,
|
|
555
|
+
operation: this.#operationOf(request)
|
|
353
556
|
});
|
|
354
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Operation names of a request (05-REQ-40, 18-REQ-07): the body is read, synchronously, only
|
|
560
|
+
* for a POST request matching a graphql entry, and dropped right after the names are taken.
|
|
561
|
+
*/
|
|
562
|
+
#operationOf(request) {
|
|
563
|
+
const entries = this.#opts.operations ?? [];
|
|
564
|
+
if (entries.length === 0) return {};
|
|
565
|
+
const method = request.method().toUpperCase();
|
|
566
|
+
let result;
|
|
567
|
+
try {
|
|
568
|
+
result = readOperation(entries, {
|
|
569
|
+
method,
|
|
570
|
+
url: request.url(),
|
|
571
|
+
body: () => {
|
|
572
|
+
const text = request.postData();
|
|
573
|
+
return text === null ? null : { text };
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
} catch (error) {
|
|
577
|
+
this.#diag.add(operationUnknown(method, null, errorText(error)));
|
|
578
|
+
return { operation: null };
|
|
579
|
+
}
|
|
580
|
+
if (!result.matched) return { operation: null };
|
|
581
|
+
if (result.names === null) this.#diag.add(operationUnknown(method, result.entry.match));
|
|
582
|
+
return { operation: result.names };
|
|
583
|
+
}
|
|
355
584
|
#onResponse(response) {
|
|
356
585
|
const entry = this.#inflight.get(response.request());
|
|
357
586
|
if (entry !== void 0) entry.response = response;
|
|
@@ -383,6 +612,7 @@ var RequestTracker = class {
|
|
|
383
612
|
this.#settle(request);
|
|
384
613
|
this.#sink.finished({
|
|
385
614
|
...base(request),
|
|
615
|
+
...entry.operation,
|
|
386
616
|
status: response.status(),
|
|
387
617
|
...timing,
|
|
388
618
|
startTime: startTimeOf(timing.startTime, entry),
|
|
@@ -444,6 +674,7 @@ var RequestTracker = class {
|
|
|
444
674
|
if (entry.response !== null) {
|
|
445
675
|
this.#sink.finished({
|
|
446
676
|
...base(request),
|
|
677
|
+
...entry.operation,
|
|
447
678
|
status: entry.response.status(),
|
|
448
679
|
startTime,
|
|
449
680
|
duration: null,
|
|
@@ -455,6 +686,7 @@ var RequestTracker = class {
|
|
|
455
686
|
}
|
|
456
687
|
this.#sink.pending({
|
|
457
688
|
...base(request),
|
|
689
|
+
...entry.operation,
|
|
458
690
|
status: "PENDING",
|
|
459
691
|
startTime,
|
|
460
692
|
duration: null,
|
|
@@ -498,6 +730,7 @@ function base(request) {
|
|
|
498
730
|
function failed(request, entry, failureText, timing) {
|
|
499
731
|
return {
|
|
500
732
|
...base(request),
|
|
733
|
+
...entry.operation,
|
|
501
734
|
status: "FAILED",
|
|
502
735
|
failureText,
|
|
503
736
|
startTime: startTimeOf(Math.round(timing.startTime), entry),
|
|
@@ -612,7 +845,7 @@ var TestCollector = class {
|
|
|
612
845
|
* Records one APIRequestContext call (15-REQ-05): the returned promise settles like `result`
|
|
613
846
|
* (same value, same error); the sample is made when it settles or at the end-of-test wait.
|
|
614
847
|
*/
|
|
615
|
-
observeApiCall(call2, source, result) {
|
|
848
|
+
observeApiCall(call2, source, result, options) {
|
|
616
849
|
if (this.#draining !== void 0) return result;
|
|
617
850
|
const startedAt = this.#opts.now();
|
|
618
851
|
const entry = {
|
|
@@ -620,7 +853,8 @@ var TestCollector = class {
|
|
|
620
853
|
source,
|
|
621
854
|
startTime: Math.round(this.#opts.wallNow()),
|
|
622
855
|
settled: Promise.resolve(),
|
|
623
|
-
done: false
|
|
856
|
+
done: false,
|
|
857
|
+
operation: this.#apiOperation(call2, options)
|
|
624
858
|
};
|
|
625
859
|
const finish = (status, extra, responseUrl) => {
|
|
626
860
|
try {
|
|
@@ -667,6 +901,29 @@ var TestCollector = class {
|
|
|
667
901
|
this.#apiInFlight.add(entry);
|
|
668
902
|
return out;
|
|
669
903
|
}
|
|
904
|
+
/**
|
|
905
|
+
* Operation names of an API call (15-REQ-20): options.data or options.multipart for a GraphQL
|
|
906
|
+
* POST, the URL and options.params for GET, the path for tRPC. Only the names are kept.
|
|
907
|
+
*/
|
|
908
|
+
#apiOperation(call2, options) {
|
|
909
|
+
const entries = this.#opts.operations ?? [];
|
|
910
|
+
if (entries.length === 0) return {};
|
|
911
|
+
if (call2.url !== null && !shouldTrackApiCall(call2.url, this.#opts.measure)) return {};
|
|
912
|
+
try {
|
|
913
|
+
const url = call2.url ?? call2.rawUrl;
|
|
914
|
+
const result = readOperation(entries, {
|
|
915
|
+
method: call2.method,
|
|
916
|
+
url: call2.method === "GET" ? urlWithParams(url, options) : url,
|
|
917
|
+
body: () => apiOperationBody(options)
|
|
918
|
+
});
|
|
919
|
+
if (!result.matched) return { operation: null };
|
|
920
|
+
if (result.names === null) this.#diag.add(operationUnknown(call2.method, result.entry.match));
|
|
921
|
+
return { operation: result.names };
|
|
922
|
+
} catch (error) {
|
|
923
|
+
this.#diag.add(operationUnknown(call2.method, null, errorText(error)));
|
|
924
|
+
return { operation: null };
|
|
925
|
+
}
|
|
926
|
+
}
|
|
670
927
|
/** The sample of a call, or null when the filters skip its URL (15-REQ-06). */
|
|
671
928
|
#apiSample(entry, status, responseUrl, extra) {
|
|
672
929
|
const url = entry.call.url ?? responseUrl ?? entry.call.rawUrl;
|
|
@@ -678,7 +935,8 @@ var TestCollector = class {
|
|
|
678
935
|
...status === "FAILED" ? { failureText: extra.failureText ?? "unknown" } : {},
|
|
679
936
|
startTime: entry.startTime,
|
|
680
937
|
duration: extra.duration ?? null,
|
|
681
|
-
source: entry.source
|
|
938
|
+
source: entry.source,
|
|
939
|
+
...entry.operation
|
|
682
940
|
};
|
|
683
941
|
}
|
|
684
942
|
/**
|
|
@@ -702,7 +960,12 @@ var TestCollector = class {
|
|
|
702
960
|
context,
|
|
703
961
|
new RequestTracker(
|
|
704
962
|
context,
|
|
705
|
-
{
|
|
963
|
+
{
|
|
964
|
+
measure: this.#opts.measure,
|
|
965
|
+
operations: this.#opts.operations ?? [],
|
|
966
|
+
now: this.#opts.now,
|
|
967
|
+
wallNow: this.#opts.wallNow
|
|
968
|
+
},
|
|
706
969
|
this.#diag,
|
|
707
970
|
this.#sink
|
|
708
971
|
)
|
|
@@ -805,7 +1068,7 @@ var TestCollector = class {
|
|
|
805
1068
|
this.#dropped = 0;
|
|
806
1069
|
}
|
|
807
1070
|
return {
|
|
808
|
-
schemaVersion:
|
|
1071
|
+
schemaVersion: 4,
|
|
809
1072
|
collector: {
|
|
810
1073
|
name: COLLECTOR_NAME,
|
|
811
1074
|
version: this.#opts.version,
|
|
@@ -853,8 +1116,10 @@ function openBuffer(browserName, baseURL, testInfo) {
|
|
|
853
1116
|
if (state !== void 0 && (!state.config.measure.api || !state.measuredProjects.includes(testInfo.project.name))) {
|
|
854
1117
|
return { collector: null, api: PASSIVE_API };
|
|
855
1118
|
}
|
|
1119
|
+
const config = state?.config ?? perfDefaults;
|
|
856
1120
|
const collector = new TestCollector({
|
|
857
|
-
measure:
|
|
1121
|
+
measure: config.measure,
|
|
1122
|
+
operations: config.keys.operations,
|
|
858
1123
|
version,
|
|
859
1124
|
browserName,
|
|
860
1125
|
testTimeout: () => testInfo.timeout,
|
|
@@ -72,7 +72,7 @@ function str(options = {}) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
function numeric(integer, options) {
|
|
75
|
-
const { minimum, maximum } = options;
|
|
75
|
+
const { minimum, exclusiveMinimum, maximum } = options;
|
|
76
76
|
const type = integer ? "integer" : "number";
|
|
77
77
|
return {
|
|
78
78
|
expected: type,
|
|
@@ -83,6 +83,9 @@ function numeric(integer, options) {
|
|
|
83
83
|
}
|
|
84
84
|
if (integer && !Number.isInteger(value)) return sink.add(pointer, "must be integer", "type");
|
|
85
85
|
if (minimum !== void 0 && value < minimum) sink.add(pointer, `must be >= ${minimum}`);
|
|
86
|
+
if (exclusiveMinimum !== void 0 && value <= exclusiveMinimum) {
|
|
87
|
+
sink.add(pointer, `must be > ${exclusiveMinimum}`);
|
|
88
|
+
}
|
|
86
89
|
if (maximum !== void 0 && value > maximum) sink.add(pointer, `must be <= ${maximum}`);
|
|
87
90
|
}
|
|
88
91
|
};
|
|
@@ -304,6 +307,7 @@ var DEFAULT_CONFIG = {
|
|
|
304
307
|
exclude: ["/socket.io/", "/sockjs/", "/sockjs-node/", "/signalr/", "/_blazor/"],
|
|
305
308
|
excludeKnownThirdParty: true,
|
|
306
309
|
successStatuses: ["2xx", "3xx"],
|
|
310
|
+
coldSamples: 1,
|
|
307
311
|
steps: true,
|
|
308
312
|
pendingTimeoutMs: 2e3
|
|
309
313
|
},
|
|
@@ -321,7 +325,8 @@ var DEFAULT_CONFIG = {
|
|
|
321
325
|
extraIdPatterns: [],
|
|
322
326
|
query: "names",
|
|
323
327
|
keepQueryValues: [],
|
|
324
|
-
dropQueryParams: []
|
|
328
|
+
dropQueryParams: [],
|
|
329
|
+
operations: []
|
|
325
330
|
},
|
|
326
331
|
checks: {
|
|
327
332
|
time: {
|
|
@@ -369,6 +374,12 @@ var DEFAULT_CONFIG = {
|
|
|
369
374
|
statuses: ["5xx", "FAILED", "PENDING"],
|
|
370
375
|
limit: { api: 0.05, step: 0.05 },
|
|
371
376
|
margin: { factor: 1.5, add: 0.02, min: 0.05 }
|
|
377
|
+
},
|
|
378
|
+
nonSuccess: {
|
|
379
|
+
enabled: true,
|
|
380
|
+
minSamples: 5,
|
|
381
|
+
limit: { api: null },
|
|
382
|
+
margin: { factor: 1.5, add: 0.02, min: 0.05 }
|
|
372
383
|
}
|
|
373
384
|
},
|
|
374
385
|
gate: { tolerance: 0, hardLimitFactor: 2, defaultThresholds: "block", maxFailedTestShare: 0.1 },
|
|
@@ -379,7 +390,8 @@ var DEFAULT_CONFIG = {
|
|
|
379
390
|
update: "all",
|
|
380
391
|
smallSampleN: 20,
|
|
381
392
|
hysteresis: { relative: 0.1, ratio: 0.01 },
|
|
382
|
-
loosenWarnRelative: 0.5
|
|
393
|
+
loosenWarnRelative: 0.5,
|
|
394
|
+
workloadShift: { factor: 2 }
|
|
383
395
|
},
|
|
384
396
|
report: { dir: "reports/pw-perf", html: true, junit: true, rawUrls: false },
|
|
385
397
|
advanced: { maxSamplesPerKey: 5e3, seed: 1 }
|
|
@@ -550,7 +562,9 @@ function presetLayer(preset) {
|
|
|
550
562
|
},
|
|
551
563
|
wilson: { margin: { factor: v.factor } }
|
|
552
564
|
},
|
|
553
|
-
errors: { margin: { factor: v.factor } }
|
|
565
|
+
errors: { margin: { factor: v.factor } },
|
|
566
|
+
// The nonSuccess margin follows the errors margin (03-REQ-30).
|
|
567
|
+
nonSuccess: { margin: { factor: v.factor } }
|
|
554
568
|
}
|
|
555
569
|
};
|
|
556
570
|
}
|
|
@@ -626,6 +640,12 @@ var checks = obj({
|
|
|
626
640
|
),
|
|
627
641
|
limit: limitByKind(ratio),
|
|
628
642
|
margin: errorsMargin
|
|
643
|
+
}),
|
|
644
|
+
nonSuccess: obj({
|
|
645
|
+
enabled,
|
|
646
|
+
minSamples,
|
|
647
|
+
limit: obj({ api: nullable(ratio) }),
|
|
648
|
+
margin: errorsMargin
|
|
629
649
|
})
|
|
630
650
|
});
|
|
631
651
|
var uniqueStrings = (minLength) => arr(str({ minLength }), { uniqueItems: true });
|
|
@@ -677,6 +697,7 @@ var packageConfig = obj({
|
|
|
677
697
|
minItems: 1
|
|
678
698
|
}
|
|
679
699
|
),
|
|
700
|
+
coldSamples: int({ minimum: 0, maximum: 5 }),
|
|
680
701
|
steps: oneOf(
|
|
681
702
|
bool,
|
|
682
703
|
obj({
|
|
@@ -721,7 +742,13 @@ var packageConfig = obj({
|
|
|
721
742
|
query: enumOf(["names", "ignore"]),
|
|
722
743
|
keepQueryValues: uniqueStrings(1),
|
|
723
744
|
dropQueryParams: uniqueStrings(1),
|
|
724
|
-
keyBuilder: constant("[function]")
|
|
745
|
+
keyBuilder: constant("[function]"),
|
|
746
|
+
operations: arr(
|
|
747
|
+
obj(
|
|
748
|
+
{ type: enumOf(["graphql", "trpc"]), match: urlPattern },
|
|
749
|
+
{ required: ["type", "match"] }
|
|
750
|
+
)
|
|
751
|
+
)
|
|
725
752
|
}),
|
|
726
753
|
checks,
|
|
727
754
|
gate: obj({
|
|
@@ -746,7 +773,8 @@ var packageConfig = obj({
|
|
|
746
773
|
update: enumOf(["all", "new-only"]),
|
|
747
774
|
smallSampleN: int({ minimum: 1 }),
|
|
748
775
|
hysteresis: obj({ relative: unit, ratio: num({ minimum: 0, maximum: 0.01 }) }),
|
|
749
|
-
loosenWarnRelative: num({ minimum: 0, maximum: 100 })
|
|
776
|
+
loosenWarnRelative: num({ minimum: 0, maximum: 100 }),
|
|
777
|
+
workloadShift: obj({ factor: nullable(num({ exclusiveMinimum: 1, maximum: 100 })) })
|
|
750
778
|
}),
|
|
751
779
|
report: obj({ dir: str({ minLength: 1 }), html: bool, junit: bool, rawUrls: bool }),
|
|
752
780
|
advanced: obj({
|
|
@@ -768,7 +796,8 @@ var derivationSettings = obj(
|
|
|
768
796
|
p99: p99Margin,
|
|
769
797
|
apdex: apdexMargin,
|
|
770
798
|
wilson: wilsonMargin,
|
|
771
|
-
errors: errorsMargin
|
|
799
|
+
errors: errorsMargin,
|
|
800
|
+
nonSuccess: errorsMargin
|
|
772
801
|
},
|
|
773
802
|
{ required: ["median", "percentile", "p99", "apdex", "wilson", "errors"] }
|
|
774
803
|
)
|
|
@@ -886,7 +915,11 @@ function issue2(code, segments, message, hint) {
|
|
|
886
915
|
const path = formatPath(segments);
|
|
887
916
|
return { code, path, message: `${path === "" ? "config" : path}: ${message}`, hint };
|
|
888
917
|
}
|
|
918
|
+
function isOperationMatch(segments) {
|
|
919
|
+
return segments.length === 4 && segments[0] === "keys" && segments[1] === "operations" && typeof segments[2] === "number" && segments[3] === "match";
|
|
920
|
+
}
|
|
889
921
|
function isPatternItem(segments) {
|
|
922
|
+
if (isOperationMatch(segments)) return true;
|
|
890
923
|
return typeof segments.at(-1) === "number" && PATTERN_LISTS.some(
|
|
891
924
|
(list) => segments.length === list.length + 1 && list.every((name, i) => segments[i] === name)
|
|
892
925
|
);
|
|
@@ -894,6 +927,9 @@ function isPatternItem(segments) {
|
|
|
894
927
|
function knownOptions(parent) {
|
|
895
928
|
if (isPatternItem(parent)) return ["regex", "flags"];
|
|
896
929
|
if (parent[0] === "keys" && parent[1] === "origins") return [];
|
|
930
|
+
if (parent.length === 3 && parent[0] === "keys" && parent[1] === "operations") {
|
|
931
|
+
return ["type", "match"];
|
|
932
|
+
}
|
|
897
933
|
if (parent.length === 2 && parent[0] === "measure" && parent[1] === "steps") {
|
|
898
934
|
return [...STEP_OPTION_NAMES];
|
|
899
935
|
}
|
|
@@ -986,26 +1022,33 @@ function schemaIssues(document) {
|
|
|
986
1022
|
}
|
|
987
1023
|
function regexIssues(document) {
|
|
988
1024
|
const issues = [];
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1025
|
+
const operations = valueAt(document, ["keys", "operations"]);
|
|
1026
|
+
const patterns = [
|
|
1027
|
+
...PATTERN_LISTS.flatMap((path) => {
|
|
1028
|
+
const list = valueAt(document, path);
|
|
1029
|
+
return Array.isArray(list) ? list.map((item, index) => [[...path, index], item]) : [];
|
|
1030
|
+
}),
|
|
1031
|
+
...Array.isArray(operations) ? operations.map((entry, index) => [
|
|
1032
|
+
["keys", "operations", index, "match"],
|
|
1033
|
+
isRecord(entry) ? entry.match : void 0
|
|
1034
|
+
]) : []
|
|
1035
|
+
];
|
|
1036
|
+
for (const [segments, item] of patterns) {
|
|
1037
|
+
if (!isRecord(item) || typeof item.regex !== "string") continue;
|
|
1038
|
+
const flags = typeof item.flags === "string" ? item.flags : "";
|
|
1039
|
+
try {
|
|
1040
|
+
new RegExp(item.regex, flags);
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1043
|
+
issues.push(
|
|
1044
|
+
issue2(
|
|
1045
|
+
"CONFIG_INVALID_REGEX",
|
|
1046
|
+
segments,
|
|
1047
|
+
`regular expression does not compile (${reason})`,
|
|
1048
|
+
'Fix the expression; it uses JavaScript RegExp syntax, e.g. { "regex": "^/api/v[0-9]+/", "flags": "i" }.'
|
|
1049
|
+
)
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1009
1052
|
}
|
|
1010
1053
|
const grep = valueAt(document, ["run", "grep"]);
|
|
1011
1054
|
if (typeof grep === "string" && grep !== "") {
|
|
@@ -1099,7 +1142,7 @@ function relationalIssues(config, isSet) {
|
|
|
1099
1142
|
)
|
|
1100
1143
|
);
|
|
1101
1144
|
}
|
|
1102
|
-
for (const rule of RULES.slice(1)) {
|
|
1145
|
+
for (const rule of [...RULES.slice(1), ["checks", "nonSuccess"]]) {
|
|
1103
1146
|
ordered(
|
|
1104
1147
|
["checks", "time", "median", "minSamples"],
|
|
1105
1148
|
[...rule, "minSamples"],
|
|
@@ -1374,6 +1417,7 @@ function resolveConfig(input, overrides) {
|
|
|
1374
1417
|
const list = valueAt(merged, path);
|
|
1375
1418
|
list.splice(0, list.length, ...list.map(snapshotPattern));
|
|
1376
1419
|
}
|
|
1420
|
+
for (const entry of merged.keys.operations) entry.match = snapshotPattern(entry.match);
|
|
1377
1421
|
if (keyBuilder.inSnapshot) merged.keys.keyBuilder = KEY_BUILDER_SNAPSHOT;
|
|
1378
1422
|
const snapshot = merged;
|
|
1379
1423
|
const { keyBuilder: _keyBuilder, ...keys } = snapshot.keys;
|
|
@@ -1393,7 +1437,11 @@ function resolveConfig(input, overrides) {
|
|
|
1393
1437
|
keys: {
|
|
1394
1438
|
...clone(keys),
|
|
1395
1439
|
extraIdPatterns: snapshot.keys.extraIdPatterns.map(compilePattern),
|
|
1396
|
-
keyBuilder: keyBuilder.keyBuilder
|
|
1440
|
+
keyBuilder: keyBuilder.keyBuilder,
|
|
1441
|
+
operations: snapshot.keys.operations.map((entry) => ({
|
|
1442
|
+
type: entry.type,
|
|
1443
|
+
match: compilePattern(entry.match)
|
|
1444
|
+
}))
|
|
1397
1445
|
}
|
|
1398
1446
|
};
|
|
1399
1447
|
return {
|
|
@@ -1424,4 +1472,21 @@ function resolveDefaults() {
|
|
|
1424
1472
|
}
|
|
1425
1473
|
var perfDefaults = deepFreeze(resolveDefaults());
|
|
1426
1474
|
|
|
1427
|
-
|
|
1475
|
+
// src/core/config/operations.ts
|
|
1476
|
+
function matchEnd(path, pattern) {
|
|
1477
|
+
if (typeof pattern === "string") {
|
|
1478
|
+
const index = path.indexOf(pattern);
|
|
1479
|
+
return index < 0 ? -1 : index + pattern.length;
|
|
1480
|
+
}
|
|
1481
|
+
const found = pattern.exec(path);
|
|
1482
|
+
return found === null ? -1 : found.index + found[0].length;
|
|
1483
|
+
}
|
|
1484
|
+
function matchOperationEntry(entries, path) {
|
|
1485
|
+
for (const entry of entries) {
|
|
1486
|
+
const end = matchEnd(path, entry.match);
|
|
1487
|
+
if (end >= 0) return { entry, end };
|
|
1488
|
+
}
|
|
1489
|
+
return null;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
export { DEFAULT_CONFIG, MARGIN_PRESETS, Sink, anyObject, arr, bool, child, compileHostPatterns, constant, count, definePerfConfig, derivationSettings, enumOf, envLabelOrNull, epochMs, evaluationStatus, expandSteps, fingerprint, hostFingerprint, int, isHostPattern, isRecord, isoDate, issue, key, kind, matchOperationEntry, matchingPattern, mode, ms, msLimit, msOrNull, nul, nullable, num, obj, oneOf, packageConfig, percentileName, perfDefaults, ratio, record, resolveConfig, runId, str, testsStatus, timestamp, tool };
|