feat(ql3): add strong cluster run stop

This commit is contained in:
whyour
2026-08-12 08:21:28 +08:00
parent c0ab62e64a
commit dd370b2842
22 changed files with 1602 additions and 321 deletions
@@ -31,6 +31,22 @@ const command = normalizeClusterRunManagementCommand({
},
});
const stopCommand = normalizeClusterRunManagementCommand({
schemaVersion: 1,
operation: 'run.stop',
request: {
projectId: 'project-1',
runId: 'run-1',
requestId: 'request-stop-1',
auditEventId: '019f9400-0000-4000-8000-000000000021',
failureAuditEventId: '019f9400-0000-4000-8000-000000000022',
body: {
schema: 'qinglong/run-cancellation@v1',
mutationId: '019f9400-0000-4000-8000-000000000023',
},
},
});
function response(overrides = {}) {
return {
schemaVersion: 1,
@@ -59,7 +75,10 @@ function response(overrides = {}) {
}
test('validates one low-sensitive retry response against the request fence', () => {
assert.deepEqual(validateClusterRunManagementClientResult(response(), command), response());
assert.deepEqual(
validateClusterRunManagementClientResult(response(), command),
response(),
);
});
test('rejects response target, execution placement and shape drift', () => {
@@ -75,3 +94,35 @@ test('rejects response target, execution placement and shape drift', () => {
);
}
});
test('validates one low-sensitive stop response against the request target', () => {
const value = {
schemaVersion: 1,
operation: 'run.stop',
stop: {
schema: 'qinglong/run-cancellation@v1',
status: 'accepted',
projectId: 'project-1',
runId: 'run-1',
runStatus: 'running',
runVersion: 5,
eventSequence: 7,
cancelRequestedAtMs: 1_000_000,
cancelReason: 'user',
},
};
assert.deepEqual(
validateClusterRunManagementClientResult(value, stopCommand),
value,
);
for (const drift of [
{ ...value, stop: { ...value.stop, projectId: 'project-2' } },
{ ...value, stop: { ...value.stop, runId: 'run-2' } },
{ ...value, operation: 'run.retry' },
]) {
assert.throws(
() => validateClusterRunManagementClientResult(drift, stopCommand),
ClusterPluginPackageManagementClientRequestError,
);
}
});