feat(core): Evaluations backend (no-changelog) (#15542)

Co-authored-by: Yiorgis Gozadinos <yiorgis@n8n.io>
Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
This commit is contained in:
Eugene
2025-05-23 09:05:13 +02:00
committed by GitHub
parent cf8b611d14
commit fa620f2d5b
18 changed files with 1266 additions and 601 deletions

View File

@@ -283,19 +283,15 @@ export type FolderWithWorkflowAndSubFolderCountAndPath = FolderWithWorkflowAndSu
export type TestRunFinalResult = 'success' | 'error' | 'warning';
export type TestRunErrorCode =
| 'PAST_EXECUTIONS_NOT_FOUND'
| 'EVALUATION_WORKFLOW_NOT_FOUND'
| 'TEST_CASES_NOT_FOUND'
| 'INTERRUPTED'
| 'UNKNOWN_ERROR';
| 'UNKNOWN_ERROR'
| 'EVALUATION_TRIGGER_NOT_FOUND';
export type TestCaseExecutionErrorCode =
| 'MOCKED_NODE_DOES_NOT_EXIST'
| 'TRIGGER_NO_LONGER_EXISTS'
| 'MOCKED_NODE_NOT_FOUND' // This will be used when node mocking will be implemented
| 'FAILED_TO_EXECUTE_WORKFLOW'
| 'EVALUATION_WORKFLOW_DOES_NOT_EXIST'
| 'FAILED_TO_EXECUTE_EVALUATION_WORKFLOW'
| 'INVALID_METRICS'
| 'PAYLOAD_LIMIT_EXCEEDED'
| 'UNKNOWN_ERROR';
export type AggregatedTestRunMetrics = Record<string, number | boolean>;

View File

@@ -32,6 +32,12 @@ export class TestCaseExecutionRepository extends Repository<TestCaseExecution> {
super(TestCaseExecution, dataSource.manager);
}
async createTestCaseExecution(testCaseExecutionProps: DeepPartial<TestCaseExecution>) {
const testCaseExecution = this.create(testCaseExecutionProps);
return await this.save(testCaseExecution);
}
async createBatch(testRunId: string, testCases: string[]) {
const mappings = this.create(
testCases.map<DeepPartial<TestCaseExecution>>(() => ({

View File

@@ -46,7 +46,7 @@ export class TestRunRepository extends Repository<TestRun> {
async markAsCancelled(id: string, trx?: EntityManager) {
trx = trx ?? this.manager;
return await trx.update(TestRun, id, { status: 'cancelled' });
return await trx.update(TestRun, id, { status: 'cancelled', completedAt: new Date() });
}
async markAsError(id: string, errorCode: TestRunErrorCode, errorDetails?: IDataObject) {
@@ -54,13 +54,14 @@ export class TestRunRepository extends Repository<TestRun> {
status: 'error',
errorCode,
errorDetails,
completedAt: new Date(),
});
}
async markAllIncompleteAsFailed() {
return await this.update(
{ status: In(['new', 'running']) },
{ status: 'error', errorCode: 'INTERRUPTED' },
{ status: 'error', errorCode: 'INTERRUPTED', completedAt: new Date() },
);
}