From 3d51aa455006903345f554a2dd90034993796114 Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 14 Apr 2026 06:23:55 +0400 Subject: vpnem: VPN infrastructure with load-balanced multi-protocol nodes - 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 --- internal/control/upgrade_test.go | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 internal/control/upgrade_test.go (limited to 'internal/control/upgrade_test.go') diff --git a/internal/control/upgrade_test.go b/internal/control/upgrade_test.go new file mode 100644 index 0000000..c3e5404 --- /dev/null +++ b/internal/control/upgrade_test.go @@ -0,0 +1,55 @@ +package control + +import ( + "context" + "strings" + "testing" +) + +type fakeRunner struct{} + +func (fakeRunner) Run(ctx context.Context, node Node, script string) (*CommandResult, error) { + if strings.Contains(script, "HEALTHZ_HTTP_CODE=") { + return &CommandResult{ + Stdout: "{\"Service\":\"sing-box\",\"Status\":\"running\"}\nHEALTHZ_HTTP_CODE=200\n", + }, nil + } + return &CommandResult{Stdout: "ok\n"}, nil +} + +func (fakeRunner) Check(ctx context.Context, node Node) (*CommandResult, error) { + return &CommandResult{Stdout: "ok"}, nil +} + +func (fakeRunner) CopyFile(ctx context.Context, node Node, localPath, remotePath string) error { + return nil +} + +func TestUpgradeNode(t *testing.T) { + t.Parallel() + + state, err := UpgradeNode(context.Background(), fakeRunner{}, Node{ + ID: "nl-01", + Name: "NL 01", + Region: "nl", + Host: "203.0.113.10", + Domain: "nl-01.example.com", + Enabled: true, + SSH: SSHConfig{User: "root", Port: 22, Auth: "key", IdentityFile: "~/.ssh/id_ed25519"}, + Protocols: []ProtocolProfile{ + {Type: "vless", Enabled: true, Port: 443, TLS: &TLSProfile{Enabled: true, ServerName: "nl-01.example.com"}, Auth: &AuthProfile{UUID: "11111111-1111-1111-1111-111111111111"}, Extra: map[string]any{"path": "/ws"}}, + }, + }, t.TempDir()) + if err != nil { + t.Fatalf("UpgradeNode() error = %v", err) + } + if state == nil { + t.Fatal("expected state") + } + if state.BootstrapStatus != "healthy" { + t.Fatalf("BootstrapStatus = %q, want healthy", state.BootstrapStatus) + } + if got := state.Metadata["lifecycle_action"]; got != "upgrade" { + t.Fatalf("lifecycle_action = %v, want upgrade", got) + } +} -- cgit v1.2.3