1
0

refactor: ICMP checker type 从 ping 统一改为 icmp,修复前端 UI 细节

- ICMP checker 的 type/configKey/YAML 配置键/接口属性名从 ping 改为 icmp
- IcmpChecker 添加 platform 构造函数注入,修复 Windows 测试兼容性
- 前端 target 表格延迟列优化:标题简化为「延迟」,单位下移到单元格,宽度 80px
- Drawer 概览页 Descriptions 添加 tableLayout=auto 收窄 label 宽度
- 同步更新 README.md、DEVELOPMENT.md、probes.example.yaml、JSON Schema 和全部测试
This commit is contained in:
2026-05-20 00:02:23 +08:00
parent 375dd3492b
commit 9b53c746f6
23 changed files with 239 additions and 224 deletions

View File

@@ -2009,14 +2009,14 @@ targets:
expect(t.expect?.durationMs).toEqual({ lte: 5000 });
});
test("解析最简 ping 配置", async () => {
const configPath = join(tempDir, "minimal-ping.yaml");
test("解析最简 icmp 配置", async () => {
const configPath = join(tempDir, "minimal-icmp.yaml");
await writeFile(
configPath,
`targets:
- id: "gateway"
type: ping
ping:
type: icmp
icmp:
host: "10.0.0.1"
`,
);
@@ -2024,21 +2024,21 @@ targets:
const config = await loadConfig(configPath);
expect(config.targets).toHaveLength(1);
const t = config.targets[0]! as ResolvedPingTarget;
expect(t.type).toBe("ping");
expect(t.ping).toEqual({ count: 3, host: "10.0.0.1", packetSize: 56 });
expect(t.type).toBe("icmp");
expect(t.icmp).toEqual({ count: 3, host: "10.0.0.1", packetSize: 56 });
expect(t.group).toBe("default");
expect(t.intervalMs).toBe(30000);
expect(t.timeoutMs).toBe(10000);
});
test("解析 ping expect 配置", async () => {
const configPath = join(tempDir, "ping-expect.yaml");
test("解析 icmp expect 配置", async () => {
const configPath = join(tempDir, "icmp-expect.yaml");
await writeFile(
configPath,
`targets:
- id: "gateway"
type: ping
ping:
type: icmp
icmp:
host: "10.0.0.1"
count: 5
packetSize: 1472
@@ -2057,7 +2057,7 @@ targets:
const config = await loadConfig(configPath);
const t = config.targets[0]! as ResolvedPingTarget;
expect(t.ping).toEqual({ count: 5, host: "10.0.0.1", packetSize: 1472 });
expect(t.icmp).toEqual({ count: 5, host: "10.0.0.1", packetSize: 1472 });
expect(t.expect).toEqual({
alive: true,
avgLatencyMs: { lte: 200 },
@@ -2067,39 +2067,39 @@ targets:
});
});
test("ping 缺少 host 抛出错误", async () => {
test("icmp 缺少 host 抛出错误", async () => {
await expectConfigError(
"ping-no-host.yaml",
"icmp-no-host.yaml",
`targets:
- id: "gateway"
type: ping
ping: {}
type: icmp
icmp: {}
`,
"ping.host",
"icmp.host",
);
});
test("ping count 非法抛出错误", async () => {
test("icmp count 非法抛出错误", async () => {
await expectConfigError(
"ping-bad-count.yaml",
"icmp-bad-count.yaml",
`targets:
- id: "gateway"
type: ping
ping:
type: icmp
icmp:
host: "10.0.0.1"
count: 0
`,
"ping.count",
"icmp.count",
);
});
test("ping expect 未知字段抛出错误", async () => {
test("icmp expect 未知字段抛出错误", async () => {
await expectConfigError(
"ping-unknown-expect.yaml",
"icmp-unknown-expect.yaml",
`targets:
- id: "gateway"
type: ping
ping:
type: icmp
icmp:
host: "10.0.0.1"
expect:
status: [200]