fix(fleet): heartbeat consistency — MOSAIC_HOME path + configurable interval (#595)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #595.
This commit is contained in:
@@ -851,6 +851,23 @@ describe('fleet ps — heartbeat parsing', () => {
|
||||
expect(hb.health).toBe('unknown');
|
||||
expect(hb.ts).toBeNull();
|
||||
});
|
||||
|
||||
it('honors MOSAIC_HEARTBEAT_INTERVAL for the freshness threshold', () => {
|
||||
const prev = process.env.MOSAIC_HEARTBEAT_INTERVAL;
|
||||
try {
|
||||
// A 60s-old beat is STALE at the default 15s interval (3x15 = 45s)...
|
||||
const ts = new Date(NOW - 60_000).toISOString();
|
||||
const content = `ts=${ts}\npid=1\nstatus=ok\n`;
|
||||
delete process.env.MOSAIC_HEARTBEAT_INTERVAL;
|
||||
expect(parseHeartbeat(content, NOW).health).toBe('stale');
|
||||
// ...but HEALTHY when the operator widened the interval to 30s (3x30 = 90s).
|
||||
process.env.MOSAIC_HEARTBEAT_INTERVAL = '30';
|
||||
expect(parseHeartbeat(content, NOW).health).toBe('healthy');
|
||||
} finally {
|
||||
if (prev === undefined) delete process.env.MOSAIC_HEARTBEAT_INTERVAL;
|
||||
else process.env.MOSAIC_HEARTBEAT_INTERVAL = prev;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('fleet ps — systemd show parsing', () => {
|
||||
|
||||
Reference in New Issue
Block a user