Files
mcpctl/src/db/tests/helpers.ts
Michal 03827f11e4 feat: eager vLLM warmup and smart page titles in paginate stage
- Add warmup() to LlmProvider interface for eager subprocess startup
- ManagedVllmProvider.warmup() starts vLLM in background on project load
- ProviderRegistry.warmupAll() triggers all managed providers
- NamedProvider proxies warmup() to inner provider
- paginate stage generates LLM-powered descriptive page titles when
  available, cached by content hash, falls back to generic "Page N"
- project-mcp-endpoint calls warmupAll() on router creation so vLLM
  is loading while the session initializes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 19:07:39 +00:00

47 lines
1.4 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const TEST_DATABASE_URL = process.env['DATABASE_URL'] ??
'postgresql://mcpctl:mcpctl_test@localhost:5433/mcpctl_test';
let prisma: PrismaClient | undefined;
export function getTestClient(): PrismaClient {
if (!prisma) {
prisma = new PrismaClient({
datasources: { db: { url: TEST_DATABASE_URL } },
});
}
return prisma;
}
/** Return a connected test client. Schema is pushed by globalSetup. */
export async function setupTestDb(): Promise<PrismaClient> {
return getTestClient();
}
export async function cleanupTestDb(): Promise<void> {
if (prisma) {
await prisma.$disconnect();
prisma = undefined;
}
}
export async function clearAllTables(client: PrismaClient): Promise<void> {
// Delete in order respecting foreign keys
await client.auditEvent.deleteMany();
await client.auditLog.deleteMany();
await client.mcpInstance.deleteMany();
await client.promptRequest.deleteMany();
await client.prompt.deleteMany();
await client.projectServer.deleteMany();
await client.secret.deleteMany();
await client.session.deleteMany();
await client.project.deleteMany();
await client.mcpServer.deleteMany();
await client.mcpTemplate.deleteMany();
await client.groupMember.deleteMany();
await client.group.deleteMany();
await client.rbacDefinition.deleteMany();
await client.user.deleteMany();
}