feat(local): bind service completion restart

This commit is contained in:
whyour
2026-08-23 00:34:46 +08:00
parent 4d71dfb937
commit 5f62f2f724
11 changed files with 659 additions and 51 deletions
@@ -92,6 +92,32 @@ test('normalizes exact systemd fresh and OpenRC adopted intents', () => {
),
});
assert.deepEqual(normalizeLocalServiceManagerIntent(openrc), openrc);
const completedRestart = intent({
schemaVersion: 2,
actionId: '123e4567-e89b-42d3-a456-426614174003',
action: 'restart',
lineage: {
mode: 'adopted',
cutoverId: 'router-edge-1-cutover',
generation: 2,
expectedActivationDigest: 'c'.repeat(64),
previousRecordDigest: 'd'.repeat(64),
completionFence: {
expectedInstanceHeadDigest: '1'.repeat(64),
expectedCompletionDigest: '2'.repeat(64),
},
},
outcomePath: path.join(
'/opt/qinglong3',
'service/service-manager-outcomes',
'123e4567-e89b-42d3-a456-426614174003.json',
),
});
assert.deepEqual(
normalizeLocalServiceManagerIntent(completedRestart),
completedRestart,
);
});
test('rejects arbitrary destinations, root drift, digest drift and unknown fields', () => {
@@ -127,6 +153,30 @@ test('rejects arbitrary destinations, root drift, digest drift and unknown field
previousRecordDigest: 'd'.repeat(64),
},
}),
intent({
schemaVersion: 2,
action: 'restart',
lineage: {
mode: 'adopted',
cutoverId: 'router-edge-1-cutover',
generation: 2,
expectedActivationDigest: 'c'.repeat(64),
previousRecordDigest: 'd'.repeat(64),
},
}),
intent({
lineage: {
mode: 'adopted',
cutoverId: 'router-edge-1-cutover',
generation: 2,
expectedActivationDigest: 'c'.repeat(64),
previousRecordDigest: 'd'.repeat(64),
completionFence: {
expectedInstanceHeadDigest: '1'.repeat(64),
expectedCompletionDigest: '2'.repeat(64),
},
},
}),
]) {
assert.throws(
() => normalizeLocalServiceManagerIntent(candidate),