Add fleet ops dashboard, Calibrate enforcement, and dead-code cleanup.
Ship live alerts, pool status, AI monitor, remote agent commands, build manager, and uninstall flow; wire Calibrate settings (WS ping, pool traffic log, retention limits) at runtime and exclude server/data from git.
This commit is contained in:
40
server/internal/alerts/evaluator_test.go
Normal file
40
server/internal/alerts/evaluator_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package alerts
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"crypto-miner-server/internal/models"
|
||||
)
|
||||
|
||||
func TestFormatPct(t *testing.T) {
|
||||
if formatPct(50.55) != "50.5" {
|
||||
t.Fatalf("expected 50.5 got %s", formatPct(50.55))
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluatorOfflineAlert(t *testing.T) {
|
||||
var fired []AlertEvent
|
||||
e := &Evaluator{
|
||||
thresholds: func() Thresholds { return Thresholds{OfflineMinutes: 5} },
|
||||
broadcast: func(ev AlertEvent) { fired = append(fired, ev) },
|
||||
baseline: make(map[string]float64),
|
||||
lastFired: make(map[string]time.Time),
|
||||
cooldown: 0,
|
||||
}
|
||||
|
||||
agent := &models.Agent{
|
||||
ID: "a1",
|
||||
Name: "worker-1",
|
||||
Status: "offline",
|
||||
LastSeen: time.Now().Add(-10 * time.Minute),
|
||||
}
|
||||
|
||||
e.checkOffline(agent, e.thresholds(), time.Now())
|
||||
if len(fired) != 1 {
|
||||
t.Fatalf("expected 1 alert, got %d", len(fired))
|
||||
}
|
||||
if fired[0].Type != "offline" {
|
||||
t.Fatalf("expected offline alert")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user