test: capture ordering regressions and enforce deploy resources
This commit is contained in:
@@ -48,6 +48,24 @@ func TestDeliveryRecorderSeparatesHistoryFromRealtime(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeliveryRecorderCapturesOrderingViolationDetails(t *testing.T) {
|
||||
recorder := newDeliveryRecorder("run1", "b", 1)
|
||||
newer := AcceptedMessage{RunID: "run1", ClientMid: "run1-p-a-0001-02", Topic: "p2p-one", Seq: 12}
|
||||
older := AcceptedMessage{RunID: "run1", ClientMid: "run1-p-a-0001-01", Topic: "p2p-one", Seq: 11}
|
||||
recorder.onData(AccountRecord{Index: 1}, testData(newer, time.Now()))
|
||||
recorder.onData(AccountRecord{Index: 1}, testData(older, time.Now()))
|
||||
|
||||
summary := recorder.summarize(AgentSummary{}, nil)
|
||||
if summary.OutOfOrder != 1 || len(summary.OrderingViolations) != 1 {
|
||||
t.Fatalf("out_of_order=%d violations=%+v", summary.OutOfOrder, summary.OrderingViolations)
|
||||
}
|
||||
violation := summary.OrderingViolations[0]
|
||||
if violation.ReceiverMachine != "b" || violation.ReceiverIndex != 1 ||
|
||||
violation.PreviousSeq != 12 || violation.CurrentSeq != 11 || violation.ClientMid != older.ClientMid {
|
||||
t.Fatalf("unexpected violation: %+v", violation)
|
||||
}
|
||||
}
|
||||
|
||||
func testData(message AcceptedMessage, sentAt time.Time) dataPacket {
|
||||
content, _ := json.Marshal(map[string]any{"run_id": message.RunID, "sent_at_unix_nano": sentAt.UnixNano()})
|
||||
return dataPacket{Topic: message.Topic, Seq: message.Seq,
|
||||
|
||||
Reference in New Issue
Block a user