@overkill-dev/run 0.0.65 → 0.0.66
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/attachments/attachment-context.js +10 -0
- package/attachments/attachment-context.js.map +1 -1
- package/attachments/failure-artifact-stream.js +53 -0
- package/attachments/failure-artifact-stream.js.map +1 -0
- package/attachments/resource-failure-context.js +41 -0
- package/attachments/resource-failure-context.js.map +1 -0
- package/engine/case-execution.d.ts +1 -0
- package/engine/case-execution.d.ts.map +1 -1
- package/engine/case-execution.js +17 -29
- package/engine/case-execution.js.map +1 -1
- package/engine/recorded-assertion-failure.js +30 -0
- package/engine/recorded-assertion-failure.js.map +1 -0
- package/engine/run-artifact.d.ts +2 -2
- package/engine/run-artifact.d.ts.map +1 -1
- package/engine/runtime-attachment.d.ts +25 -5
- package/engine/runtime-attachment.d.ts.map +1 -1
- package/engine/runtime-attachment.js.map +1 -1
- package/package-version.js +31 -0
- package/package-version.js.map +1 -0
- package/package.json +21 -3
- package/packages/resources/attachment-context.entry-point.js +1 -1
- package/packages/resources/attachment-context.entry-point.js.map +1 -1
- package/packages/simulation/transcript.entry-point.js +2 -0
- package/packages/simulation/transcript.entry-point.js.map +1 -1
- package/readme.md +18 -6
- package/reporters/human-reporter-rendering.js +52 -22
- package/reporters/human-reporter-rendering.js.map +1 -1
- package/resources/failure-artifacts.js +9 -0
- package/resources/failure-artifacts.js.map +1 -0
- package/run/assertion-result-schema.js +69 -0
- package/run/assertion-result-schema.js.map +1 -0
- package/run/attachment-coordinator-context.js.map +1 -1
- package/run/attachment-coordinator.js +8 -4
- package/run/attachment-coordinator.js.map +1 -1
- package/run/attachment-execution.js +53 -6
- package/run/attachment-execution.js.map +1 -1
- package/run/attachment-protocol.js +4 -0
- package/run/attachment-protocol.js.map +1 -1
- package/run/attachment-reporter.js +1 -0
- package/run/attachment-reporter.js.map +1 -1
- package/run/attachment-results.js +5 -9
- package/run/attachment-results.js.map +1 -1
- package/run/attachment-storage-session.js +1 -0
- package/run/attachment-storage-session.js.map +1 -1
- package/run/attachment-storage-writer.js +128 -0
- package/run/attachment-storage-writer.js.map +1 -0
- package/run/attachment-store.js +84 -127
- package/run/attachment-store.js.map +1 -1
- package/run/attachment-wire-schema.js +45 -9
- package/run/attachment-wire-schema.js.map +1 -1
- package/run/attachment-worker-context.js +1 -1
- package/run/attachment-worker-context.js.map +1 -1
- package/run/attachment-writer.js +5 -3
- package/run/attachment-writer.js.map +1 -1
- package/run/capability-policy-snapshots.d.ts +3 -2
- package/run/capability-policy-snapshots.d.ts.map +1 -1
- package/run/capability-policy-snapshots.js.map +1 -1
- package/run/capability-policy.js +48 -38
- package/run/capability-policy.js.map +1 -1
- package/run/child-process-protocol.js +17 -13
- package/run/child-process-protocol.js.map +1 -1
- package/run/child-process-shutdown.js +54 -0
- package/run/child-process-shutdown.js.map +1 -0
- package/run/collected-run-plan-schema.js +90 -0
- package/run/collected-run-plan-schema.js.map +1 -0
- package/run/coverage-config-schema.d.ts +2 -2
- package/run/coverage-runtime-source.js +5 -0
- package/run/coverage-runtime-source.js.map +1 -1
- package/run/coverage-source-selection.js +6 -2
- package/run/coverage-source-selection.js.map +1 -1
- package/run/current-process-run-orchestrator.js +7 -11
- package/run/current-process-run-orchestrator.js.map +1 -1
- package/run/diff-schema.js +78 -0
- package/run/diff-schema.js.map +1 -0
- package/run/failure-artifact-retention.js +76 -0
- package/run/failure-artifact-retention.js.map +1 -0
- package/run/node-child-process-starters.js +8 -1
- package/run/node-child-process-starters.js.map +1 -1
- package/run/node-process-policy-observation.js +43 -0
- package/run/node-process-policy-observation.js.map +1 -0
- package/run/permission-denial-runtime-policy.js +3 -0
- package/run/permission-denial-runtime-policy.js.map +1 -1
- package/run/reporter-event-schema.js +42 -0
- package/run/reporter-event-schema.js.map +1 -0
- package/run/resource-disposal-error.js +27 -0
- package/run/resource-disposal-error.js.map +1 -0
- package/run/resource-failure-preparation.js +86 -0
- package/run/resource-failure-preparation.js.map +1 -0
- package/run/resource-lifecycle-disposal.js +132 -0
- package/run/resource-lifecycle-disposal.js.map +1 -0
- package/run/resource-lifecycle-session-acquirer.js +31 -10
- package/run/resource-lifecycle-session-acquirer.js.map +1 -1
- package/run/resource-lifecycle-state.d.ts +2 -1
- package/run/resource-lifecycle-state.d.ts.map +1 -1
- package/run/resource-lifecycle-state.js +30 -1
- package/run/resource-lifecycle-state.js.map +1 -1
- package/run/resource-lifecycle.js +26 -104
- package/run/resource-lifecycle.js.map +1 -1
- package/run/run-artifact-id-schema.js +27 -0
- package/run/run-artifact-id-schema.js.map +1 -0
- package/run/run-artifact-schema.js +74 -0
- package/run/run-artifact-schema.js.map +1 -0
- package/run/run-collection-error-result.js +1 -1
- package/run/run-collection-error-result.js.map +1 -1
- package/run/run-command-schema.js +60 -0
- package/run/run-command-schema.js.map +1 -0
- package/run/run-config-schema.d.ts +2 -2
- package/run/run-errors.d.ts +2 -0
- package/run/run-errors.d.ts.map +1 -1
- package/run/run-errors.js +17 -0
- package/run/run-errors.js.map +1 -1
- package/run/run-identity-schema.js +38 -0
- package/run/run-identity-schema.js.map +1 -0
- package/run/run-local-command.js +18 -5
- package/run/run-local-command.js.map +1 -1
- package/run/run-local-coverage.js +16 -3
- package/run/run-local-coverage.js.map +1 -1
- package/run/run-orchestrator.d.ts +2 -2
- package/run/run-orchestrator.d.ts.map +1 -1
- package/run/run-orchestrator.js +2 -2
- package/run/run-orchestrator.js.map +1 -1
- package/run/run-record-versions.js +1 -30
- package/run/run-record-versions.js.map +1 -1
- package/run/run-result-schema.js +65 -0
- package/run/run-result-schema.js.map +1 -0
- package/run/run-runtime-schema.js +64 -0
- package/run/run-runtime-schema.js.map +1 -0
- package/run/run-support.js +4 -0
- package/run/run-support.js.map +1 -1
- package/run/serialized-value-schema.js +76 -0
- package/run/serialized-value-schema.js.map +1 -0
- package/run/simulation-witness.js +38 -0
- package/run/simulation-witness.js.map +1 -0
- package/run/supervised-child-failure.js +26 -0
- package/run/supervised-child-failure.js.map +1 -0
- package/run/supervised-child-process.d.ts +3 -0
- package/run/supervised-child-process.d.ts.map +1 -1
- package/run/supervised-child-process.js +2 -0
- package/run/supervised-child-process.js.map +1 -1
- package/run/supervised-child-transport.js +125 -0
- package/run/supervised-child-transport.js.map +1 -0
- package/run/supervised-child.entry-point.js +38 -33
- package/run/supervised-child.entry-point.js.map +1 -1
- package/run/supervised-child.js +2 -2
- package/run/supervised-child.js.map +1 -1
- package/run/supervised-protocol-schema.js +42 -0
- package/run/supervised-protocol-schema.js.map +1 -0
- package/run/supervised-run-collection.js +33 -30
- package/run/supervised-run-collection.js.map +1 -1
- package/run/supervised-run-runtime.js +33 -15
- package/run/supervised-run-runtime.js.map +1 -1
- package/run/supervised-run-state.js +43 -22
- package/run/supervised-run-state.js.map +1 -1
- package/run/supervised-run.js +69 -36
- package/run/supervised-run.js.map +1 -1
- package/run/worker-pool-execution.js +2 -3
- package/run/worker-pool-execution.js.map +1 -1
- package/run/worker-pool-host-process.js +50 -20
- package/run/worker-pool-host-process.js.map +1 -1
- package/run/worker-pool-host-protocol-schema.js +80 -0
- package/run/worker-pool-host-protocol-schema.js.map +1 -0
- package/run/worker-pool-host-protocol.js.map +1 -1
- package/run/worker-pool-host-task.js +20 -11
- package/run/worker-pool-host-task.js.map +1 -1
- package/run/worker-pool-host-transport.js +96 -0
- package/run/worker-pool-host-transport.js.map +1 -0
- package/run/worker-pool-host.entry-point.js +37 -5
- package/run/worker-pool-host.entry-point.js.map +1 -1
- package/run/worker-pool-protocol.js +3 -0
- package/run/worker-pool-protocol.js.map +1 -1
- package/run/worker-pool-resource-lifecycle-execution.js +66 -1
- package/run/worker-pool-resource-lifecycle-execution.js.map +1 -1
- package/run/worker-pool-routing.js +2 -1
- package/run/worker-pool-routing.js.map +1 -1
- package/run/worker-pool-task-events.js +18 -15
- package/run/worker-pool-task-events.js.map +1 -1
- package/run/worker-pool-task-schema.js +61 -0
- package/run/worker-pool-task-schema.js.map +1 -0
- package/run/worker-pool-task-validation.js +1 -0
- package/run/worker-pool-task-validation.js.map +1 -1
- package/run/worker-pool-worker-resources.js +68 -0
- package/run/worker-pool-worker-resources.js.map +1 -1
- package/run/worker-pool-worker.js +11 -4
- package/run/worker-pool-worker.js.map +1 -1
- package/sbom.cdx.json +5 -5
- package/stored-value.js +12 -0
- package/stored-value.js.map +1 -0
- package/transcript/http-transcript-artifact.js +2 -0
- package/transcript/http-transcript-artifact.js.map +1 -0
- package/transcript/transcript-store.d.ts +1 -1
- package/transcript/transcript-store.d.ts.map +1 -1
- package/transcript/transcript-store.js +29 -3
- package/transcript/transcript-store.js.map +1 -1
- package/run/node-process-capability-restrictions.js +0 -92
- package/run/node-process-capability-restrictions.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-disposal-error.js","sourceRoot":"","sources":["../../../../source/run/resource-disposal-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACjD,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAuB,KAAK,CAAC,MAAM,CAAC;QAChD,OAAO,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,CAAE,KAAK,CAAE,CAAC;AACrB,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IACzC,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,OAAO,CAAE,CAAC;IAC/C,CAAC;IACD,OAAO,CAAE;YACL,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE,IAAI;YACtB,KAAK,EAAE,KAAK;YACZ,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,2BAA2B;YACpC,OAAO,EAAE,gBAAgB;SAC5B,CAAE,CAAC;AACR,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACjD,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { preparedResourceAttachments } from "../packages/resources/attachment-context.entry-point.js";
|
|
2
|
+
import { runWithTranscriptScope } from "../transcript/transcript-store.js";
|
|
3
|
+
import { prepareResourceFailureArtifacts } from "../resources/failure-artifacts.js";
|
|
4
|
+
import { resolvedResourceScenarioBindings } from "../resources/resource-scenario-binding.js";
|
|
5
|
+
import { AttachmentOperationError } from "./attachment-failure.js";
|
|
6
|
+
import { simulationWitnessAttachments } from "./simulation-witness.js";
|
|
7
|
+
function attemptScenarioBindings(record, testCase) {
|
|
8
|
+
const selected = Object.fromEntries(testCase.workId.runtimes.flatMap(function runtimeScenarios(runtime) {
|
|
9
|
+
return Object.entries(runtime.scenarios);
|
|
10
|
+
}));
|
|
11
|
+
return Object.fromEntries(Object.entries(resolvedResourceScenarioBindings(record.descriptor)).map(function resolvedSlot([name, value]) {
|
|
12
|
+
return [name, selected[name] ?? value];
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
export async function prepareAttemptResource(record, testCase, attempt) {
|
|
16
|
+
if (record.external) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const attachments = preparedResourceAttachments(record.descriptor.name, {
|
|
20
|
+
kind: 'attempt',
|
|
21
|
+
work: testCase.workId,
|
|
22
|
+
attempt
|
|
23
|
+
}, 'instrumented', 'attachment');
|
|
24
|
+
if (attachments === null) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
await prepareResourceFailureArtifacts(record.descriptor, {
|
|
29
|
+
kind: 'attempt',
|
|
30
|
+
handle: record.ownerHandle,
|
|
31
|
+
resource: record.descriptor.name,
|
|
32
|
+
scenarios: attemptScenarioBindings(record, testCase),
|
|
33
|
+
signal: controller.signal,
|
|
34
|
+
work: testCase.workId,
|
|
35
|
+
attempt,
|
|
36
|
+
attachments: simulationWitnessAttachments(attachments, record.descriptor.name, testCase.workId, attempt)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function prepareLifetimeCapture(record, capture) {
|
|
40
|
+
try {
|
|
41
|
+
await runWithTranscriptScope(null, async function prepareLifetimeEvidence() {
|
|
42
|
+
await prepareResourceFailureArtifacts(record.descriptor, capture);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new AttachmentOperationError('Failure artifact preparation failed.', {
|
|
47
|
+
cause: { resource: record.descriptor.name, cause: error },
|
|
48
|
+
drift: false,
|
|
49
|
+
subtype: 'artifact',
|
|
50
|
+
owner: { kind: 'run' }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function prepareLifetimeResource(record) {
|
|
55
|
+
if (record.external || record.descriptor.scope === 'per-case') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const attachments = preparedResourceAttachments(record.descriptor.name, {
|
|
59
|
+
kind: 'resource',
|
|
60
|
+
resource: record.descriptor.name,
|
|
61
|
+
boundary: record.boundary.key
|
|
62
|
+
}, 'instrumented', 'attachment');
|
|
63
|
+
if (attachments !== null) {
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
await prepareLifetimeCapture(record, {
|
|
66
|
+
kind: 'lifetime',
|
|
67
|
+
handle: record.ownerHandle,
|
|
68
|
+
resource: record.descriptor.name,
|
|
69
|
+
scenarios: resolvedResourceScenarioBindings(record.descriptor),
|
|
70
|
+
signal: controller.signal,
|
|
71
|
+
attachments
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function resourcePreparationError(resource, testCase, attempt, cause) {
|
|
76
|
+
if (cause instanceof AttachmentOperationError) {
|
|
77
|
+
return cause;
|
|
78
|
+
}
|
|
79
|
+
return new AttachmentOperationError('Failure artifact preparation failed.', {
|
|
80
|
+
cause: { resource, cause },
|
|
81
|
+
drift: false,
|
|
82
|
+
subtype: 'artifact',
|
|
83
|
+
owner: { kind: 'case', work: testCase.workId, attempt }
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=resource-failure-preparation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-failure-preparation.js","sourceRoot":"","sources":["../../../../source/run/resource-failure-preparation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAA+B,MAAM,mCAAmC,CAAC;AACjH,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAG7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE,SAAS,uBAAuB,CAC5B,MAA6B,EAC7B,QAAsB;IAEtB,MAAM,QAAQ,GAAqC,MAAM,CAAC,WAAW,CACjE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,gBAAgB,CAAC,OAAO;QAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC,CAAC,CACL,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,gCAAgC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,YAAY,CAAC,CAAE,IAAI,EAAE,KAAK,CAAE;QACzG,OAAO,CAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,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C,sCAAsC,EAAE;QACxE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;QAC1B,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE;KAC1D,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { resourceAttachments } from "../packages/resources/attachment-context.entry-point.js";
|
|
2
|
+
import { closeAttemptFailureStreams } from "../attachments/failure-artifact-stream.js";
|
|
3
|
+
import { callableResourceDefinition } from "../resources/resource-graph.js";
|
|
4
|
+
import { resourceDisposalErrors, resourceDisposalCauses } from "./resource-disposal-error.js";
|
|
5
|
+
import { prepareLifetimeResource, prepareAttemptResource, resourcePreparationError } from "./resource-failure-preparation.js";
|
|
6
|
+
import { lifecycleScenarioBindings } from "./resource-lifecycle-composition.js";
|
|
7
|
+
import { currentAttachmentExecution } from "./resource-lifecycle-state.js";
|
|
8
|
+
import { caseResourceBoundaryKeys, resourceScopes } from "./resource-lifecycle-boundaries.js";
|
|
9
|
+
async function disposeResourceRecord(record, signal, timing) {
|
|
10
|
+
const { dispose } = callableResourceDefinition(record.descriptor);
|
|
11
|
+
if (record.external || dispose === null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const disposeHandle = async function disposeResourceHandle() {
|
|
15
|
+
await dispose(record.ownerHandle, {
|
|
16
|
+
attachments: resourceAttachments(record.descriptor.name),
|
|
17
|
+
dependencies: record.dependencyContext,
|
|
18
|
+
scenarios: lifecycleScenarioBindings(record.descriptor),
|
|
19
|
+
signal
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
if (timing === null) {
|
|
23
|
+
await disposeHandle();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
await timing.measure({
|
|
27
|
+
phase: 'dispose',
|
|
28
|
+
resource: { name: record.descriptor.name, scope: record.descriptor.scope },
|
|
29
|
+
signal
|
|
30
|
+
}, disposeHandle);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function disposePreparedResource(record, request) {
|
|
34
|
+
const [preparation] = await Promise.allSettled([prepareLifetimeResource(record)]);
|
|
35
|
+
const [disposal] = await Promise.allSettled([disposeResourceRecord(record, request.signal, request.timing)]);
|
|
36
|
+
const failures = [preparation, disposal].flatMap(function failure(result) {
|
|
37
|
+
return result.status === 'rejected'
|
|
38
|
+
? [
|
|
39
|
+
result.reason instanceof Error
|
|
40
|
+
? result.reason
|
|
41
|
+
: new Error('Resource cleanup failed.', { cause: result.reason })
|
|
42
|
+
]
|
|
43
|
+
: [];
|
|
44
|
+
});
|
|
45
|
+
if (failures.length > 0) {
|
|
46
|
+
await currentAttachmentExecution()?.markResourceFailure(record.boundary.key);
|
|
47
|
+
if (failures.length === 1 && failures[0] !== undefined) {
|
|
48
|
+
throw failures[0];
|
|
49
|
+
}
|
|
50
|
+
throw new AggregateError(failures, 'Resource cleanup failed.');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export async function disposeBoundary(stores, boundaryKey, request) {
|
|
54
|
+
const record = stores.existingRecord(boundaryKey);
|
|
55
|
+
if (record === undefined) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
stores.deleteRecord(boundaryKey);
|
|
59
|
+
stores.deleteAcquisition(boundaryKey);
|
|
60
|
+
await disposePreparedResource(record, request);
|
|
61
|
+
}
|
|
62
|
+
export function freshDisposalSignal() {
|
|
63
|
+
const controller = new AbortController();
|
|
64
|
+
return controller.signal;
|
|
65
|
+
}
|
|
66
|
+
async function disposeCompletedBoundary(stores, boundary, timing, testCases) {
|
|
67
|
+
const remaining = stores.remainingBoundaryUses(boundary);
|
|
68
|
+
if (remaining <= 0) {
|
|
69
|
+
await disposeBoundary(stores, boundary, { signal: freshDisposalSignal(), timing, testCases });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export async function disposeCompletedBoundaries(stores, options, testCase) {
|
|
73
|
+
const sharedScopes = new Set(Array.from(options.caseDisposalScopes).filter(function isShared(scope) {
|
|
74
|
+
return scope !== 'per-case';
|
|
75
|
+
}));
|
|
76
|
+
for (const boundary of caseResourceBoundaryKeys(testCase, sharedScopes).toReversed()) {
|
|
77
|
+
try {
|
|
78
|
+
await disposeCompletedBoundary(stores, boundary, options.timing, options.testCases);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
for (const cause of resourceDisposalCauses(error)) {
|
|
82
|
+
stores.recordCaseError(testCase, 'Resource disposal failed.', cause);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export async function prepareManagedResources(stores, testCase, attempt) {
|
|
88
|
+
const boundaries = caseResourceBoundaryKeys(testCase, new Set(resourceScopes));
|
|
89
|
+
for (const record of stores.records()) {
|
|
90
|
+
if (boundaries.includes(record.boundary.key)) {
|
|
91
|
+
try {
|
|
92
|
+
await prepareAttemptResource(record, testCase, attempt);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
stores.recordCaseError(testCase, 'Failure artifact preparation failed.', resourcePreparationError(record.descriptor.name, testCase, attempt, error));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function closeManagedFailureStreams(stores, testCase, attempt) {
|
|
101
|
+
try {
|
|
102
|
+
await closeAttemptFailureStreams(testCase.workId, attempt);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
stores.recordCaseError(testCase, 'Failure artifact capture failed.', resourcePreparationError('integration resources', testCase, attempt, error));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function disposeAllManagedResources(stores, signal, timing, testCases) {
|
|
109
|
+
const errors = [];
|
|
110
|
+
for (const record of stores.records().toReversed()) {
|
|
111
|
+
try {
|
|
112
|
+
await disposeBoundary(stores, record.boundary.key, { signal, timing, testCases });
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
errors.push(...resourceDisposalErrors(error));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return errors;
|
|
119
|
+
}
|
|
120
|
+
export async function completeManagedBoundaries(stores, boundaryKeys, timing, testCases) {
|
|
121
|
+
const errors = [];
|
|
122
|
+
for (const boundaryKey of boundaryKeys) {
|
|
123
|
+
try {
|
|
124
|
+
await disposeCompletedBoundary(stores, boundaryKey, timing, testCases);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
errors.push(...resourceDisposalErrors(error));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return errors;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=resource-lifecycle-disposal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-lifecycle-disposal.js","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-disposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EACH,0BAA0B,EAG7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAc9F,KAAK,UAAU,qBAAqB,CAChC,MAA6B,EAC7B,MAAmB,EACnB,MAAsC;IAEtC,MAAM,EAAE,OAAO,EAAE,GAAG,0BAA0B,CAAC,MAAM,CA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,CAAC,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC3C,MAA8B,EAC9B,YAA+B,EAC/B,MAAsC,EACtC,SAAkC;IAElC,MAAM,MAAM,GAAyB,EAAE,CAAC;IAExC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACrC,IAAI,CAAC;YACD,MAAM,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC3E,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runWithResourceFailureContext } from "../attachments/resource-failure-context.js";
|
|
2
2
|
import { workIdentityKey } from "../engine/identity.js";
|
|
3
3
|
import { acquisitionResourceScenarioBindings, exposeResourceHandle, sourceResourceDefinition } from "../resources/resource-scenario-binding.js";
|
|
4
|
-
import { boundaryFor, initialBoundaryUseCountsFromRecords } from "./resource-lifecycle-boundaries.js";
|
|
5
|
-
import { resourceWrapperLifecycleError } from "./resource-lifecycle-error.js";
|
|
4
|
+
import { caseResourceBoundaryKeys, boundaryFor, initialBoundaryUseCountsFromRecords } from "./resource-lifecycle-boundaries.js";
|
|
5
|
+
import { resourceWrapperLifecycleError, resourceWrapperErrorFromUnknown } from "./resource-lifecycle-error.js";
|
|
6
6
|
import { acquireResourceWithStartupBudget } from "./resource-lifecycle-startup-budget.js";
|
|
7
7
|
import { deserializeProjectedHandle, projectedHandle, serializeProjectedHandle } from "./resource-lifecycle-projection.js";
|
|
8
|
-
import { currentLifecycleAttempt } from "./resource-lifecycle-state.js";
|
|
8
|
+
import { currentLifecycleAttempt, currentAttachmentExecution } from "./resource-lifecycle-state.js";
|
|
9
9
|
function caseKey(testCase, attempt) {
|
|
10
10
|
return `${workIdentityKey(testCase.workId)}:${attempt.index}`;
|
|
11
11
|
}
|
|
@@ -36,7 +36,7 @@ export function createManagedStores(options) {
|
|
|
36
36
|
const key = caseKey(testCase, attempt);
|
|
37
37
|
const errors = errorsByCase.get(key) ?? [];
|
|
38
38
|
errors.push({
|
|
39
|
-
...
|
|
39
|
+
...resourceWrapperErrorFromUnknown(message, cause).runnerError(testCase.id, testCase.workId),
|
|
40
40
|
attributedToAttempt: attempt
|
|
41
41
|
});
|
|
42
42
|
errorsByCase.set(key, errors);
|
|
@@ -113,12 +113,32 @@ export function createManagedResourceAcquirer(stores, options) {
|
|
|
113
113
|
}
|
|
114
114
|
async function startResource(resource, boundary, testCase, signal) {
|
|
115
115
|
const dependencyContext = await acquireDependencyContext(resource, testCase, signal);
|
|
116
|
+
if (resource.scope !== 'per-case') {
|
|
117
|
+
const consumers = options
|
|
118
|
+
.testCases
|
|
119
|
+
.filter(function consumesBoundary(candidate) {
|
|
120
|
+
return caseResourceBoundaryKeys(candidate, new Set([resource.scope])).includes(boundary.key);
|
|
121
|
+
})
|
|
122
|
+
.map(function consumerWork(candidate) {
|
|
123
|
+
return candidate.workId;
|
|
124
|
+
});
|
|
125
|
+
await currentAttachmentExecution()?.registerResourceConsumers(boundary.key, consumers);
|
|
126
|
+
}
|
|
116
127
|
const acquireHandle = async function acquireResourceHandle() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
const condition = resource.scope === 'per-case'
|
|
129
|
+
? {
|
|
130
|
+
kind: 'attempt',
|
|
131
|
+
work: testCase.workId,
|
|
132
|
+
attempt: currentLifecycleAttempt() ?? { index: 0 }
|
|
133
|
+
}
|
|
134
|
+
: { kind: 'resource', resource: resource.name, boundary: boundary.key };
|
|
135
|
+
return await runWithResourceFailureContext({ name: resource.name, condition }, async function acquireWithFailureCapture(attachments) {
|
|
136
|
+
return await acquireResourceWithStartupBudget(resource, {
|
|
137
|
+
attachments,
|
|
138
|
+
dependencies: dependencyContext,
|
|
139
|
+
scenarios: acquisitionResourceScenarioBindings(resource),
|
|
140
|
+
signal
|
|
141
|
+
});
|
|
122
142
|
});
|
|
123
143
|
};
|
|
124
144
|
const ownerHandle = options.timing === null
|
|
@@ -163,6 +183,7 @@ export function createManagedResourceAcquirer(stores, options) {
|
|
|
163
183
|
return await acquisition;
|
|
164
184
|
}
|
|
165
185
|
catch (error) {
|
|
186
|
+
await currentAttachmentExecution()?.markResourceFailure(boundary.key);
|
|
166
187
|
stores.deleteAcquisition(boundary.key);
|
|
167
188
|
throw error;
|
|
168
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lifecycle-session-acquirer.js","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-session-acquirer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"resource-lifecycle-session-acquirer.js","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-session-acquirer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAOxE,OAAO,EACH,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EAC3B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACH,wBAAwB,EACxB,WAAW,EACX,mCAAmC,EAEtC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAC/G,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EACH,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EAE3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,uBAAuB,EACvB,0BAA0B,EAG7B,MA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AM,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjG,CAAC;IAED,eAAe,GAAG,OAAO,CAAC;IAE1B,OAAO,EAAE,OAAO,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunnerError } from '../engine/run-result.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type AttemptId } from '../engine/identity.ts';
|
|
3
3
|
import type { TestPlanCase } from '../engine/test-plan.ts';
|
|
4
4
|
import type { ComposedResourceSession, LifecycleMessages, ResourceWrapperStep } from './resource-lifecycle-composition.ts';
|
|
5
5
|
export type ManagedRunnerError = RunnerError;
|
|
@@ -11,6 +11,7 @@ type ManagedResourceScopeAcquisition = {
|
|
|
11
11
|
readonly testCase: TestPlanCase;
|
|
12
12
|
};
|
|
13
13
|
export type ManagedLifecycleState = {
|
|
14
|
+
readonly prepareAttempt: (testCase: TestPlanCase, attempt: AttemptId) => Promise<void>;
|
|
14
15
|
readonly completeCase: (testCase: TestPlanCase, attempt: AttemptId) => Promise<void>;
|
|
15
16
|
readonly acquireComposedResources: (steps: readonly ResourceWrapperStep[], signal: AbortSignal, messages: LifecycleMessages) => Promise<ComposedResourceSession>;
|
|
16
17
|
readonly acquireResourceScopes: (request: ManagedResourceScopeAcquisition) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lifecycle-state.d.ts","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource-lifecycle-state.d.ts","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAmB,KAAkB,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBA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ACxB,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,QAAQ,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,KAAK,SAAS,kBAAkB,EAAE,CAAC;IAC1G,QAAQ,CAAC,oBAAoB,EAAE,MAAM,SAAS,kBAAkB,EAAE,CAAC;IACnE,QAAQ,CAAC,aAAa,EAAE,MAAM,SAAS,kBAAkB,EAAE,CAAC;CAC/D,CAAC;AAKF,wBAAgB,sBAAsB,IAAI,qBAAqB,GAAG,IAAI,CAErE;AAED"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { runWithAttachmentContext } from "../packages/resources/attachment-context.entry-point.js";
|
|
3
|
+
import { createTranscriptAttemptScope } from "../attachments/resource-failure-context.js";
|
|
3
4
|
import { runWithTranscriptScope } from "../transcript/transcript-store.js";
|
|
5
|
+
import { workIdentityKey } from "../engine/identity.js";
|
|
4
6
|
const activeLifecycle = new AsyncLocalStorage();
|
|
5
7
|
const runningCase = new AsyncLocalStorage();
|
|
6
8
|
export function activeManagedLifecycle() {
|
|
@@ -15,9 +17,17 @@ export function currentLifecycleCase() {
|
|
|
15
17
|
export function currentLifecycleAttempt() {
|
|
16
18
|
return runningCase.getStore()?.attempt ?? null;
|
|
17
19
|
}
|
|
20
|
+
const transcriptAttempts = new WeakMap();
|
|
21
|
+
function transcriptAttemptScope(testCase, attempt) {
|
|
22
|
+
const attempts = transcriptAttempts.get(testCase) ?? new Map();
|
|
23
|
+
const scope = attempts.get(attempt.index) ?? createTranscriptAttemptScope(testCase.workId, attempt);
|
|
24
|
+
attempts.set(attempt.index, scope);
|
|
25
|
+
transcriptAttempts.set(testCase, attempts);
|
|
26
|
+
return scope;
|
|
27
|
+
}
|
|
18
28
|
export async function runWithLifecycleCase(testCase, attempt, run) {
|
|
19
29
|
return await runningCase.run({ testCase, attempt }, async function runScopedCase() {
|
|
20
|
-
return await runWithTranscriptScope(testCase, run);
|
|
30
|
+
return await runWithTranscriptScope(transcriptAttemptScope(testCase, attempt), run);
|
|
21
31
|
});
|
|
22
32
|
}
|
|
23
33
|
const executionContext = new AsyncLocalStorage();
|
|
@@ -29,4 +39,23 @@ export async function runWithAttachmentExecution(execution, run) {
|
|
|
29
39
|
return await runWithAttachmentContext(execution.context, run);
|
|
30
40
|
});
|
|
31
41
|
}
|
|
42
|
+
export async function prepareOwnedAttempt(lifecycle, testCases, work, attempt) {
|
|
43
|
+
const testCase = testCases.find(function ownsWork(candidate) {
|
|
44
|
+
return workIdentityKey(candidate.workId) === workIdentityKey(work);
|
|
45
|
+
});
|
|
46
|
+
if (testCase === undefined) {
|
|
47
|
+
throw new TypeError('Resource preparation is outside the owner session.');
|
|
48
|
+
}
|
|
49
|
+
const prepare = async function prepareOwnedResources() {
|
|
50
|
+
await runWithLifecycleCase(testCase, attempt, async function prepareScopedResources() {
|
|
51
|
+
await lifecycle.prepareAttempt(testCase, attempt);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const attachments = currentAttachmentExecution();
|
|
55
|
+
await (attachments === null ? prepare() : attachments.runAttempt(work, attempt, prepare));
|
|
56
|
+
return [
|
|
57
|
+
...lifecycle.takeAttemptErrors(testCase, attempt),
|
|
58
|
+
...attachments?.takeErrors({ kind: 'case', work, attempt }) ?? []
|
|
59
|
+
];
|
|
60
|
+
}
|
|
32
61
|
//# sourceMappingURL=resource-lifecycle-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lifecycle-state.js","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-lifecycle-state.js","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-state.ts"],"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AAK,UAAU,qBAAqB;QAChD,MAAM,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,UAAU,sBAAsB;YAC/E,MAAM,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IACF,MAAM,WAAW,GAAG,0BAA0B,EAAE,CAAC;IACjD,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1F,OAAO;QACH,GAAG,SAAS,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC;QACjD,GAAG,WAAW,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE;KACpE,CAAC;AACN,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { combinedResourceEntries, composedResourceSession, directResourceEntries,
|
|
4
|
-
import { currentAttachmentExecution, currentLifecycleCase, runWithLifecycleCase, runWithManagedLifecycle } from "./resource-lifecycle-state.js";
|
|
1
|
+
import { assertResourceDependencyScopes, createResourceGraph } from "../resources/resource-graph.js";
|
|
2
|
+
import { prepareManagedResources, closeManagedFailureStreams, disposeAllManagedResources, completeManagedBoundaries, disposeBoundary, disposeCompletedBoundaries, freshDisposalSignal } from "./resource-lifecycle-disposal.js";
|
|
3
|
+
import { combinedResourceEntries, composedResourceSession, directResourceEntries, resourceMapFromEntries, stepRuntimeGraphs } from "./resource-lifecycle-composition.js";
|
|
4
|
+
import { prepareOwnedAttempt, currentAttachmentExecution, currentLifecycleCase, runWithLifecycleCase, runWithManagedLifecycle } from "./resource-lifecycle-state.js";
|
|
5
5
|
import { resourceWrapperErrorFromUnknown, resourceWrapperLifecycleError } from "./resource-lifecycle-error.js";
|
|
6
6
|
import { managedResourceSession } from "./resource-lifecycle-managed-session.js";
|
|
7
7
|
import { boundaryFor, caseResourceBoundaryKeys, resourceLifecycleBoundaryUseCounts, resourceScopes } from "./resource-lifecycle-boundaries.js";
|
|
@@ -15,68 +15,13 @@ function currentRunningCase() {
|
|
|
15
15
|
}
|
|
16
16
|
function defaultLifecycleOptions(testCases, timing) {
|
|
17
17
|
return {
|
|
18
|
+
testCases,
|
|
18
19
|
boundaryUseCounts: resourceLifecycleBoundaryUseCounts(testCases),
|
|
19
20
|
caseDisposalScopes: new Set(resourceScopes),
|
|
20
21
|
projectedResources: { resources: [] },
|
|
21
22
|
timing
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
async function disposeResourceRecord(record, signal, timing) {
|
|
25
|
-
const { dispose } = callableResourceDefinition(record.descriptor);
|
|
26
|
-
if (record.external || dispose === null) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const disposeHandle = async function disposeResourceHandle() {
|
|
30
|
-
await dispose(record.ownerHandle, {
|
|
31
|
-
attachments: resourceAttachments(record.descriptor.name),
|
|
32
|
-
dependencies: record.dependencyContext,
|
|
33
|
-
scenarios: lifecycleScenarioBindings(record.descriptor),
|
|
34
|
-
signal
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
if (timing === null) {
|
|
38
|
-
await disposeHandle();
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
await timing.measure({
|
|
42
|
-
phase: 'dispose',
|
|
43
|
-
resource: { name: record.descriptor.name, scope: record.descriptor.scope },
|
|
44
|
-
signal
|
|
45
|
-
}, disposeHandle);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function disposeBoundary(stores, boundaryKey, signal, timing) {
|
|
49
|
-
const record = stores.existingRecord(boundaryKey);
|
|
50
|
-
if (record === undefined) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
stores.deleteRecord(boundaryKey);
|
|
54
|
-
stores.deleteAcquisition(boundaryKey);
|
|
55
|
-
await disposeResourceRecord(record, signal, timing);
|
|
56
|
-
}
|
|
57
|
-
function freshDisposalSignal() {
|
|
58
|
-
const controller = new AbortController();
|
|
59
|
-
return controller.signal;
|
|
60
|
-
}
|
|
61
|
-
async function disposeCompletedBoundary(stores, boundary, timing) {
|
|
62
|
-
const remaining = stores.remainingBoundaryUses(boundary);
|
|
63
|
-
if (remaining <= 0) {
|
|
64
|
-
await disposeBoundary(stores, boundary, freshDisposalSignal(), timing);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async function disposeCompletedBoundaries(stores, options, testCase) {
|
|
68
|
-
const sharedScopes = new Set(Array.from(options.caseDisposalScopes).filter(function isShared(scope) {
|
|
69
|
-
return scope !== 'per-case';
|
|
70
|
-
}));
|
|
71
|
-
for (const boundary of caseResourceBoundaryKeys(testCase, sharedScopes).toReversed()) {
|
|
72
|
-
try {
|
|
73
|
-
await disposeCompletedBoundary(stores, boundary, options.timing);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
stores.recordCaseError(testCase, 'Resource disposal failed.', error);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
25
|
async function acquireTopLevelResources(acquirer, graph, testCase, signal) {
|
|
81
26
|
await Promise.all(graph.topLevelEntries.map(async function acquireTopLevel([, resource]) {
|
|
82
27
|
await acquirer.acquire(resource, testCase, signal);
|
|
@@ -122,51 +67,15 @@ async function acquireManagedResourceScopes(request) {
|
|
|
122
67
|
}
|
|
123
68
|
}
|
|
124
69
|
}
|
|
125
|
-
async function disposeAllManagedResources(stores, signal, timing) {
|
|
126
|
-
const errors = [];
|
|
127
|
-
for (const record of stores.records().toReversed()) {
|
|
128
|
-
try {
|
|
129
|
-
await disposeBoundary(stores, record.boundary.key, signal, timing);
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
errors.push({
|
|
133
|
-
attributedToAttempt: null,
|
|
134
|
-
attributedTo: null,
|
|
135
|
-
attributedToWork: null,
|
|
136
|
-
cause: error,
|
|
137
|
-
diagnostics: [],
|
|
138
|
-
message: 'Resource disposal failed.',
|
|
139
|
-
subtype: 'runtime-policy'
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return errors;
|
|
144
|
-
}
|
|
145
|
-
async function completeManagedBoundaries(stores, boundaryKeys, timing) {
|
|
146
|
-
const errors = [];
|
|
147
|
-
for (const boundaryKey of boundaryKeys) {
|
|
148
|
-
try {
|
|
149
|
-
await disposeCompletedBoundary(stores, boundaryKey, timing);
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
errors.push({
|
|
153
|
-
attributedToAttempt: null,
|
|
154
|
-
attributedTo: null,
|
|
155
|
-
attributedToWork: null,
|
|
156
|
-
cause: error,
|
|
157
|
-
diagnostics: [],
|
|
158
|
-
message: 'Resource disposal failed.',
|
|
159
|
-
subtype: 'runtime-policy'
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return errors;
|
|
164
|
-
}
|
|
165
70
|
async function disposeCaseResources(stores, options, testCase) {
|
|
166
71
|
const boundaries = caseResourceBoundaryKeys(testCase, new Set(['per-case'])).toReversed();
|
|
167
72
|
for (const boundary of boundaries) {
|
|
168
73
|
try {
|
|
169
|
-
await disposeBoundary(stores, boundary,
|
|
74
|
+
await disposeBoundary(stores, boundary, {
|
|
75
|
+
signal: freshDisposalSignal(),
|
|
76
|
+
timing: options.timing,
|
|
77
|
+
testCases: options.testCases
|
|
78
|
+
});
|
|
170
79
|
}
|
|
171
80
|
catch (error) {
|
|
172
81
|
stores.recordCaseError(testCase, 'Resource disposal failed.', error);
|
|
@@ -179,6 +88,9 @@ function createManagedLifecycleState(options) {
|
|
|
179
88
|
return {
|
|
180
89
|
stores,
|
|
181
90
|
lifecycle: {
|
|
91
|
+
async prepareAttempt(testCase, attempt) {
|
|
92
|
+
await prepareManagedResources(stores, testCase, attempt);
|
|
93
|
+
},
|
|
182
94
|
async acquireComposedResources(steps, signal, messages) {
|
|
183
95
|
return await acquireManagedComposedResources({ ...context, messages, signal, steps });
|
|
184
96
|
},
|
|
@@ -186,7 +98,7 @@ function createManagedLifecycleState(options) {
|
|
|
186
98
|
await acquireManagedResourceScopes({ ...context, ...request });
|
|
187
99
|
},
|
|
188
100
|
async disposeAll(signal) {
|
|
189
|
-
return await disposeAllManagedResources(stores, signal, options.timing);
|
|
101
|
+
return await disposeAllManagedResources(stores, signal, options.timing, options.testCases);
|
|
190
102
|
},
|
|
191
103
|
async completeCase(testCase, attempt) {
|
|
192
104
|
await runWithLifecycleCase(testCase, attempt, async function completeLogicalCase() {
|
|
@@ -200,6 +112,7 @@ function createManagedLifecycleState(options) {
|
|
|
200
112
|
finally {
|
|
201
113
|
await runWithLifecycleCase(testCase, attempt, async function disposeAttemptResources() {
|
|
202
114
|
await disposeCaseResources(stores, options, testCase);
|
|
115
|
+
await closeManagedFailureStreams(stores, testCase, attempt);
|
|
203
116
|
});
|
|
204
117
|
}
|
|
205
118
|
},
|
|
@@ -217,6 +130,9 @@ function createManagedLifecycleState(options) {
|
|
|
217
130
|
}
|
|
218
131
|
function createRuntimePolicyFromLifecycle(lifecycle) {
|
|
219
132
|
return {
|
|
133
|
+
async prepareAttempt(testCase, attempt) {
|
|
134
|
+
await lifecycle.prepareAttempt(testCase, attempt);
|
|
135
|
+
},
|
|
220
136
|
async completeCase(testCase, attempt) {
|
|
221
137
|
const attachments = currentAttachmentExecution();
|
|
222
138
|
const complete = async function completeOwnedCase() {
|
|
@@ -262,8 +178,11 @@ export function createResourceLifecycleRuntimePolicy(testCases, timing) {
|
|
|
262
178
|
export function createResourceLifecycleSession(options) {
|
|
263
179
|
const { lifecycle, stores } = createManagedLifecycleState(options);
|
|
264
180
|
return {
|
|
181
|
+
async prepareAttempt(work, attempt) {
|
|
182
|
+
return await prepareOwnedAttempt(lifecycle, options.testCases, work, attempt);
|
|
183
|
+
},
|
|
265
184
|
async completeBoundaries(boundaryKeys) {
|
|
266
|
-
return await completeManagedBoundaries(stores, boundaryKeys, options.timing);
|
|
185
|
+
return await completeManagedBoundaries(stores, boundaryKeys, options.timing, options.testCases);
|
|
267
186
|
},
|
|
268
187
|
async disposeAll(signal) {
|
|
269
188
|
return await lifecycle.disposeAll(signal);
|
|
@@ -288,8 +207,11 @@ export async function acquireResourceLifecycleScopes(request) {
|
|
|
288
207
|
}
|
|
289
208
|
});
|
|
290
209
|
return {
|
|
210
|
+
async prepareAttempt(work, attempt) {
|
|
211
|
+
return await prepareOwnedAttempt(lifecycle, request.testCases, work, attempt);
|
|
212
|
+
},
|
|
291
213
|
async completeBoundaries(boundaryKeys) {
|
|
292
|
-
return await completeManagedBoundaries(stores, boundaryKeys, request.options.timing);
|
|
214
|
+
return await completeManagedBoundaries(stores, boundaryKeys, request.options.timing, request.testCases);
|
|
293
215
|
},
|
|
294
216
|
async disposeAll(disposalSignal) {
|
|
295
217
|
return await lifecycle.disposeAll(disposalSignal);
|