chore: import upstream snapshot with attribution
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import type { Server } from 'node:http';
|
||||
|
||||
import request from 'supertest';
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { getDb } from '../../../src/database/index';
|
||||
import { runDbMigrations } from '../../../src/migrate';
|
||||
import EvalResult from '../../../src/models/evalResult';
|
||||
import { createApp } from '../../../src/server/server';
|
||||
import { createEvaluateResult } from '../../factories/eval';
|
||||
import EvalFactory from '../../factories/evalFactory';
|
||||
|
||||
describe('Eval Routes - Trace linkage persistence', () => {
|
||||
let api: ReturnType<typeof request.agent>;
|
||||
let server: Server;
|
||||
|
||||
beforeAll(async () => {
|
||||
await runDbMigrations();
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server = createApp().listen(0, '127.0.0.1', (error?: Error) =>
|
||||
error ? reject(error) : resolve(),
|
||||
);
|
||||
});
|
||||
api = request.agent(server);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (!server.listening) {
|
||||
return;
|
||||
}
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.close((error) => (error ? reject(error) : resolve()));
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
const db = await getDb();
|
||||
await db.run('DELETE FROM eval_results');
|
||||
await db.run('DELETE FROM evals_to_datasets');
|
||||
await db.run('DELETE FROM evals_to_prompts');
|
||||
await db.run('DELETE FROM evals_to_tags');
|
||||
await db.run('DELETE FROM evals');
|
||||
});
|
||||
|
||||
it('keeps trace linkage when v4 eval saves include traced rows', async () => {
|
||||
const tracedResult = createEvaluateResult({
|
||||
traceId: 'route-create-trace-id',
|
||||
evaluationId: 'route-create-evaluation-id',
|
||||
metadata: { source: 'route-create' },
|
||||
});
|
||||
|
||||
const response = await api.post('/api/eval').send({
|
||||
config: { description: 'Trace linkage route coverage' },
|
||||
prompts: [],
|
||||
results: [tracedResult],
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const [persistedResult] = await EvalResult.findManyByEvalId(response.body.id);
|
||||
expect(persistedResult.toEvaluateResult()).toMatchObject({
|
||||
traceId: 'route-create-trace-id',
|
||||
evaluationId: 'route-create-evaluation-id',
|
||||
metadata: { source: 'route-create' },
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps trace linkage when appended results arrive through POST /api/eval/:id/results', async () => {
|
||||
const eval_ = await EvalFactory.create({ numResults: 0 });
|
||||
const tracedResult = createEvaluateResult({
|
||||
traceId: 'route-append-trace-id',
|
||||
evaluationId: 'route-append-evaluation-id',
|
||||
metadata: { source: 'route-append' },
|
||||
});
|
||||
|
||||
const response = await api.post(`/api/eval/${eval_.id}/results`).send([
|
||||
{
|
||||
id: 'route-append-trace-result',
|
||||
evalId: eval_.id,
|
||||
...tracedResult,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(response.status).toBe(204);
|
||||
|
||||
const [persistedResult] = await EvalResult.findManyByEvalId(eval_.id);
|
||||
expect(persistedResult.toEvaluateResult()).toMatchObject({
|
||||
traceId: 'route-append-trace-id',
|
||||
evaluationId: 'route-append-evaluation-id',
|
||||
metadata: { source: 'route-append' },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user