feat: M3 cluster page (LB groups + health check status) e2e-verified failover; M6 cache API + version path hardening + frontend cluster methods

This commit is contained in:
2026-08-17 22:44:04 +08:00
parent a842198447
commit 5bd70b90c0
11 changed files with 470 additions and 128 deletions

View File

@ -120,3 +120,35 @@ func TestRegisterAndDiscover(t *testing.T) {
t.Fatalf("node list = %+v", got)
}
}
func TestCacheInfoAndPrune(t *testing.T) {
dir := t.TempDir()
writeFakeFrpc(t, dir, "0.70.0")
writeFakeFrpc(t, dir, "0.71.0")
reg := NewRegistry(dir)
infos := reg.CacheInfo()
if len(infos) != 2 {
t.Fatalf("cache info = %+v", infos)
}
// prune keep=1 -> removes oldest by modtime (0.70.0 likely older)
removed := reg.PruneCache(1)
_ = removed
if len(reg.CacheInfo()) != 1 {
t.Fatalf("after prune keep=1: %+v", reg.CacheInfo())
}
}
func TestPathSafeVersion(t *testing.T) {
good := []string{"0.71.0", "v0.71.0", "1.2.3-beta", "0.71.0-rc1_amd64"}
for _, v := range good {
if _, ok := pathSafeVersion(v); !ok {
t.Fatalf("expected safe: %q", v)
}
}
bad := []string{"", "../evil", "a/b", "..", `x\y`, "0.7 1.0"}
for _, v := range bad {
if _, ok := pathSafeVersion(v); ok {
t.Fatalf("expected unsafe: %q", v)
}
}
}