mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
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:
@@ -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>;
|
||||
|
||||
@@ -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>>(() => ({
|
||||
|
||||
@@ -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() },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user