test(ui): cover degraded overview health semantics
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { assertEquals } from 'jsr:@std/assert@^1.0.0';
|
||||
import { ClusterManager } from '../ts/cluster/cluster-manager.ts';
|
||||
import { UiServer } from '../ts/ui/server.ts';
|
||||
|
||||
Deno.test('UiServer overview mirrors degraded API health semantics', async () => {
|
||||
const port = 20300 + Math.floor(Math.random() * 1000);
|
||||
const cluster = new ClusterManager();
|
||||
cluster.configure({
|
||||
enabled: false,
|
||||
nodeName: 'ui-test-node',
|
||||
role: 'standalone',
|
||||
bindHost: '127.0.0.1',
|
||||
gossipPort: 7946,
|
||||
heartbeatIntervalMs: 5000,
|
||||
seedNodes: [],
|
||||
});
|
||||
|
||||
const server = new UiServer(
|
||||
{ enabled: true, port, host: '127.0.0.1', assetSource: 'disk' },
|
||||
{
|
||||
async getAllStatus() {
|
||||
return new Map([
|
||||
['vllm-1', { running: false, health: 'unhealthy' }],
|
||||
]);
|
||||
},
|
||||
async getAllAvailableModels() {
|
||||
return new Map();
|
||||
},
|
||||
} as never,
|
||||
cluster,
|
||||
);
|
||||
|
||||
(server as unknown as {
|
||||
gpuDetector: { detectGpus: () => Promise<unknown[]> };
|
||||
}).gpuDetector = {
|
||||
async detectGpus() {
|
||||
return [{ id: 'nvidia-0' }];
|
||||
},
|
||||
};
|
||||
|
||||
await server.start();
|
||||
|
||||
try {
|
||||
const response = await fetch(`http://127.0.0.1:${port}/_ui/overview`);
|
||||
const body = await response.json();
|
||||
|
||||
assertEquals(response.status, 200);
|
||||
assertEquals(body.health.status, 'degraded');
|
||||
assertEquals(body.health.reasons.includes('unhealthy_container'), true);
|
||||
assertEquals(body.health.reasons.includes('no_models_available'), true);
|
||||
assertEquals(body.node.name, 'ui-test-node');
|
||||
} finally {
|
||||
await server.stop();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user