@@ -14,12 +14,12 @@ import (
1414 "time"
1515
1616 model "github.com/DataDog/agent-payload/v5/process"
17+ "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/impl/common"
18+ npmodel "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/model"
1719 "github.com/DataDog/datadog-agent/pkg/networkpath/payload"
1820 "github.com/DataDog/datadog-agent/pkg/trace/teststatsd"
1921 "github.com/stretchr/testify/assert"
2022 "github.com/stretchr/testify/require"
21-
22- npmodel "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/model"
2323)
2424
2525func baselineConn (host string , bytes uint64 ) npmodel.NetworkPathConnection {
@@ -28,7 +28,7 @@ func baselineConn(host string, bytes uint64) npmodel.NetworkPathConnection {
2828 Type : model .ConnectionType_udp ,
2929 Direction : model .ConnectionDirection_outgoing ,
3030 Family : model .ConnectionFamily_v4 ,
31- Baseline : npmodel.BaselineSignals {Bytes : bytes },
31+ Baseline : npmodel.BaselineSignals {SentBytes : bytes },
3232 }
3333}
3434
@@ -93,9 +93,9 @@ func TestBaselinePrioritizesDiagnosticConnections(t *testing.T) {
9393
9494 healthyLarge := baselineConn ("10.0.0.1" , 1_000 )
9595 diagnosticSmall := baselineConn ("10.0.0.2" , 1 )
96- diagnosticSmall .Baseline .Diagnostic = true
96+ diagnosticSmall .Baseline .TimeoutCount = 1
9797 diagnosticLarge := baselineConn ("10.0.0.3" , 10 )
98- diagnosticLarge .Baseline .Diagnostic = true
98+ diagnosticLarge .Baseline .RTOCount = 1
9999
100100 collector .ScheduleNetworkPathTests (slices .Values ([]npmodel.NetworkPathConnection {
101101 healthyLarge ,
@@ -107,6 +107,31 @@ func TestBaselinePrioritizesDiagnosticConnections(t *testing.T) {
107107 assert .Equal (t , []string {"10.0.0.3" , "10.0.0.2" , "10.0.0.1" }, scheduledBaselineHosts (t , collector ))
108108}
109109
110+ func TestBaselineDiagnosticSignals (t * testing.T ) {
111+ for name , signals := range map [string ]npmodel.BaselineSignals {
112+ "timeout" : {TimeoutCount : 1 },
113+ "rto" : {RTOCount : 1 },
114+ "retransmit" : {Retransmits : 1 },
115+ } {
116+ t .Run (name , func (t * testing.T ) {
117+ selected := addBaselinePath (nil , common.Pathtest {Hostname : name }, signals )
118+
119+ require .Len (t , selected , 1 )
120+ assert .True (t , selected [0 ].diagnostic )
121+ })
122+ }
123+ }
124+
125+ func TestBaselineCombinesSentAndReceivedBytes (t * testing.T ) {
126+ selected := addBaselinePath (nil , common.Pathtest {Hostname : "host" }, npmodel.BaselineSignals {
127+ SentBytes : 5 ,
128+ RecvBytes : 6 ,
129+ })
130+
131+ require .Len (t , selected , 1 )
132+ assert .Equal (t , uint64 (11 ), selected [0 ].bytes )
133+ }
134+
110135func TestBaselineKeepsStrongestObservationPerPath (t * testing.T ) {
111136 _ , collector := newTestNpCollector (t , map [string ]any {
112137 "network_path.connections_monitoring.baseline_tests_enabled" : true ,
0 commit comments