Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Stabilize publish-path mock fixture proofs

rcourtman269f6ac8a5ff
diff --git a/internal/mock/generator.go b/internal/mock/generator.go
index a8e21183a8..808a67ca0c 100644
--- a/internal/mock/generator.go
+++ b/internal/mock/generator.go
@@ -360,6 +360,7 @@ func buildFixtureState(config MockConfig) models.StateSnapshot {
ensureMockNodeHostLinks(&data)
ensureMockKubernetesNodeHostLinks(&data)
+ ensureMockFixtureHostIORates(&data)
// Generate physical disks for each node
for _, node := range data.Nodes {
@@ -2812,6 +2813,58 @@ func syncMockKubernetesNodeHosts(data *models.StateSnapshot) {
}
}
+func ensureMockFixtureHostIORates(data *models.StateSnapshot) {
+ if data == nil {
+ return
+ }
+
+ for i := range data.Hosts {
+ host := &data.Hosts[i]
+ if strings.EqualFold(host.Status, "offline") {
+ host.NetInRate = 0
+ host.NetOutRate = 0
+ host.DiskReadRate = 0
+ host.DiskWriteRate = 0
+ continue
+ }
+ if host.NetInRate <= 0 {
+ host.NetInRate = generateMockHostRate("network-in")
+ }
+ if host.NetOutRate <= 0 {
+ host.NetOutRate = generateMockHostRate("network-out")
+ }
+ if host.DiskReadRate <= 0 {
+ host.DiskReadRate = generateMockHostRate("disk-read")
+ }
+ if host.DiskWriteRate <= 0 {
+ host.DiskWriteRate = generateMockHostRate("disk-write")
+ }
+ }
+
+ for i := range data.DockerHosts {
+ host := &data.DockerHosts[i]
+ if strings.EqualFold(host.Status, "offline") {
+ host.NetInRate = 0
+ host.NetOutRate = 0
+ host.DiskReadRate = 0
+ host.DiskWriteRate = 0
+ continue
+ }
+ if host.NetInRate <= 0 {
+ host.NetInRate = generateMockHostRate("network-in")
+ }
+ if host.NetOutRate <= 0 {
+ host.NetOutRate = generateMockHostRate("network-out")
+ }
+ if host.DiskReadRate <= 0 {
+ host.DiskReadRate = generateMockHostRate("disk-read")
+ }
+ if host.DiskWriteRate <= 0 {
+ host.DiskWriteRate = generateMockHostRate("disk-write")
+ }
+ }
+}
+
func buildMockLinkedHostFromNode(node models.Node, hostID string, hostIndex int, now time.Time) models.Host {
if hostID == "" {
hostID = fmt.Sprintf("host-node-%s", node.ID)
diff --git a/internal/monitoring/monitor_extra_coverage_test.go b/internal/monitoring/monitor_extra_coverage_test.go
index 3ac79ec538..8af36be6f5 100644
--- a/internal/monitoring/monitor_extra_coverage_test.go
+++ b/internal/monitoring/monitor_extra_coverage_test.go
@@ -21,6 +21,8 @@ import (
)
func TestMonitor_GetConnectionStatuses_MockMode_Extra(t *testing.T) {
+ setMockSamplerTestEnv(t, time.Hour, 5*time.Minute)
+
m := &Monitor{
state: models.NewState(),
alertManager: alerts.NewManager(),
@@ -140,6 +142,8 @@ func TestMonitor_Cleanup_Extra(t *testing.T) {
}
func TestMonitor_SetMockMode_Advanced_Extra(t *testing.T) {
+ setMockSamplerTestEnv(t, time.Hour, 5*time.Minute)
+
m := &Monitor{
config: &config.Config{
DiscoveryEnabled: true,