Skip to content

Commit 39f6dd2

Browse files
CodeCasterXclaude
andcommitted
chore: fix /test command timeout issue
为 /test 命令添加必要的超时参数,解决 Maven 构建超时问题: - Maven clean install 添加 run_in_background 和 timeout=900000 (15分钟) - FIT 服务启动添加 run_in_background 和 timeout=120000 (2分钟) 这些更改确保了长时间运行的构建任务不会因为默认 2 分钟超时而失败。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 45b78c4 commit 39f6dd2

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.claude/commands/test.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
执行完整的测试流程,包括单元测试、构建验证和集成测试。
2+
3+
**用法:**
4+
- `/test` - 执行完整测试流程
5+
6+
**执行步骤:**
7+
8+
## 1. 清理构建产物
9+
10+
删除之前的构建目录:
11+
```bash
12+
rm -rf build
13+
```
14+
15+
## 2. 执行单元测试和构建
16+
17+
运行 Maven 构建,这会执行全量单元测试并生成构建产物:
18+
```bash run_in_background timeout=900000
19+
mvn clean install
20+
```
21+
22+
**说明:** 使用后台运行模式以避免超时限制
23+
24+
**预期结果:**
25+
- 所有单元测试通过
26+
- 在根目录生成 `build/` 目录
27+
- 构建产物包含 `build/bin/fit` 启动脚本
28+
29+
## 3. 启动 FIT 服务进行集成测试
30+
31+
**关键要求:**
32+
- `fit` 命令无法在包含 FIT 框架的目录中执行
33+
- 必须在一个新建的动态插件目录下执行
34+
35+
**启动步骤:**
36+
37+
1. **增加执行权限**
38+
```bash
39+
chmod +x build/bin/*
40+
```
41+
42+
2. **创建动态插件目录并启动**
43+
```bash run_in_background timeout=120000
44+
mkdir -p dynamic-plugins
45+
cd dynamic-plugins
46+
../build/bin/fit start
47+
```
48+
49+
使用后台运行模式,超时时间设置为 120 秒(2分钟),给服务足够的启动时间。
50+
51+
**启动成功的判断标准:**
52+
- 输出日志中包含启动成功的关键信息
53+
- 没有出现 ERROR 或 FATAL 级别的日志
54+
- 服务端口(默认 8080)成功监听
55+
56+
## 4. 验证服务功能
57+
58+
### 4.1 健康检查接口验证(推荐)
59+
60+
访问 Actuator 健康检查接口,验证插件加载情况:
61+
```bash
62+
curl -s http://localhost:8080/actuator/plugins
63+
```
64+
65+
**预期结果:**
66+
- HTTP 状态码 200
67+
- 返回 JSON 格式的插件列表
68+
- 包含核心插件信息
69+
70+
### 4.2 Swagger 文档页面验证
71+
72+
访问 OpenAPI 文档页面,验证 HTTP 服务和文档生成功能:
73+
```bash
74+
curl -s http://localhost:8080/openapi.html
75+
```
76+
77+
**预期结果:**
78+
- HTTP 状态码 200
79+
- 返回 HTML 内容
80+
- 包含 Swagger UI 页面
81+
82+
## 5. 清理测试环境
83+
84+
测试完成后,停止 FIT 服务并返回项目根目录:
85+
86+
```bash
87+
cd ..
88+
# 停止 FIT 服务(找到进程并终止)
89+
```
90+
91+
**测试报告:**
92+
93+
生成测试报告,包含:
94+
1. ✅/❌ 单元测试结果
95+
2. ✅/❌ 构建状态
96+
3. ✅/❌ FIT 服务启动状态
97+
4. ✅/❌ 健康检查接口响应
98+
5. ✅/❌ Swagger 文档页面可访问性
99+
100+
**注意事项:**
101+
102+
1. **启动目录限制**:必须在动态插件目录下执行 `fit start`
103+
2. **端口冲突**:确保 8080 端口未被占用
104+
3. **权限问题**:确保 `build/bin/fit` 有执行权限
105+
4. **进程管理**:测试完成后记得停止 FIT 服务

0 commit comments

Comments
 (0)