fix: stabilize flaky server API and spread gate tests
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

Serialize agent WebSocket writes (ping + JSON), mutex-protect spreadGateClock,
and harden deploy-plan spread route hint setup under parallel test runs.
This commit is contained in:
AetherForge
2026-06-07 05:23:28 -07:00
parent 499d6cd8d3
commit ed9c90a420
5 changed files with 64 additions and 13 deletions

View File

@@ -92,6 +92,25 @@ func testAgentClientIP(agentID string) string {
return fmt.Sprintf("10.42.%d.%d", (sum%250)+1, ((sum/250)%250)+1)
}
func waitForHubAgents(t *testing.T, hub *WSHub, agentIDs ...string) {
t.Helper()
deadline := time.Now().Add(3 * time.Second)
for time.Now().Before(deadline) {
allConnected := true
for _, id := range agentIDs {
if !hub.isAgentConnected(id) {
allConnected = false
break
}
}
if allConnected {
return
}
time.Sleep(10 * time.Millisecond)
}
t.Fatalf("agents not connected: %v", agentIDs)
}
func connectTestAgent(t *testing.T, hub *WSHub, agentID string) *websocket.Conn {
t.Helper()
srv := httptest.NewServer(http.HandlerFunc(hub.HandleAgentWS))