refactor: 统一 expect 断言体系,引入共享 ValueMatcher/ContentRules/KeyValueExpect 模型
- 引入共享 ValueMatcher(equals/contains/regex/exists/empty/gt/gte/lt/lte) - 引入共享 ContentRules 数组(direct/json/css/xpath 提取器) - 引入共享 KeyValueExpect(动态键值断言,字面量等价 equals) - maxDurationMs → durationMs: ValueMatcher(所有 checker) - match → regex(固定无 flags) - Ping max* → packetLossPercent/avgLatencyMs/maxLatencyMs(ValueMatcher) - LLM finishReason/rawFinishReason → ValueMatcher - DB 新增 result: ContentRules - TCP banner → ContentRules 数组 - 删除旧模块:operator.ts、validate-operator.ts、duration.ts、body.ts、text.ts、output.ts - 更新全部 checker schema/validate/expect/execute - 更新 probe-config.schema.json、probes.example.yaml - 更新 README.md、DEVELOPMENT.md(含 expect 字段选择规范) - 同步 10 个 delta specs 到主 specs,归档 change
This commit is contained in:
@@ -34,7 +34,8 @@ targets:
|
||||
url: "https://www.baidu.com"
|
||||
expect:
|
||||
status: [200]
|
||||
maxDurationMs: 5000
|
||||
durationMs:
|
||||
lte: 5000
|
||||
|
||||
- id: "httpbin-json"
|
||||
name: "${env_name} JSON API — 完整流水线"
|
||||
@@ -51,7 +52,8 @@ targets:
|
||||
headers:
|
||||
Content-Type:
|
||||
contains: "application/json"
|
||||
maxDurationMs: 8000
|
||||
durationMs:
|
||||
lte: 8000
|
||||
body:
|
||||
- json:
|
||||
path: "$.slideshow.title"
|
||||
@@ -92,7 +94,7 @@ targets:
|
||||
expect:
|
||||
exitCode: [0]
|
||||
stdout:
|
||||
- match: "^\\d+\\.\\d+\\.\\d+"
|
||||
- regex: "^\\d+\\.\\d+\\.\\d+"
|
||||
|
||||
- id: "bun-stdout-rules"
|
||||
name: "多规则 stdout 顺序校验"
|
||||
@@ -104,7 +106,7 @@ targets:
|
||||
expect:
|
||||
stdout:
|
||||
- contains: "version:"
|
||||
- match: "\\d+\\.\\d+\\.\\d+"
|
||||
- regex: "\\d+\\.\\d+\\.\\d+"
|
||||
- contains: "healthy"
|
||||
|
||||
- id: "bun-stderr"
|
||||
@@ -127,7 +129,8 @@ targets:
|
||||
db:
|
||||
url: "${sqlite_url}"
|
||||
expect:
|
||||
maxDurationMs: 1000
|
||||
durationMs:
|
||||
lte: 1000
|
||||
|
||||
- id: "sqlite-query"
|
||||
name: "SQLite 内存数据库多列结果校验"
|
||||
@@ -145,6 +148,10 @@ targets:
|
||||
exists: true
|
||||
role:
|
||||
contains: "engineer"
|
||||
result:
|
||||
- json:
|
||||
path: "$.rows[0].role"
|
||||
equals: "engineer"
|
||||
|
||||
# ========== TCP targets ==========
|
||||
|
||||
@@ -156,7 +163,8 @@ targets:
|
||||
host: "127.0.0.1"
|
||||
port: 6379
|
||||
expect:
|
||||
maxDurationMs: 3000
|
||||
durationMs:
|
||||
lte: 3000
|
||||
|
||||
- id: "smtp-banner"
|
||||
name: "SMTP Banner 探测"
|
||||
@@ -169,7 +177,7 @@ targets:
|
||||
bannerReadTimeout: 3000
|
||||
expect:
|
||||
banner:
|
||||
contains: "ESMTP"
|
||||
- contains: "ESMTP"
|
||||
|
||||
# ========== Ping targets ==========
|
||||
|
||||
@@ -183,10 +191,14 @@ targets:
|
||||
packetSize: 56
|
||||
expect:
|
||||
alive: true
|
||||
maxPacketLoss: 10
|
||||
maxAvgLatencyMs: 100
|
||||
maxMaxLatencyMs: 300
|
||||
maxDurationMs: 5000
|
||||
packetLossPercent:
|
||||
lte: 10
|
||||
avgLatencyMs:
|
||||
lte: 100
|
||||
maxLatencyMs:
|
||||
lte: 300
|
||||
durationMs:
|
||||
lte: 5000
|
||||
|
||||
# ========== UDP targets ==========
|
||||
|
||||
@@ -201,7 +213,8 @@ targets:
|
||||
expect:
|
||||
response:
|
||||
- contains: "PONG"
|
||||
maxDurationMs: 100
|
||||
durationMs:
|
||||
lte: 100
|
||||
|
||||
- id: "udp-binary-probe"
|
||||
name: "UDP 二进制协议探测"
|
||||
@@ -216,7 +229,8 @@ targets:
|
||||
expect:
|
||||
responseSize:
|
||||
gte: 4
|
||||
maxDurationMs: 200
|
||||
durationMs:
|
||||
lte: 200
|
||||
|
||||
- id: "udp-fire-and-forget"
|
||||
name: "UDP 发送验证(不等待响应)"
|
||||
@@ -242,7 +256,8 @@ targets:
|
||||
expect:
|
||||
status:
|
||||
- 200
|
||||
finishReason: "stop"
|
||||
finishReason:
|
||||
equals: "stop"
|
||||
output:
|
||||
- contains: "OK"
|
||||
|
||||
@@ -264,5 +279,7 @@ targets:
|
||||
completed: true
|
||||
firstTokenMs:
|
||||
lte: 5000
|
||||
finishReason: "stop"
|
||||
maxDurationMs: 15000
|
||||
finishReason:
|
||||
equals: "stop"
|
||||
durationMs:
|
||||
lte: 15000
|
||||
|
||||
Reference in New Issue
Block a user