mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-07-10 00:14:38 +00:00
test: add regression tests for missing frontend fields
Ensures that LinkedHostAgentId, CommandsEnabled, IsLegacy, and LinkedNodeId are correctly propagated to the frontend. This prevents regressions of the bugs fixed for #952 and #971.
This commit is contained in:
parent
a0e5f22983
commit
4cd3e53c3e
3 changed files with 27 additions and 11 deletions
|
|
@ -114,14 +114,15 @@ func TestNodeToFrontend(t *testing.T) {
|
|||
Total: 500000000000,
|
||||
Used: 250000000000,
|
||||
},
|
||||
Uptime: 86400,
|
||||
LoadAverage: []float64{0.5, 0.7, 0.9},
|
||||
KernelVersion: "5.15.0",
|
||||
PVEVersion: "7.4-3",
|
||||
LastSeen: now,
|
||||
ConnectionHealth: "connected",
|
||||
IsClusterMember: true,
|
||||
ClusterName: "pve-cluster",
|
||||
Uptime: 86400,
|
||||
LoadAverage: []float64{0.5, 0.7, 0.9},
|
||||
KernelVersion: "5.15.0",
|
||||
PVEVersion: "7.4-3",
|
||||
LastSeen: now,
|
||||
ConnectionHealth: "connected",
|
||||
IsClusterMember: true,
|
||||
ClusterName: "pve-cluster",
|
||||
LinkedHostAgentID: "agent-123",
|
||||
}
|
||||
|
||||
frontend := node.ToFrontend()
|
||||
|
|
@ -159,6 +160,9 @@ func TestNodeToFrontend(t *testing.T) {
|
|||
if len(frontend.LoadAverage) != 3 {
|
||||
t.Errorf("LoadAverage length = %d, want 3", len(frontend.LoadAverage))
|
||||
}
|
||||
if frontend.LinkedHostAgentId != node.LinkedHostAgentID {
|
||||
t.Errorf("LinkedHostAgentId = %q, want %q", frontend.LinkedHostAgentId, node.LinkedHostAgentID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeToFrontend_EmptyDisplayName(t *testing.T) {
|
||||
|
|
@ -1076,6 +1080,9 @@ func TestHostToFrontend(t *testing.T) {
|
|||
Sensors: HostSensorSummary{
|
||||
TemperatureCelsius: map[string]float64{"cpu": 55.0},
|
||||
},
|
||||
CommandsEnabled: true,
|
||||
IsLegacy: false,
|
||||
LinkedNodeID: "node-abc",
|
||||
}
|
||||
|
||||
frontend := host.ToFrontend()
|
||||
|
|
@ -1119,6 +1126,15 @@ func TestHostToFrontend(t *testing.T) {
|
|||
if frontend.Sensors == nil {
|
||||
t.Error("Sensors should not be nil")
|
||||
}
|
||||
if frontend.CommandsEnabled != host.CommandsEnabled {
|
||||
t.Errorf("CommandsEnabled = %v, want %v", frontend.CommandsEnabled, host.CommandsEnabled)
|
||||
}
|
||||
if frontend.IsLegacy != host.IsLegacy {
|
||||
t.Errorf("IsLegacy = %v, want %v", frontend.IsLegacy, host.IsLegacy)
|
||||
}
|
||||
if frontend.LinkedNodeId != host.LinkedNodeID {
|
||||
t.Errorf("LinkedNodeId = %q, want %q", frontend.LinkedNodeId, host.LinkedNodeID)
|
||||
}
|
||||
if frontend.TokenLastUsedAt == nil || *frontend.TokenLastUsedAt != tokenLastUsed.Unix()*1000 {
|
||||
t.Errorf("TokenLastUsedAt = %v, want %d", frontend.TokenLastUsedAt, tokenLastUsed.Unix()*1000)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ func TestSanitizeEndpointError(t *testing.T) {
|
|||
{"context deadline basic", "context deadline exceeded", "Request timed out - Proxmox API may be slow or waiting on unreachable backend services"},
|
||||
{"context deadline storage", "Get /api2/json/nodes/delly/storage: context deadline exceeded", "Request timed out - storage API slow (check for unreachable PBS/NFS/Ceph backends)"},
|
||||
{"context deadline pbs", "pbs-backup context deadline exceeded", "Request timed out - PBS storage backend unreachable"},
|
||||
{"context deadline port 8007", "Can't connect to verdeclose:8007 context deadline exceeded", "Request timed out - PBS storage backend unreachable"},
|
||||
{"context deadline port 8007", "Can't connect to tower:8007 context deadline exceeded", "Request timed out - PBS storage backend unreachable"},
|
||||
// Client timeout
|
||||
{"client timeout", "Client.Timeout exceeded while awaiting headers", "Connection timed out - Proxmox API not responding in time"},
|
||||
// Connection refused
|
||||
|
|
@ -281,7 +281,7 @@ func TestSanitizeEndpointError(t *testing.T) {
|
|||
{"403 error", "status 403: Forbidden", "Authentication failed - check API token or credentials"},
|
||||
{"authentication keyword", "authentication failed: invalid token", "Authentication failed - check API token or credentials"},
|
||||
// PBS specific
|
||||
{"pbs connect error", "Can't connect to verdeclose:8007 (Connection timed out)", "PBS storage unreachable - check Proxmox Backup Server connectivity"},
|
||||
{"pbs connect error", "Can't connect to tower:8007 (Connection timed out)", "PBS storage unreachable - check Proxmox Backup Server connectivity"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|||
DEPLOY_SCRIPT="$SCRIPT_DIR/dev-deploy-agent.sh"
|
||||
|
||||
# Hosts to sync to (edit this list as needed)
|
||||
HOSTS=("verdeclose" "minipc" "delly" "pimox")
|
||||
HOSTS=("tower")
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue