smoke-test
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSmoke Test Skillpack
冒烟测试技能包
Runorgbrain smoke-testafter any container restart.bash scripts/smoke-test.sh
容器重启后运行或gbrain smoke-test。bash scripts/smoke-test.sh
Contract
功能承诺
This skill guarantees:
- 8 core tests verify gbrain + OpenClaw health after restart
- Known failures are auto-fixed before reporting
- User-extensible via drop-in scripts
~/.gbrain/smoke-tests.d/*.sh - Results logged to
/tmp/gbrain-smoke-test.log - Exit code = number of unfixed failures (0 = all pass)
本技能承诺:
- 8项核心测试验证重启后gbrain + OpenClaw的健康状态
- 报告前自动修复已知故障
- 可通过 即插即用脚本进行用户扩展
~/.gbrain/smoke-tests.d/*.sh - 结果记录至
/tmp/gbrain-smoke-test.log - 退出码 = 未修复故障数量(0表示全部通过)
Built-in Tests
内置测试
| # | Test | Auto-Fix |
|---|---|---|
| 1 | Bun runtime | Install from bun.sh |
| 2 | GBrain CLI loads | Reinstall deps |
| 3 | GBrain database (doctor) | — |
| 4 | GBrain worker process | Start worker |
| 5 | OpenClaw Codex plugin (Zod CJS) | |
| 6 | OpenClaw gateway | — (may not be started yet) |
| 7 | Embedding API key | — (check .env) |
| 8 | Brain repo exists | — |
| 序号 | 测试内容 | 自动修复方案 |
|---|---|---|
| 1 | Bun runtime | 从bun.sh安装 |
| 2 | GBrain CLI加载 | 重新安装依赖 |
| 3 | GBrain数据库(诊断) | — |
| 4 | GBrain工作进程 | 启动工作进程 |
| 5 | OpenClaw Codex插件(Zod CJS) | |
| 6 | OpenClaw网关 | —(可能尚未启动) |
| 7 | Embedding API密钥 | —(检查.env文件) |
| 8 | Brain仓库存在 | — |
Usage
使用方法
CLI
CLI方式
bash
gbrain smoke-testbash
gbrain smoke-testDirect
直接运行
bash
bash scripts/smoke-test.shbash
bash scripts/smoke-test.shFrom OpenClaw bootstrap
从OpenClaw启动脚本调用
Add to your or equivalent:
ensure-services.shbash
bash /path/to/gbrain/scripts/smoke-test.sh >> /tmp/bootstrap.log 2>&1添加至你的 或等效脚本:
ensure-services.shbash
bash /path/to/gbrain/scripts/smoke-test.sh >> /tmp/bootstrap.log 2>&1From an agent
从Agent调用
exec: bash /data/gbrain/scripts/smoke-test.shexec: bash /data/gbrain/scripts/smoke-test.shAdding Custom Tests
添加自定义测试
Create executable scripts in :
~/.gbrain/smoke-tests.d/bash
undefined在 目录下创建可执行脚本:
~/.gbrain/smoke-tests.d/bash
undefined~/.gbrain/smoke-tests.d/check-redis.sh
~/.gbrain/smoke-tests.d/check-redis.sh
#!/bin/bash
redis-cli ping | grep -q PONG
Rules:
- Exit 0 = pass, non-zero = fail
- Filename becomes the test name (e.g. `check-redis` from `check-redis.sh`)
- Keep tests fast (< 10s each)
- Tests run in alphabetical order#!/bin/bash
redis-cli ping | grep -q PONG
规则:
- 退出码0表示通过,非0表示失败
- 文件名即为测试名称(例如`check-redis.sh`对应测试名`check-redis`)
- 测试需保持快速(每个测试耗时<10秒)
- 测试按字母顺序运行Adding Built-in Tests
添加内置测试
Edit . Follow this pattern:
scripts/smoke-test.shbash
undefined编辑 ,遵循以下模式:
scripts/smoke-test.shbash
undefined── N. [Service Name] ──────────────────────────────────────
── N. [服务名称] ──────────────────────────────────────
if [test condition]; then
pass "[Service Name]"
else
Auto-fix attempt
[fix command]
if [re-test condition]; then
fixed "[What was fixed]"
pass "[Service Name] (after fix)"
else
fail "[Service Name] — [error detail]"
fi
fi
undefinedif [测试条件]; then
pass "[服务名称]"
else
尝试自动修复
[修复命令]
if [重新测试条件]; then
fixed "[修复内容]"
pass "[服务名称](修复后)"
else
fail "[服务名称] — [错误详情]"
fi
fi
undefinedDesign rules:
设计规则:
- Test first — never fix without confirming broken
- Re-test after fix — verify the fix worked
- Timeout everything — on any command that could hang
timeout N - Use helpers — ,
pass(),fail(),fixed()skip() - Idempotent fixes — safe to run repeatedly
- Skip gracefully — when a prerequisite is missing, don't fail
skip()
- 先测试再修复 — 确认故障后再执行修复操作
- 修复后重新测试 — 验证修复是否生效
- 所有操作设置超时 — 对可能挂起的命令使用
timeout N - 使用辅助函数 — ,
pass(),fail(),fixed()skip() - 修复操作幂等 — 重复执行不会产生问题
- 优雅跳过 — 当依赖缺失时使用,不要标记为失败
skip()
Environment Variables
环境变量
| Var | Default | Description |
|---|---|---|
| | Log file path |
| (auto-detect) | Force gbrain install path |
| (from .env) | Database connection URL |
| | Gateway port to test |
| | Brain repo path |
| 变量名 | 默认值 | 描述 |
|---|---|---|
| | 日志文件路径 |
| (自动检测) | 强制指定gbrain安装路径 |
| (来自.env) | 数据库连接URL |
| | 待测试的网关端口 |
| | Brain仓库路径 |
Known Issues & Their Auto-Fixes
已知问题及自动修复方案
Codex Zod core.cjs Missing (discovered 2026-04-23)
Codex Zod core.cjs缺失(发现于2026-04-23)
- Symptom: → all Codex ACP sessions fail
Cannot find module './core.cjs' - Cause: Zod v4 npm package ships without in some installs
core.cjs - Auto-fix: in the codex extension's zod dir
npm install zod@4 --force - Persistence: Does NOT survive container restart (gateway reinstalls deps)
- This is why smoke tests must run on every restart
- 症状: → 所有Codex ACP会话失败
Cannot find module './core.cjs' - 原因: Zod v4 npm包在部分安装场景下未包含
core.cjs - 自动修复: 在codex扩展的zod目录中执行
npm install zod@4 --force - 持久性: 无法在容器重启后保留(网关会重新安装依赖)
- 因此必须在每次重启后运行冒烟测试
GBrain Worker Auth Failure
GBrain工作进程认证失败
- Symptom: Worker can't connect to DB
- Cause: not propagated to worker subprocess
GBRAIN_DATABASE_URL - Auto-fix: Script explicitly passes both and
DATABASE_URLGBRAIN_DATABASE_URL
- 症状: 工作进程无法连接数据库
- 原因: 未传递给工作进程子进程
GBRAIN_DATABASE_URL - 自动修复: 脚本显式传递和
DATABASE_URL两个变量GBRAIN_DATABASE_URL
Anti-Patterns
反模式
- ❌ Running smoke tests on every chat turn. Once per container restart (or on user request) is plenty. The script is cheap but it's not free.
- ❌ Writing a user drop-in without around any command that could hang. A single hung drop-in stalls every subsequent run.
timeout N - ❌ Auto-fixing without confirming the check is actually broken first.
The loop is the contract; fixes that skip the re-test can report success on a still-broken state.
pass → fail-detected → fix → re-test - ❌ Treating as
skip. Missing prerequisites (no OpenClaw installed, no brain repo configured) are skips, not failures. Exit code = count of real failures, not skipped checks.fail - ❌ Hardcoding paths in a user drop-in. Read env vars
(,
GBRAIN_DATABASE_URL, etc.) so the script travels across container rebuilds.HOME
- ❌ 每次对话轮次都运行冒烟测试。仅需在容器重启后(或用户请求时)运行一次即可。脚本开销虽小但并非无成本。
- ❌ 在用户即插即用脚本中,不对可能挂起的命令添加。单个挂起的脚本会导致后续所有运行停滞。
timeout N - ❌ 未确认检查项确实故障就执行自动修复。是标准流程;跳过重新测试的修复可能会在状态仍异常时报告成功。
通过→检测到故障→修复→重新测试 - ❌ 将视为
跳过。缺失依赖(未安装OpenClaw、未配置brain仓库)属于跳过项,而非故障项。退出码=实际故障数量,不包含跳过的检查项。失败 - ❌ 在用户即插即用脚本中硬编码路径。读取环境变量(,
GBRAIN_DATABASE_URL等),确保脚本可在容器重建后正常运行。HOME
Output Format
输出格式
The script writes a one-line status per check to stdout (✅/❌/🔧/⏭️) plus a
final summary line: . A
structured timestamped log appends to
(default ) for post-run forensics. Exit code
equals the count of unfixed failures (0 = all pass, positive integer =
count of remaining failures).
Results: N/M passed, F auto-fixed, S skipped$GBRAIN_SMOKE_LOG/tmp/gbrain-smoke-test.log脚本会向标准输出写入每行一个检查状态(✅/❌/🔧/⏭️),最后一行是总结:。结构化的带时间戳日志会追加至(默认),用于事后分析。退出码等于未修复故障的数量(0表示全部通过,正整数表示剩余故障数量)。
结果:N/M通过,F项已修复,S项已跳过$GBRAIN_SMOKE_LOG/tmp/gbrain-smoke-test.log