test: stabilize distributed load verification

This commit is contained in:
richjohnrambo
2026-09-28 09:50:33 +08:00
parent d3c679878d
commit a974572f72
12 changed files with 344 additions and 46 deletions
+11
View File
@@ -100,6 +100,16 @@ func TestCoordinatorClientWaitsForBothAgentsAndMergesLedger(t *testing.T) {
if err != nil || len(observed) != 1 || observed[0].ClientMid != "unknown" {
t.Fatalf("observed=%+v err=%v", observed, err)
}
if err = client.submitHistory(context.Background(), "a", []string{"mid-2", "mid-1"}); err != nil {
t.Fatal(err)
}
if err = client.submitHistory(context.Background(), "b", []string{"mid-2", "mid-3"}); err != nil {
t.Fatal(err)
}
history, err := client.history(context.Background())
if err != nil || len(history) != 3 || history[0] != "mid-1" || history[1] != "mid-2" || history[2] != "mid-3" {
t.Fatalf("history=%+v err=%v", history, err)
}
}
func testCoordinatorMux(state *coordinatorState) *http.ServeMux {
@@ -108,6 +118,7 @@ func testCoordinatorMux(state *coordinatorState) *http.ServeMux {
mux.HandleFunc("/v1/start", state.handleStart)
mux.HandleFunc("/v1/ledger", state.handleLedger)
mux.HandleFunc("/v1/observed", state.handleObserved)
mux.HandleFunc("/v1/history", state.handleHistory)
mux.HandleFunc("/v1/summary", state.handleSummary)
mux.HandleFunc("/v1/status", state.handleStatus)
return mux