@@ -57,6 +57,12 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
5757 EndpointID : 2 , InstanceID : "b" , RecordTime : hourStart .Add (59 * time .Minute ).UTC (),
5858 DeltaTCPIn : 30 , DeltaTCPOut : 1_200_000_000 ,
5959 },
60+ {
61+ // Duplicate latest timestamps are possible when an SSE event is
62+ // dispatched more than once. The higher ID must win deterministically.
63+ EndpointID : 1 , InstanceID : "a" , RecordTime : hourStart .Add (59 * time .Minute ).UTC (),
64+ DeltaTCPIn : 25 , DeltaTCPOut : 2_900_000_000 ,
65+ },
6066 }
6167 if err := db .Create (& history ).Error ; err != nil {
6268 t .Fatalf ("insert service history: %v" , err )
@@ -81,8 +87,8 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
8187 if ! summary .HourTime .Equal (hourStart .UTC ()) {
8288 t .Fatalf ("hour time = %s, want %s" , summary .HourTime , hourStart .UTC ())
8389 }
84- if summary .TCPTxTotal != 4_000_000_000 {
85- t .Fatalf ("tcp tx total = %d, want 4000000000 " , summary .TCPTxTotal )
90+ if summary .TCPTxTotal != 4_100_000_000 {
91+ t .Fatalf ("tcp tx total = %d, want 4100000000 " , summary .TCPTxTotal )
8692 }
8793 if summary .InstanceCount != 2 {
8894 t .Fatalf ("instance count = %d, want 2" , summary .InstanceCount )
@@ -92,8 +98,8 @@ func TestAggregateTrafficDataForHourNormalizesUTCAndKeepsInt64(t *testing.T) {
9298 if err := db .Where ("instance_id = ?" , "a" ).First (& instanceA ).Error ; err != nil {
9399 t .Fatalf ("load instance a summary: %v" , err )
94100 }
95- if instanceA .TCPTxIncrement != 300_000_000 {
96- t .Fatalf ("tcp tx increment = %d, want 300000000 " , instanceA .TCPTxIncrement )
101+ if instanceA .TCPTxIncrement != 400_000_000 {
102+ t .Fatalf ("tcp tx increment = %d, want 400000000 " , instanceA .TCPTxIncrement )
97103 }
98104}
99105
0 commit comments