- HTTP checker defaults schema 不再支持 method 字段 - resolve 逻辑从三级 fallback 简化为两级(target -> 内置默认) - 配置文件中出现 defaults.http.method 将触发未知字段校验错误 - per-target http.method 覆盖功能保持不变 - 同步更新示例配置、README 文档和测试用例
130 lines
2.7 KiB
YAML
130 lines
2.7 KiB
YAML
server:
|
|
host: "127.0.0.1"
|
|
port: 3000
|
|
dataDir: "/tmp/probes_data"
|
|
|
|
runtime:
|
|
maxConcurrentChecks: 20
|
|
|
|
defaults:
|
|
interval: "30s"
|
|
timeout: "10s"
|
|
http:
|
|
maxBodyBytes: "10MB"
|
|
cmd:
|
|
maxOutputBytes: "1MB"
|
|
|
|
targets:
|
|
# ========== HTTP targets ==========
|
|
|
|
- name: "Baidu 首页可用"
|
|
type: http
|
|
group: "搜索引擎"
|
|
http:
|
|
url: "https://www.baidu.com"
|
|
expect:
|
|
status: [200]
|
|
maxDurationMs: 5000
|
|
|
|
- name: "JSON API — 完整流水线"
|
|
type: http
|
|
group: "后端服务"
|
|
interval: "1m"
|
|
timeout: "15s"
|
|
http:
|
|
url: "https://httpbin.org/json"
|
|
headers:
|
|
Accept: "application/json"
|
|
expect:
|
|
headers:
|
|
Content-Type:
|
|
contains: "application/json"
|
|
maxDurationMs: 8000
|
|
body:
|
|
- json:
|
|
path: "$.slideshow.title"
|
|
equals: "Sample Slide Show"
|
|
- json:
|
|
path: "$.slideshow.slides[0].title"
|
|
contains: "Wake"
|
|
- regex: '"title"'
|
|
|
|
- name: "POST 接口测试"
|
|
type: http
|
|
http:
|
|
url: "https://httpbin.org/post"
|
|
method: POST
|
|
headers:
|
|
Content-Type: "application/json"
|
|
body: '{"action":"check","version":1}'
|
|
expect:
|
|
status: [200]
|
|
body:
|
|
- json:
|
|
path: "$.json.action"
|
|
equals: "check"
|
|
- json:
|
|
path: "$.json.version"
|
|
gte: 1
|
|
|
|
# ========== Cmd targets ==========
|
|
|
|
- name: "Bun 版本输出匹配"
|
|
type: cmd
|
|
group: "系统检查"
|
|
cmd:
|
|
exec: "bun"
|
|
args: ["--version"]
|
|
expect:
|
|
exitCode: [0]
|
|
stdout:
|
|
- match: "^\\d+\\.\\d+\\.\\d+"
|
|
|
|
- name: "多规则 stdout 顺序校验"
|
|
type: cmd
|
|
interval: "5m"
|
|
cmd:
|
|
exec: "bun"
|
|
args: ["-e", "console.log('version: 2.0.1, status: healthy')"]
|
|
expect:
|
|
stdout:
|
|
- contains: "version:"
|
|
- match: "\\d+\\.\\d+\\.\\d+"
|
|
- contains: "healthy"
|
|
|
|
- name: "stderr 内容检查"
|
|
type: cmd
|
|
cmd:
|
|
exec: "bun"
|
|
args: ["-e", "process.stderr.write('simulated error\\n'); process.exit(1)"]
|
|
expect:
|
|
exitCode: [1]
|
|
stderr:
|
|
- contains: "simulated error"
|
|
|
|
# ========== DB targets ==========
|
|
|
|
- name: "SQLite 内存数据库连接测试"
|
|
type: db
|
|
group: "数据库"
|
|
db:
|
|
url: "sqlite://:memory:"
|
|
expect:
|
|
maxDurationMs: 1000
|
|
|
|
- name: "SQLite 内存数据库多列结果校验"
|
|
type: db
|
|
db:
|
|
url: "sqlite://:memory:"
|
|
query: "SELECT 1 as id, 'Alice' as name, 'engineer' as role"
|
|
expect:
|
|
rowCount:
|
|
equals: 1
|
|
rows:
|
|
- id:
|
|
gte: 1
|
|
name:
|
|
exists: true
|
|
role:
|
|
contains: "engineer"
|