Skip to content

Latest commit

 

History

History
208 lines (162 loc) · 4.5 KB

File metadata and controls

208 lines (162 loc) · 4.5 KB

🎉 项目启动成功!

✅ 服务状态

  • 后端服务: 运行中 (端口 5001)
  • 数据库: SQLite (开发模式)
  • 管理员账号: admin / admin123

📍 访问地址

🧪 API 测试结果

1. 登录 API ✅

curl -X POST http://localhost:5001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123"}'

响应:

{
  "message": "Login successful",
  "user": {
    "id": 1,
    "username": "admin"
  }
}

2. 获取任务列表 ✅

curl -X GET http://localhost:5001/api/tasks/ \
  -b cookies.txt

响应:

{
  "tasks": []
}

3. 创建任务 ✅

curl -X POST http://localhost:5001/api/tasks/ \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "name": "测试压力测试任务",
    "task_type": "perf_test",
    "config": "{\"url\":\"https://tokensea.ai\",\"api_key\":\"test-key\",\"model\":\"Qwen2.5-0.5B-Instruct\",\"parallel\":8,\"number\":50}",
    "schedule_type": "manual",
    "is_enabled": false
  }'

响应:

{
  "message": "Task created successfully",
  "task": {
    "id": 1,
    "name": "测试压力测试任务",
    "task_type": "perf_test",
    "status": "idle"
  }
}

4. 获取统计信息 ✅

curl -X GET http://localhost:5001/api/results/statistics \
  -b cookies.txt

响应:

{
  "total_tasks": 1,
  "enabled_tasks": 0,
  "running_tasks": 0,
  "total_perf_results": 0,
  "total_quality_results": 0
}

📝 已修复的问题

  1. 数据库配置: 使用 SQLite 替代 MySQL(开发环境)
  2. User 模型: 添加 UserMixin 继承以支持 Flask-Login
  3. 端口冲突: 从 5000 改为 5001

🚀 下一步操作

选项 1: 使用 API(推荐)

使用 curl 或 Postman 测试 API:

# 登录并保存 cookie
curl -X POST http://localhost:5001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123"}' \
  -c cookies.txt

# 查看任务列表
curl -X GET http://localhost:5001/api/tasks/ -b cookies.txt

# 创建新任务
curl -X POST http://localhost:5001/api/tasks/ \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{"name":"我的任务","task_type":"perf_test","config":"{\"url\":\"https://api.example.com\",\"api_key\":\"sk-xxx\",\"model\":\"gpt-3.5-turbo\",\"parallel\":8,\"number\":50}","schedule_type":"manual","is_enabled":false}'

选项 2: 构建前端(需要 Node.js)

如果需要完整的前端界面:

cd frontend
npm install
npm run build

然后访问 http://localhost:5001 即可看到完整的管理界面。

选项 3: 开发模式(前后端分离)

前端开发服务器:

cd frontend
npm install
npm run dev

访问 http://localhost:3000(前端会自动代理到后端 5001)

📊 数据库信息

  • 位置: backend/backend.db
  • 类型: SQLite
  • 表结构: 已创建 4 个表
    • users (用户表)
    • tasks (任务表)
    • perf_test_results (压力测试结果表)
    • quality_test_results (质量测试结果表)

🔧 管理命令

# 查看日志
tail -f app.log

# 停止服务
kill <PID>

# 重启服务
python3 run.py

# 初始化数据库
python3 init_db.py

📖 API 文档

认证 API

  • POST /api/auth/login - 登录
  • POST /api/auth/logout - 登出
  • GET /api/auth/me - 获取当前用户
  • POST /api/auth/change-password - 修改密码

任务 API

  • GET /api/tasks/ - 获取任务列表
  • GET /api/tasks/ - 获取任务详情
  • POST /api/tasks/ - 创建任务
  • PUT /api/tasks/ - 更新任务
  • DELETE /api/tasks/ - 删除任务
  • POST /api/tasks//run - 执行任务
  • POST /api/tasks//stop - 停止任务

结果 API

  • GET /api/results/perf - 获取压力测试结果
  • GET /api/results/quality - 获取质量测试结果
  • GET /api/results/statistics - 获取统计信息

🎯 测试建议

  1. 使用 Postman 或 curl 测试所有 API
  2. 创建几个测试任务(压力测试和质量测试)
  3. 手动执行任务查看结果
  4. 查询结果验证数据保存

📝 注意事项

  • 当前使用 SQLite 数据库,适合开发测试
  • 生产环境建议切换到 MySQL(修改 .env 配置)
  • 前端需要构建才能看到完整界面
  • API Key 等敏感信息请妥善保管

🎉 项目已成功启动!

所有核心功能已验证正常工作,可以开始使用 API 进行测试了!