test: report exact ACK latency percentiles
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRunMergeComputesArrivalAndPersistenceGate(t *testing.T) {
|
||||
@@ -53,6 +54,32 @@ func TestMergedHistogramP95(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergedAckP95UsesExactAcceptedTimestamps(t *testing.T) {
|
||||
base := time.Date(2026, 9, 27, 8, 0, 0, 0, time.UTC)
|
||||
agents := []AgentSummary{{
|
||||
AckLatency: HistogramSnapshot{Count: 4, MaxMS: 900, Buckets: map[string]int64{"1s": 4}},
|
||||
AcceptedLocal: []AcceptedMessage{
|
||||
{SentAt: base, AckAt: base.Add(100 * time.Millisecond)},
|
||||
{SentAt: base, AckAt: base.Add(200 * time.Millisecond)},
|
||||
{SentAt: base, AckAt: base.Add(300 * time.Millisecond)},
|
||||
{SentAt: base, AckAt: base.Add(400 * time.Millisecond)},
|
||||
},
|
||||
}}
|
||||
if got := mergedAckP95(agents); got != 400 {
|
||||
t.Fatalf("exact p95=%v want=400", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergedAckP95FallsBackWhenRawSamplesAreIncomplete(t *testing.T) {
|
||||
agents := []AgentSummary{{
|
||||
AckLatency: HistogramSnapshot{Count: 2, MaxMS: 900, Buckets: map[string]int64{"1s": 2}},
|
||||
AcceptedLocal: []AcceptedMessage{{SentAt: time.Now(), AckAt: time.Now().Add(100 * time.Millisecond)}},
|
||||
}}
|
||||
if got := mergedAckP95(agents); got != 1000 {
|
||||
t.Fatalf("fallback p95=%v want=1000", got)
|
||||
}
|
||||
}
|
||||
|
||||
func writeSummaryForTest(t *testing.T, path string, summary AgentSummary) {
|
||||
t.Helper()
|
||||
raw, err := json.Marshal(summary)
|
||||
|
||||
Reference in New Issue
Block a user