Improve failover status feedback and controls
Build and Deploy Gateway / build-and-push (push) Successful in 26s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-20 01:32:03 +03:00
parent 9055934e92
commit 74227ae38c
7 changed files with 174 additions and 87 deletions
+22
View File
@@ -295,6 +295,7 @@ test('an in-flight observation is discarded after failover is disabled', async (
await testHarness.service.reconcile();
const round = testHarness.service.runRound();
await new Promise((resolve) => setImmediate(resolve));
assert.equal(testHarness.service.snapshot().reason, 'checking-channels');
await testHarness.service.save({ ...enabled, enabled: false });
for (const probe of pending) probe.resolve({ vpn: { sites: [{ status: probe.role === 'reserve' ? 'available' : 'unavailable' }] } });
await round;
@@ -320,6 +321,27 @@ test('one channel probe failure does not erase the other channel health', async
await testHarness.service.checkNow();
assert.equal(testHarness.service.snapshot().primary.health, 'unknown');
assert.equal(testHarness.service.snapshot().reserve.health, 'healthy');
assert.notEqual(testHarness.service.snapshot().reason, 'checking-channels');
});
test('manual check exposes both in-flight channel roles and clears them after completion', async () => {
const pending = [];
const testHarness = harness(serviceState(), {
dataplane: {
checkConfig: async () => ({}),
runFailoverProbe: (role) => new Promise((resolve) => pending.push({ role, resolve })),
readFailoverSelector: async () => ({ role: 'primary' }),
selectFailoverRole: async (role) => ({ role }),
setFailoverActivityEnabled: async () => {},
readFailoverActivity: async () => ({ activity: { state: 'quiet', observedAt: new Date().toISOString() } }),
},
});
const check = testHarness.service.checkNow();
await new Promise(setImmediate);
assert.equal(testHarness.service.snapshot().reason, 'checking-channels');
for (const probe of pending) probe.resolve({ vpn: { sites: [{ status: 'available' }] } });
await check;
assert.notEqual(testHarness.service.snapshot().reason, 'checking-channels');
});
test('monitoring wakes at an earlier decision deadline instead of waiting a full interval', async () => {