36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { classifyService } from '../src/classify.js';
|
|
|
|
describe('classifyService', () => {
|
|
it('operational when available meets min and none paused', () => {
|
|
assert.equal(
|
|
classifyService({ min: 3, available: 3, running: 3, paused: 0, instances: [{ pid: 1, healthy: true }] }),
|
|
'operational',
|
|
);
|
|
});
|
|
|
|
it('degraded when a replica is paused even if floor is still met', () => {
|
|
assert.equal(
|
|
classifyService({
|
|
min: 3,
|
|
available: 3,
|
|
running: 4,
|
|
paused: 1,
|
|
instances: [
|
|
{ pid: 1, paused: true, healthy: false },
|
|
{ pid: 2, paused: false, healthy: true },
|
|
],
|
|
}),
|
|
'degraded',
|
|
);
|
|
});
|
|
|
|
it('not operational when min>0 and nothing available', () => {
|
|
assert.equal(classifyService({ min: 1, available: 0, running: 0, paused: 0, instances: [] }), 'down');
|
|
});
|
|
|
|
it('optional idle (min 0, not running) is operational', () => {
|
|
assert.equal(classifyService({ min: 0, available: 0, running: 0, paused: 0 }), 'operational');
|
|
});
|
|
});
|