@@ -31,8 +31,13 @@ type RepeatedNetworkFlowTestSuite struct {
3131 NumIter int
3232 SleepBetweenCurlTime int
3333 SleepBetweenIterations int
34- ExpectedActive int // number of active connections expected
35- ExpectedInactive int // number of inactive connections expected
34+ // Due to connections having finite lifetimes it is possible to catch the connection
35+ // during the short time that it is active, thus we cannot in all cases be certain
36+ // of the number of active connections that are found, but we can be certain that the
37+ // number of active connections will be in a certain range.
38+ ExpectedMinActive int // minimum number of active connections expected
39+ ExpectedMaxActive int // maximum number of active connections expected
40+ ExpectedInactive int // number of inactive connections expected
3641}
3742
3843// Launches collector
@@ -111,7 +116,7 @@ func (s *RepeatedNetworkFlowTestSuite) TearDownSuite() {
111116}
112117
113118func (s * RepeatedNetworkFlowTestSuite ) TestRepeatedNetworkFlow () {
114- networkConnections := s .Sensor ().ExpectConnectionsN (s .T (), s . ServerContainer , 10 * time . Second , s . ExpectedActive + s . ExpectedInactive )
119+ networkConnections := s .Sensor ().Connections (s .ServerContainer )
115120
116121 observedActive := 0
117122 observedInactive := 0
@@ -124,7 +129,9 @@ func (s *RepeatedNetworkFlowTestSuite) TestRepeatedNetworkFlow() {
124129 }
125130 }
126131
127- assert .Equal (s .T (), s .ExpectedActive , observedActive , "Unexpected number of active connections reported" )
132+ //assert.Equal(s.T(), s.ExpectedActive, observedActive, "Unexpected number of active connections reported")
133+ assert .True (s .T (), s .ExpectedMinActive <= observedActive , "Too few active connections reported" )
134+ assert .True (s .T (), s .ExpectedMaxActive >= observedActive , "Too many active connections reported" )
128135 assert .Equal (s .T (), s .ExpectedInactive , observedInactive , "Unexpected number of inactive connections reported" )
129136
130137 // Server side checks
0 commit comments