feat: 支持基于 crontab 的定时账号测试
每个测试计划绑定一个账号和一个模型,按 cron 表达式定期执行测试, 保存历史结果并在前端账号管理页面中提供完整的增删改查和结果查看功能。 主要变更: - 新增 scheduled_test_plans / scheduled_test_results 两张表及迁移 - 后端 service 层:CRUD 服务 + 后台 cron runner(每分钟扫描到期计划并发执行) - RunTestBackground 方法通过 httptest 在内存中执行账号测试并解析 SSE 输出 - Redis leader lock + pg_try_advisory_lock 双重保障多实例部署只执行一次 - REST API:5 个管理端点(计划 CRUD + 结果查询) - 前端 ScheduledTestsPanel 组件:计划管理、启用开关、内联编辑、结果展开查看 - 中英文 i18n 支持 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1457,3 +1457,45 @@ export interface TotpLogin2FARequest {
|
||||
temp_token: string
|
||||
totp_code: string
|
||||
}
|
||||
|
||||
// ==================== Scheduled Test Types ====================
|
||||
|
||||
export interface ScheduledTestPlan {
|
||||
id: number
|
||||
account_id: number
|
||||
model_id: string
|
||||
cron_expression: string
|
||||
enabled: boolean
|
||||
max_results: number
|
||||
last_run_at: string | null
|
||||
next_run_at: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface ScheduledTestResult {
|
||||
id: number
|
||||
plan_id: number
|
||||
status: string
|
||||
response_text: string
|
||||
error_message: string
|
||||
latency_ms: number
|
||||
started_at: string
|
||||
finished_at: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface CreateScheduledTestPlanRequest {
|
||||
account_id: number
|
||||
model_id: string
|
||||
cron_expression: string
|
||||
enabled?: boolean
|
||||
max_results?: number
|
||||
}
|
||||
|
||||
export interface UpdateScheduledTestPlanRequest {
|
||||
model_id?: string
|
||||
cron_expression?: string
|
||||
enabled?: boolean
|
||||
max_results?: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user