diff options
| author | sergei <sergei@em-sysadmin.xyz> | 2026-04-14 06:23:55 +0400 |
|---|---|---|
| committer | sergei <sergei@em-sysadmin.xyz> | 2026-04-14 06:23:55 +0400 |
| commit | 3d51aa455006903345f554a2dd90034993796114 (patch) | |
| tree | 62a7be2faf047f5eb7886feebc3b815556f03d7f /internal/control/health_test.go | |
| download | vpnem-main.tar.gz vpnem-main.tar.bz2 vpnem-main.zip | |
- Multi-protocol VPS nodes (VLESS-REALITY + Hysteria2 + SOCKS5)
- Smart load balancing via recommendation API
- Windows/Linux client (Go + Wails + sing-box)
- Server API with RealIP detection and connection tracking
- Auto-deployment via vpnui control plane
- Silent Windows installer with UAC elevation
- Load-based server recommendation (no sticky sessions)
- Best Server one-click connection workflow
Diffstat (limited to 'internal/control/health_test.go')
| -rw-r--r-- | internal/control/health_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/control/health_test.go b/internal/control/health_test.go new file mode 100644 index 0000000..a0f488f --- /dev/null +++ b/internal/control/health_test.go @@ -0,0 +1,49 @@ +package control + +import "testing" + +func TestParseHealthCheckOutput(t *testing.T) { + t.Parallel() + + stdout := `{"Service":"sing-box","State":"running"} +{"Service":"caddy","State":"running"} +HEALTHZ_HTTP_CODE=200 +` + services, metadata := parseHealthCheckOutput(stdout, []ProtocolProfile{ + {Type: "vless", Enabled: true, Port: 443}, + {Type: "vmess", Enabled: true, Port: 443}, + {Type: "shadowsocks", Enabled: true, Port: 8443}, + }) + + if len(services) != 3 { + t.Fatalf("len(services) = %d, want 3", len(services)) + } + if metadata["healthz_http_code"] != 200 { + t.Fatalf("healthz_http_code = %v, want 200", metadata["healthz_http_code"]) + } + if services[0].Status != "running" && services[1].Status != "running" && services[2].Status != "running" { + t.Fatal("expected at least one service marked running") + } +} + +func TestParseHealthCheckOutputDockerPSFallback(t *testing.T) { + t.Parallel() + + stdout := `{"Names":"current_sing-box_1","Labels":"com.docker.compose.service=sing-box,com.docker.compose.project=current","State":"running","Status":"Up 52 seconds"} +HY2_MIXED_PORT=5.180.97.199 +` + services, _ := parseHealthCheckOutput(stdout, []ProtocolProfile{ + {Type: "vless-reality", Enabled: true, Port: 443}, + {Type: "hysteria2", Enabled: true, Port: 443}, + }) + + if len(services) != 2 { + t.Fatalf("len(services) = %d, want 2", len(services)) + } + if services[0].Status != "running" { + t.Fatalf("vless-reality status = %q, want running", services[0].Status) + } + if services[1].Status != "running" { + t.Fatalf("hysteria2 status = %q, want running", services[1].Status) + } +} |
