summaryrefslogtreecommitdiff
path: root/internal/control/bootstrap_test.go
diff options
context:
space:
mode:
authorsergei <sergei@em-sysadmin.xyz>2026-04-14 06:23:55 +0400
committersergei <sergei@em-sysadmin.xyz>2026-04-14 06:23:55 +0400
commit3d51aa455006903345f554a2dd90034993796114 (patch)
tree62a7be2faf047f5eb7886feebc3b815556f03d7f /internal/control/bootstrap_test.go
downloadvpnem-main.tar.gz
vpnem-main.tar.bz2
vpnem-main.zip
vpnem: VPN infrastructure with load-balanced multi-protocol nodesHEADmain
- 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/bootstrap_test.go')
-rw-r--r--internal/control/bootstrap_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/internal/control/bootstrap_test.go b/internal/control/bootstrap_test.go
new file mode 100644
index 0000000..70e5ccb
--- /dev/null
+++ b/internal/control/bootstrap_test.go
@@ -0,0 +1,58 @@
+package control
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestRenderBootstrapScript(t *testing.T) {
+ t.Parallel()
+
+ script := RenderBootstrapPrepareScript()
+ script += RenderBootstrapFinalizeScript(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",
+ },
+ }, "20260401-123000", "/tmp/vpnem-node-nl-01.tar.gz")
+
+ if !strings.Contains(script, "mkdir -p /opt/vpnem-node/releases") {
+ t.Fatal("expected remote workdir creation")
+ }
+ if !strings.Contains(script, "vpnem-node release 20260401-123000 ready for nl-01") {
+ t.Fatal("expected release finalize message")
+ }
+}
+
+func TestSaveNodeState(t *testing.T) {
+ t.Parallel()
+
+ dir := t.TempDir()
+ err := SaveNodeState(dir, NodeState{
+ NodeID: "nl-01",
+ BootstrapStatus: "ready",
+ Services: []ServiceStatus{
+ {Type: "vless", Status: "configured", Port: 443},
+ },
+ })
+ if err != nil {
+ t.Fatalf("SaveNodeState error = %v", err)
+ }
+
+ data, err := os.ReadFile(filepath.Join(dir, "nl-01.json"))
+ if err != nil {
+ t.Fatalf("ReadFile error = %v", err)
+ }
+ if !strings.Contains(string(data), `"bootstrap_status": "ready"`) {
+ t.Fatal("expected bootstrap_status in state file")
+ }
+}