@testsprite/testsprite-cli 0.12.0 → 0.14.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 +59 -49
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +436 -5
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +34 -20
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +408 -70
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +14 -5
- package/dist/commands/project.js +110 -70
- package/dist/commands/schedule.d.ts +14 -0
- package/dist/commands/schedule.js +193 -15
- package/dist/commands/test.d.ts +123 -44
- package/dist/commands/test.js +2993 -636
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +217 -47
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +221 -18
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +39 -50
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +16 -2
- package/dist/lib/client-factory.js +37 -6
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +27 -3
- package/dist/lib/conflict-reason.js +53 -4
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +104 -7
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.d.ts +18 -11
- package/dist/lib/errors.js +123 -14
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +1 -0
- package/dist/lib/gh-output.js +16 -4
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +39 -19
- package/dist/lib/http.js +46 -24
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +18 -4
- package/dist/lib/junit-report.js +23 -5
- package/dist/lib/local-target.d.ts +14 -4
- package/dist/lib/local-target.js +48 -13
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +15 -16
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +21 -5
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +88 -7
- package/dist/lib/runs.types.d.ts +68 -11
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +11 -11
- package/dist/lib/telemetry.d.ts +10 -8
- package/dist/lib/telemetry.js +24 -17
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +111 -4
- package/dist/lib/tunnel-session.d.ts +16 -4
- package/dist/lib/tunnel-session.js +7 -5
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +8 -8
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -38
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { type EnvironmentTunnelContext } from '../lib/environment-tunnel.js';
|
|
2
|
+
import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
3
|
+
import type { TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
4
|
+
import type { TunnelClientHandle } from '../lib/tunnel-session.js';
|
|
1
5
|
import { Command } from 'commander';
|
|
2
6
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
7
|
import { type FetchImpl } from '../lib/http.js';
|
|
4
8
|
import { type JUnitReportFormat } from '../lib/junit-report.js';
|
|
5
9
|
import type { CliDeleteTestListResponse, CliTestList, CliTestListDetail, CliTestListRunResponse } from '../lib/testlist.types.js';
|
|
6
10
|
export interface TestListDeps {
|
|
11
|
+
shutdown?: ShutdownHandle;
|
|
12
|
+
createTunnelClient?: (options: TunnelClientOptions) => TunnelClientHandle;
|
|
13
|
+
environmentTunnel?: EnvironmentTunnelContext;
|
|
7
14
|
env?: NodeJS.ProcessEnv;
|
|
8
15
|
credentialsPath?: string;
|
|
9
16
|
fetchImpl?: FetchImpl;
|
|
@@ -60,6 +67,9 @@ export declare function waitRequestTimeoutMs(opts: {
|
|
|
60
67
|
requestTimeoutMs?: number;
|
|
61
68
|
}): number | undefined;
|
|
62
69
|
export interface RunTestlistRunOptions extends CommonOptions {
|
|
70
|
+
noWait?: boolean;
|
|
71
|
+
skipPreflight?: boolean;
|
|
72
|
+
concurrencyIsDefault?: boolean;
|
|
63
73
|
listId: string;
|
|
64
74
|
/** --case (repeatable): run only this subset of the list's cases (== test ids). */
|
|
65
75
|
cases?: string[];
|
|
@@ -78,11 +88,6 @@ export interface RunTestlistRunOptions extends CommonOptions {
|
|
|
78
88
|
/** --summary-file: also write the reduced machine summary JSON to this path. */
|
|
79
89
|
summaryFile?: string;
|
|
80
90
|
}
|
|
81
|
-
/**
|
|
82
|
-
* `testlist run` — dispatch the list's cases (optionally a `--case` subset) and,
|
|
83
|
-
* with `--wait`, poll every returned runId to a verdict, optionally writing a
|
|
84
|
-
* JUnit XML report (`--report junit`). testlist run is V3-only.
|
|
85
|
-
*/
|
|
86
91
|
export declare function runTestlistRun(opts: RunTestlistRunOptions, deps?: TestListDeps): Promise<CliTestListRunResponse>;
|
|
87
92
|
export declare function createTestListCommand(deps?: TestListDeps): Command;
|
|
88
93
|
export {};
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
import { TunnelLostError } from '../lib/tunnel-session.js';
|
|
2
|
+
import { resolveEnvironmentRunTarget, readEnvironmentPreflight, groupEnvironmentTargets, emitEnvironmentDispatchPartial, withEnvironmentTunnel, } from '../lib/environment-tunnel.js';
|
|
3
|
+
import { globalShutdown } from '../lib/interrupt.js';
|
|
1
4
|
import { randomUUID } from 'node:crypto';
|
|
2
5
|
import { Command } from 'commander';
|
|
3
6
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
7
|
import { ApiError, CLIError, InterruptError, RequestTimeoutError, localValidationError, } from '../lib/errors.js';
|
|
5
8
|
import { REQUEST_TIMEOUT_DEFAULT_MS, REQUEST_TIMEOUT_MAX_MS, } from '../lib/http.js';
|
|
9
|
+
import { resolveProfileName } from '../lib/config.js';
|
|
6
10
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
7
11
|
import { pollRunUntilTerminal, TimeoutError } from '../lib/poll.js';
|
|
8
12
|
import { emitCiArtifacts, summarizeAcceptedPayload } from '../lib/gh-output.js';
|
|
9
|
-
import { describeConflict, insufficientCreditsConflictError, isAllCreditsRefusal, summarizeConflicts, } from '../lib/conflict-reason.js';
|
|
13
|
+
import { billingConflictLink, describeConflict, insufficientCreditsConflictError, isAllCreditsRefusal, isPausedRefusal, pausedConflictError, summarizeConflicts, } from '../lib/conflict-reason.js';
|
|
10
14
|
import { recordBatchOutcome } from '../lib/telemetry.js';
|
|
11
15
|
import { formatRunProgressLine } from '../lib/run-progress.js';
|
|
12
16
|
import { createTicker } from '../lib/ticker.js';
|
|
13
|
-
import { buildJUnitReport, parseJUnitReportFormat, writeJUnitReportFile, } from '../lib/junit-report.js';
|
|
17
|
+
import { buildJUnitReport, durationSecondsBetween, parseJUnitReportFormat, skippedJUnitResultsFromSummary, writeJUnitReportFile, } from '../lib/junit-report.js';
|
|
14
18
|
import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
|
|
15
19
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
16
|
-
import { resolveWaitFailure } from '../lib/wait-exit.js';
|
|
20
|
+
import { resolveWaitFailure, waitMemberError } from '../lib/wait-exit.js';
|
|
17
21
|
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
18
|
-
function resolveCommonOptions(command) {
|
|
22
|
+
function resolveCommonOptions(command, env) {
|
|
19
23
|
const g = command.optsWithGlobals();
|
|
20
24
|
return {
|
|
21
|
-
profile: g.profile
|
|
25
|
+
profile: resolveProfileName(g.profile, env),
|
|
22
26
|
output: resolveOutputMode(g.output),
|
|
23
27
|
endpointUrl: g.endpointUrl,
|
|
24
28
|
debug: g.debug ?? false,
|
|
@@ -288,9 +292,7 @@ function assertNoNotFound(resp) {
|
|
|
288
292
|
* with `--wait`, poll every returned runId to a verdict, optionally writing a
|
|
289
293
|
* JUnit XML report (`--report junit`). testlist run is V3-only.
|
|
290
294
|
*/
|
|
291
|
-
|
|
292
|
-
const out = makeOutput(opts.output, deps);
|
|
293
|
-
const stderrFn = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
295
|
+
function validateTestlistRunOptions(opts) {
|
|
294
296
|
if (opts.idempotencyKey !== undefined)
|
|
295
297
|
assertIdempotencyKey(opts.idempotencyKey);
|
|
296
298
|
if (!Number.isInteger(opts.maxConcurrency) ||
|
|
@@ -315,6 +317,74 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
315
317
|
if (opts.summaryFile !== undefined && !opts.wait) {
|
|
316
318
|
throw localValidationError('summary-file', '--summary-file requires --wait (it reduces the terminal run result). Add --wait.');
|
|
317
319
|
}
|
|
320
|
+
}
|
|
321
|
+
export async function runTestlistRun(opts, deps = {}) {
|
|
322
|
+
validateTestlistRunOptions({ ...opts, wait: opts.wait || (!opts.dryRun && !opts.noWait) });
|
|
323
|
+
if (opts.dryRun || deps.environmentTunnel)
|
|
324
|
+
return runTestlistRunCore(opts, deps);
|
|
325
|
+
let client;
|
|
326
|
+
try {
|
|
327
|
+
client = makeClient(opts, deps);
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
validateTestlistRunOptions(opts);
|
|
331
|
+
throw err;
|
|
332
|
+
}
|
|
333
|
+
const stderr = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
334
|
+
let list;
|
|
335
|
+
try {
|
|
336
|
+
list = await readEnvironmentPreflight(client, `/testlist/${encodeURIComponent(opts.listId)}`);
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
if (err instanceof InterruptError)
|
|
340
|
+
throw err;
|
|
341
|
+
return runTestlistRunCore(opts, deps);
|
|
342
|
+
}
|
|
343
|
+
const targets = new Map();
|
|
344
|
+
const backend = [];
|
|
345
|
+
const cache = new Map();
|
|
346
|
+
for (const test of list.cases ?? []) {
|
|
347
|
+
if (opts.cases?.length && !opts.cases.includes(test.testId))
|
|
348
|
+
continue;
|
|
349
|
+
const environment = list.projectEnvironments?.find(row => row.projectId === test.projectId)?.environmentName;
|
|
350
|
+
const target = await resolveEnvironmentRunTarget({
|
|
351
|
+
client,
|
|
352
|
+
testId: test.testId,
|
|
353
|
+
knownTest: test,
|
|
354
|
+
includeBackend: true,
|
|
355
|
+
environment,
|
|
356
|
+
noWait: opts.noWait,
|
|
357
|
+
verbose: opts.verbose || opts.debug,
|
|
358
|
+
stderr,
|
|
359
|
+
cache,
|
|
360
|
+
});
|
|
361
|
+
if (target && test.type === 'backend')
|
|
362
|
+
backend.push({ testId: test.testId, reason: 'backend-test' });
|
|
363
|
+
else if (target)
|
|
364
|
+
targets.set(test.testId, target);
|
|
365
|
+
}
|
|
366
|
+
if (!targets.size)
|
|
367
|
+
return runTestlistRunCore(opts, deps);
|
|
368
|
+
const maxConcurrency = opts.concurrencyIsDefault ? 5 : opts.maxConcurrency;
|
|
369
|
+
if (maxConcurrency > 10)
|
|
370
|
+
throw localValidationError('max-concurrency', 'tunnel runs support at most 10 concurrent runs (default 5)');
|
|
371
|
+
if (backend.length)
|
|
372
|
+
stderr(`[advisory] ${backend.length} backend test(s) skipped — tunnel runs frontend tests only.`);
|
|
373
|
+
const cases = (list.cases ?? [])
|
|
374
|
+
.filter(test => !backend.some(row => row.testId === test.testId) &&
|
|
375
|
+
(!opts.cases?.length || opts.cases.includes(test.testId)))
|
|
376
|
+
.map(test => test.testId);
|
|
377
|
+
cases.push(...(opts.cases ?? []).filter(id => !list.cases?.some(test => test.testId === id)));
|
|
378
|
+
return withEnvironmentTunnel({ ...opts, maxConcurrency, requestTimeoutMs: waitRequestTimeoutMs({ ...opts, wait: true }) }, deps, [...targets.values()], 'testlist run', context => {
|
|
379
|
+
context.targets = targets;
|
|
380
|
+
context.skipped = backend;
|
|
381
|
+
return runTestlistRunCore({ ...opts, cases, wait: true, maxConcurrency }, { ...deps, environmentTunnel: context });
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
async function runTestlistRunCore(opts, deps = {}) {
|
|
385
|
+
validateTestlistRunOptions(opts);
|
|
386
|
+
const out = makeOutput(opts.output, deps);
|
|
387
|
+
const stderrFn = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
318
388
|
const idempotencyKey = opts.idempotencyKey ?? `cli-testlist-run-${randomUUID()}`;
|
|
319
389
|
emitIdempotencyKey(opts, deps, idempotencyKey, opts.idempotencyKey);
|
|
320
390
|
if (opts.dryRun) {
|
|
@@ -324,8 +394,51 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
324
394
|
return sample;
|
|
325
395
|
}
|
|
326
396
|
// Under --wait, raise the per-request timeout to cover --timeout (see helper).
|
|
327
|
-
const client =
|
|
328
|
-
|
|
397
|
+
const client = deps.environmentTunnel?.client ??
|
|
398
|
+
makeClient({ ...opts, requestTimeoutMs: waitRequestTimeoutMs(opts) }, deps);
|
|
399
|
+
let resp;
|
|
400
|
+
if (deps.environmentTunnel) {
|
|
401
|
+
const targets = deps.environmentTunnel.targets;
|
|
402
|
+
const groups = groupEnvironmentTargets(opts.cases ?? [...targets.keys()], targets, deps.environmentTunnel.maxConcurrency);
|
|
403
|
+
const responses = [];
|
|
404
|
+
try {
|
|
405
|
+
for (const [index, testIds] of groups.entries()) {
|
|
406
|
+
const target = targets.get(testIds[0]);
|
|
407
|
+
const suffix = groups.length > 1 ? `:group${index}` : '';
|
|
408
|
+
if (target)
|
|
409
|
+
await deps.environmentTunnel.waitForCapacity(testIds.length);
|
|
410
|
+
const response = await client.triggerTestListRun(opts.listId, {
|
|
411
|
+
testIds,
|
|
412
|
+
...(target
|
|
413
|
+
? { targetUrl: target.targetUrl, tunnelClientId: deps.environmentTunnel.clientId }
|
|
414
|
+
: {}),
|
|
415
|
+
}, { idempotencyKey: `${idempotencyKey.slice(0, 256 - suffix.length)}${suffix}` });
|
|
416
|
+
responses.push(response);
|
|
417
|
+
if (target)
|
|
418
|
+
await deps.environmentTunnel.confirm(response, response.accepted.map(row => row.runId));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch (err) {
|
|
422
|
+
if (responses.length)
|
|
423
|
+
await emitEnvironmentDispatchPartial(responses, groups.flat(), opts, deps, 'testlist', err, deps.environmentTunnel);
|
|
424
|
+
throw err;
|
|
425
|
+
}
|
|
426
|
+
resp = {
|
|
427
|
+
...responses[0],
|
|
428
|
+
...(deps.environmentTunnel.skipped?.length
|
|
429
|
+
? { skipped: deps.environmentTunnel.skipped }
|
|
430
|
+
: {}),
|
|
431
|
+
accepted: responses.flatMap(row => row.accepted),
|
|
432
|
+
conflicts: responses.flatMap(row => row.conflicts),
|
|
433
|
+
deferred: responses.flatMap(row => row.deferred),
|
|
434
|
+
...(responses.some(row => row.notFound)
|
|
435
|
+
? { notFound: responses.flatMap(row => row.notFound ?? []) }
|
|
436
|
+
: {}),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
resp = await client.triggerTestListRun(opts.listId, opts.cases && opts.cases.length > 0 ? { testIds: opts.cases } : {}, { idempotencyKey });
|
|
441
|
+
}
|
|
329
442
|
// Partial `--case` miss: some ids were not members of this list. The matched
|
|
330
443
|
// subset still dispatched; a FULL miss is a 404 upstream and never reaches
|
|
331
444
|
// here. Warn on stderr so JSON stdout stays the machine payload (the ids are
|
|
@@ -333,6 +446,11 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
333
446
|
if (resp.notFound && resp.notFound.length > 0) {
|
|
334
447
|
stderrFn(`warning: ${resp.notFound.length} --case id(s) not in this list, skipped: ${resp.notFound.join(' ')}`);
|
|
335
448
|
}
|
|
449
|
+
if (resp.accepted.length > 0) {
|
|
450
|
+
const link = billingConflictLink(resp.conflicts, client.resolvedBaseUrl);
|
|
451
|
+
if (link)
|
|
452
|
+
stderrFn(`[advisory] Billing refusal for some tests.${link}`);
|
|
453
|
+
}
|
|
336
454
|
// All-conflict: nothing new dispatched because every targeted case is already
|
|
337
455
|
// in flight → exit 6, for BOTH --wait and non-wait (a --wait over zero accepted
|
|
338
456
|
// would otherwise no-op straight to exit 0). Distinct from the empty/no-match
|
|
@@ -352,7 +470,7 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
352
470
|
// into the summary as non-passed rows. The non-wait path never emits CI
|
|
353
471
|
// artifacts, matching the main tail below.
|
|
354
472
|
if (opts.wait) {
|
|
355
|
-
|
|
473
|
+
const summary = summarizeAcceptedPayload(JSON.stringify({
|
|
356
474
|
accepted: [],
|
|
357
475
|
conflicts: resp.conflicts,
|
|
358
476
|
deferred: resp.deferred,
|
|
@@ -361,7 +479,16 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
361
479
|
// CI summary must report the whole requested set (same reason the
|
|
362
480
|
// main --wait envelope threads it). Undefined ⇒ JSON.stringify drops it.
|
|
363
481
|
notFound: resp.notFound,
|
|
364
|
-
}), { notFoundNote: 'not a member of this list (not dispatched)' })
|
|
482
|
+
}), { notFoundNote: 'not a member of this list (not dispatched)' });
|
|
483
|
+
if (opts.report === 'junit' && opts.reportFile !== undefined) {
|
|
484
|
+
const suiteName = opts.reportSuiteName ?? `testsprite:testlist:${opts.listId}`;
|
|
485
|
+
await writeJUnitReportFile(opts.reportFile, buildJUnitReport({
|
|
486
|
+
suiteName,
|
|
487
|
+
classname: `testlist:${opts.listId}`,
|
|
488
|
+
results: skippedJUnitResultsFromSummary(summary),
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
emitCiArtifacts(summary, opts, {
|
|
365
492
|
env: deps.env ?? process.env,
|
|
366
493
|
stdout: deps.stdout ?? ((line) => process.stdout.write(`${line}\n`)),
|
|
367
494
|
stderr: stderrFn,
|
|
@@ -373,16 +500,24 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
373
500
|
if (isAllCreditsRefusal(resp)) {
|
|
374
501
|
throw insufficientCreditsConflictError(resp.conflicts, client.resolvedBaseUrl);
|
|
375
502
|
}
|
|
503
|
+
if (isPausedRefusal(resp)) {
|
|
504
|
+
throw pausedConflictError(resp.conflicts, client.resolvedBaseUrl);
|
|
505
|
+
}
|
|
376
506
|
const pollIds = resp.conflicts
|
|
377
507
|
.map(c => c.currentRunId)
|
|
378
508
|
.filter((id) => Boolean(id));
|
|
379
509
|
// Name the causes instead of blanket "already in flight" — a list pinned to
|
|
380
510
|
// a local env or a view-only project is not something to poll. The poll hint
|
|
381
|
-
// is emitted only for the cases that actually have an in-flight run.
|
|
511
|
+
// is emitted only for the cases that actually have an in-flight run. A
|
|
512
|
+
// paused (`billing_hold`) / insufficient_credits conflict riding along a NON-uniform
|
|
513
|
+
// mix (the uniform cases already threw above) still needs its upgrade
|
|
514
|
+
// link — `accepted.length` is 0 in this whole branch, so the advisory
|
|
515
|
+
// printed earlier (guarded on `accepted.length > 0`) never showed it.
|
|
382
516
|
throw new CLIError(`Nothing dispatched — ${resp.conflicts.length} conflict(s): ${summarizeConflicts(resp.conflicts)}` +
|
|
383
517
|
(pollIds.length > 0
|
|
384
518
|
? `. Poll in-flight runs: testsprite test wait ${pollIds.join(' ')}`
|
|
385
|
-
: '')
|
|
519
|
+
: '') +
|
|
520
|
+
billingConflictLink(resp.conflicts, client.resolvedBaseUrl), 6);
|
|
386
521
|
}
|
|
387
522
|
if (!opts.wait) {
|
|
388
523
|
// Print what dispatched, or the empty/no-match reason. Exit 0.
|
|
@@ -405,8 +540,9 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
405
540
|
// empty-suite report rather than nothing.
|
|
406
541
|
// --- --wait fan-out ---
|
|
407
542
|
const ticker = createTicker(stderrFn, opts.output === 'json' ? false : undefined);
|
|
408
|
-
const batchDeadlineMs = Date.now() + opts.timeoutSeconds * 1000;
|
|
543
|
+
const batchDeadlineMs = deps.environmentTunnel?.deadlineMs ?? Date.now() + opts.timeoutSeconds * 1000;
|
|
409
544
|
const results = [];
|
|
545
|
+
const reportDurations = new Map();
|
|
410
546
|
async function pollOne(entry) {
|
|
411
547
|
const remainingMs = batchDeadlineMs - Date.now();
|
|
412
548
|
if (remainingMs <= 0) {
|
|
@@ -429,8 +565,13 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
429
565
|
timeoutSeconds: Math.ceil(remainingMs / 1000),
|
|
430
566
|
sleep: deps.sleep,
|
|
431
567
|
onTransition: opts.verbose ? (msg) => stderrFn(`[verbose] ${msg}`) : undefined,
|
|
432
|
-
|
|
568
|
+
shutdown: deps.shutdown ?? globalShutdown,
|
|
569
|
+
onTick: (run, elapsedMs) => {
|
|
570
|
+
deps.environmentTunnel?.onPoll(run);
|
|
571
|
+
ticker.update(formatRunProgressLine(run, elapsedMs, `(${entry.testId})`));
|
|
572
|
+
},
|
|
433
573
|
});
|
|
574
|
+
reportDurations.set(entry.runId, durationSecondsBetween(finalRun.startedAt, finalRun.finishedAt, finalRun.createdAt));
|
|
434
575
|
return {
|
|
435
576
|
testId: entry.testId,
|
|
436
577
|
testTitle: finalRun.testTitle ?? null,
|
|
@@ -455,6 +596,8 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
455
596
|
};
|
|
456
597
|
}
|
|
457
598
|
catch (err) {
|
|
599
|
+
if (deps.environmentTunnel && err instanceof TunnelLostError)
|
|
600
|
+
throw err;
|
|
458
601
|
if (err instanceof TimeoutError) {
|
|
459
602
|
return {
|
|
460
603
|
testId: entry.testId,
|
|
@@ -486,7 +629,7 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
486
629
|
testId: entry.testId,
|
|
487
630
|
runId: entry.runId,
|
|
488
631
|
status: 'error',
|
|
489
|
-
error:
|
|
632
|
+
error: waitMemberError(err),
|
|
490
633
|
};
|
|
491
634
|
}
|
|
492
635
|
throw err;
|
|
@@ -496,32 +639,41 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
496
639
|
// `runTestRunAll`'s inline driver rather than extracting a shared helper).
|
|
497
640
|
let pollIdx = 0;
|
|
498
641
|
let inFlight = 0;
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
642
|
+
try {
|
|
643
|
+
await new Promise((resolve, reject) => {
|
|
644
|
+
function startNext() {
|
|
645
|
+
while (inFlight < opts.maxConcurrency && pollIdx < resp.accepted.length) {
|
|
646
|
+
const entry = resp.accepted[pollIdx++];
|
|
647
|
+
inFlight++;
|
|
648
|
+
pollOne(entry)
|
|
649
|
+
.then(r => {
|
|
650
|
+
results.push(r);
|
|
651
|
+
inFlight--;
|
|
652
|
+
startNext();
|
|
653
|
+
if (inFlight === 0 && pollIdx >= resp.accepted.length)
|
|
654
|
+
resolve();
|
|
655
|
+
})
|
|
656
|
+
.catch(reject);
|
|
657
|
+
}
|
|
513
658
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
659
|
+
startNext();
|
|
660
|
+
if (resp.accepted.length === 0)
|
|
661
|
+
resolve();
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
catch (err) {
|
|
665
|
+
ticker.finalize();
|
|
666
|
+
if (deps.environmentTunnel)
|
|
667
|
+
await emitEnvironmentDispatchPartial([resp], resp.accepted.map(row => row.testId), opts, deps, 'testlist', err, deps.environmentTunnel);
|
|
668
|
+
throw err;
|
|
669
|
+
}
|
|
519
670
|
ticker.finalize();
|
|
520
671
|
const passed = results.filter(r => r.status === 'passed').length;
|
|
521
672
|
const failed = results.filter(r => r.status !== 'passed' && r.status !== 'timeout').length;
|
|
522
673
|
const timedOut = results.filter(r => r.status === 'timeout').length;
|
|
523
674
|
stderrFn(`Test-list run complete: ${passed}/${resp.accepted.length} passed, ${failed} failed/blocked, ${timedOut} timed out`);
|
|
524
675
|
const jsonPayload = {
|
|
676
|
+
...(deps.environmentTunnel?.skipped?.length ? { skipped: deps.environmentTunnel.skipped } : {}),
|
|
525
677
|
accepted: results,
|
|
526
678
|
conflicts: resp.conflicts,
|
|
527
679
|
deferred: resp.deferred,
|
|
@@ -546,7 +698,20 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
546
698
|
// Multi-project list: name the suite/classname by the LIST, not one project
|
|
547
699
|
// (`resolveBatchReportProjectId`'s single-project assumption doesn't hold).
|
|
548
700
|
const suiteName = opts.reportSuiteName ?? `testsprite:testlist:${opts.listId}`;
|
|
549
|
-
const
|
|
701
|
+
const summary = summarizeAcceptedPayload(JSON.stringify(jsonPayload), {
|
|
702
|
+
notFoundNote: 'not a member of this list (not dispatched)',
|
|
703
|
+
});
|
|
704
|
+
const xml = buildJUnitReport({
|
|
705
|
+
suiteName,
|
|
706
|
+
classname: `testlist:${opts.listId}`,
|
|
707
|
+
results: [
|
|
708
|
+
...results.map(r => ({
|
|
709
|
+
...r,
|
|
710
|
+
durationSeconds: r.runId ? reportDurations.get(r.runId) : undefined,
|
|
711
|
+
})),
|
|
712
|
+
...skippedJUnitResultsFromSummary(summary, results),
|
|
713
|
+
],
|
|
714
|
+
});
|
|
550
715
|
await writeJUnitReportFile(opts.reportFile, xml);
|
|
551
716
|
}
|
|
552
717
|
out.print(jsonPayload, () => results.map(r => `${r.runId} ${r.status}`).join('\n'));
|
|
@@ -658,7 +823,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
658
823
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
659
824
|
.action(async (cmdOpts, command) => {
|
|
660
825
|
await runTestlistList({
|
|
661
|
-
...resolveCommonOptions(command),
|
|
826
|
+
...resolveCommonOptions(command, deps.env),
|
|
662
827
|
columns: cmdOpts.columns,
|
|
663
828
|
noHeader: cmdOpts.header === false,
|
|
664
829
|
}, deps);
|
|
@@ -668,7 +833,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
668
833
|
.description('Get a test list with its cases')
|
|
669
834
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
670
835
|
.action(async (listId, _cmdOpts, command) => {
|
|
671
|
-
await runTestlistGet({ ...resolveCommonOptions(command), listId }, deps);
|
|
836
|
+
await runTestlistGet({ ...resolveCommonOptions(command, deps.env), listId }, deps);
|
|
672
837
|
});
|
|
673
838
|
testlist
|
|
674
839
|
.command('create')
|
|
@@ -679,7 +844,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
679
844
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
680
845
|
.action(async (cmdOpts, command) => {
|
|
681
846
|
await runTestlistCreate({
|
|
682
|
-
...resolveCommonOptions(command),
|
|
847
|
+
...resolveCommonOptions(command, deps.env),
|
|
683
848
|
name: cmdOpts.name,
|
|
684
849
|
projectEnv: cmdOpts.projectEnv,
|
|
685
850
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -695,7 +860,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
695
860
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
696
861
|
.action(async (listId, cmdOpts, command) => {
|
|
697
862
|
await runTestlistUpdate({
|
|
698
|
-
...resolveCommonOptions(command),
|
|
863
|
+
...resolveCommonOptions(command, deps.env),
|
|
699
864
|
listId,
|
|
700
865
|
name: cmdOpts.name,
|
|
701
866
|
projectEnv: cmdOpts.projectEnv,
|
|
@@ -711,7 +876,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
711
876
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
712
877
|
.action(async (listId, cmdOpts, command) => {
|
|
713
878
|
await runTestlistDelete({
|
|
714
|
-
...resolveCommonOptions(command),
|
|
879
|
+
...resolveCommonOptions(command, deps.env),
|
|
715
880
|
listId,
|
|
716
881
|
confirm: cmdOpts.confirm,
|
|
717
882
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -724,7 +889,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
724
889
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
725
890
|
.action(async (listId, testIds, cmdOpts, command) => {
|
|
726
891
|
await runTestlistAdd({
|
|
727
|
-
...resolveCommonOptions(command),
|
|
892
|
+
...resolveCommonOptions(command, deps.env),
|
|
728
893
|
listId,
|
|
729
894
|
testIds,
|
|
730
895
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -737,7 +902,7 @@ export function createTestListCommand(deps = {}) {
|
|
|
737
902
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
738
903
|
.action(async (listId, testIds, cmdOpts, command) => {
|
|
739
904
|
await runTestlistRemove({
|
|
740
|
-
...resolveCommonOptions(command),
|
|
905
|
+
...resolveCommonOptions(command, deps.env),
|
|
741
906
|
listId,
|
|
742
907
|
testIds,
|
|
743
908
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -745,11 +910,13 @@ export function createTestListCommand(deps = {}) {
|
|
|
745
910
|
});
|
|
746
911
|
testlist
|
|
747
912
|
.command('run <list-id>')
|
|
748
|
-
.description('Run a test list (dispatch its cases and return pollable run ids)')
|
|
913
|
+
.description('Run a test list (dispatch its cases and return pollable run ids). Loopback environments open a tunnel automatically and wait.')
|
|
749
914
|
.option('--case <test-id>', 'run only this case (repeatable; default: every case in the list)', collectRepeatable, [])
|
|
750
915
|
.option('--wait', 'poll every dispatched run until terminal or --timeout', false)
|
|
916
|
+
.option('--no-wait', 'detach without opening an automatic environment tunnel')
|
|
917
|
+
.option('--skip-preflight', 'skip the loopback port probe before opening a tunnel')
|
|
751
918
|
.option('--timeout <s>', 'with --wait, max seconds to wait (1–3600, default 600)')
|
|
752
|
-
.option('--max-concurrency <n>', `with
|
|
919
|
+
.option('--max-concurrency <n>', `with a tunnel, max runs in flight (1-10, default 5); otherwise with --wait, max polls (1-${MAX_TESTLIST_RUN_CONCURRENCY}, default ${DEFAULT_TESTLIST_RUN_CONCURRENCY})`)
|
|
753
920
|
.option('--idempotency-key <key>', 'caller-supplied idempotency key (1-256 chars)')
|
|
754
921
|
.option('--report <format>', 'with --wait: write a JUnit XML sidecar after polling (accepted: junit)')
|
|
755
922
|
.option('--report-file <path>', 'output path for --report (atomic write)')
|
|
@@ -760,10 +927,13 @@ export function createTestListCommand(deps = {}) {
|
|
|
760
927
|
.action(async (listId, cmdOpts, command) => {
|
|
761
928
|
const wait = cmdOpts.wait === true;
|
|
762
929
|
await runTestlistRun({
|
|
763
|
-
...resolveCommonOptions(command),
|
|
930
|
+
...resolveCommonOptions(command, deps.env),
|
|
764
931
|
listId,
|
|
765
932
|
cases: cmdOpts.case,
|
|
766
933
|
wait,
|
|
934
|
+
noWait: command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false,
|
|
935
|
+
skipPreflight: cmdOpts.skipPreflight === true,
|
|
936
|
+
concurrencyIsDefault: cmdOpts.maxConcurrency === undefined,
|
|
767
937
|
timeoutSeconds: parseTestlistTimeoutFlag(cmdOpts.timeout),
|
|
768
938
|
maxConcurrency: parseTestlistConcurrencyFlag(cmdOpts.maxConcurrency),
|
|
769
939
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `testsprite tunnel start | status | stop
|
|
2
|
+
* `testsprite tunnel start | list | status | stop`.
|
|
3
3
|
*
|
|
4
4
|
* The out-of-band primitive under `test run --local`, which is sugar over it.
|
|
5
5
|
* Two things it buys that the sugar cannot:
|
|
@@ -22,7 +22,7 @@ import { Command } from 'commander';
|
|
|
22
22
|
import type { CommonOptions } from '../lib/client-factory.js';
|
|
23
23
|
import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
24
24
|
import { type TunnelClientHandle } from '../lib/tunnel-session.js';
|
|
25
|
-
import type { TunnelStatusResponse } from '../lib/tunnel.types.js';
|
|
25
|
+
import type { TunnelListResponse, TunnelStatusResponse } from '../lib/tunnel.types.js';
|
|
26
26
|
import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
27
27
|
export interface TunnelDeps {
|
|
28
28
|
env?: NodeJS.ProcessEnv;
|
|
@@ -41,6 +41,28 @@ export interface TunnelStartOptions extends CommonOptions {
|
|
|
41
41
|
export interface TunnelClientIdOptions extends CommonOptions {
|
|
42
42
|
clientId: string;
|
|
43
43
|
}
|
|
44
|
+
export interface TunnelStopOptions extends CommonOptions {
|
|
45
|
+
clientId?: string;
|
|
46
|
+
all?: boolean;
|
|
47
|
+
confirm?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface TunnelStopResult {
|
|
50
|
+
clientId: string;
|
|
51
|
+
stopped: boolean;
|
|
52
|
+
error?: {
|
|
53
|
+
code: string;
|
|
54
|
+
message: string;
|
|
55
|
+
exitCode: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface TunnelStopSummary {
|
|
59
|
+
results: TunnelStopResult[];
|
|
60
|
+
summary: {
|
|
61
|
+
total: number;
|
|
62
|
+
stopped: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
44
66
|
/**
|
|
45
67
|
* Open a tunnel and hold it until the command is stopped.
|
|
46
68
|
*
|
|
@@ -60,6 +82,7 @@ export declare function runTunnelStart(opts: TunnelStartOptions, deps?: TunnelDe
|
|
|
60
82
|
* defect backend-v2.0 #1068 fixed on the server side of this same question.
|
|
61
83
|
*/
|
|
62
84
|
export declare function runTunnelStatus(opts: TunnelClientIdOptions, deps?: TunnelDeps): Promise<TunnelStatusResponse>;
|
|
85
|
+
export declare function runTunnelList(opts: CommonOptions, deps?: TunnelDeps): Promise<TunnelListResponse>;
|
|
63
86
|
/**
|
|
64
87
|
* Destroy a binding. Idempotent by contract — deleting an unknown or
|
|
65
88
|
* already-deleted binding is a success, because the requested end state holds.
|
|
@@ -68,5 +91,5 @@ export declare function runTunnelStatus(opts: TunnelClientIdOptions, deps?: Tunn
|
|
|
68
91
|
* removes the client from the tunnel server. A running `tunnel start`
|
|
69
92
|
* observes the revocation on its next status check and exits.
|
|
70
93
|
*/
|
|
71
|
-
export declare function runTunnelStop(opts:
|
|
94
|
+
export declare function runTunnelStop(opts: TunnelStopOptions, deps?: TunnelDeps): Promise<void>;
|
|
72
95
|
export declare function createTunnelCommand(deps?: TunnelDeps): Command;
|