@@ -109,7 +109,7 @@ func (s *TracerSuite) TestTCPRemoveEntries() {
109
109
defer c2 .Close ()
110
110
111
111
assert .EventuallyWithT (t , func (ct * assert.CollectT ) {
112
- conn , ok := findConnection (c2 .LocalAddr (), c2 .RemoteAddr (), getConnections (t , tr ))
112
+ conn , ok := findConnection (c2 .LocalAddr (), c2 .RemoteAddr (), getConnections (ct , tr ))
113
113
if ! assert .True (ct , ok ) {
114
114
return
115
115
}
@@ -123,9 +123,9 @@ func (s *TracerSuite) TestTCPRemoveEntries() {
123
123
}, 3 * time .Second , 100 * time .Millisecond )
124
124
125
125
// Make sure the first connection got cleaned up
126
- assert .Eventually (t , func () bool {
127
- _ , ok := findConnection (c .LocalAddr (), c .RemoteAddr (), getConnections (t , tr ))
128
- return ! ok
126
+ assert .EventuallyWithT (t , func (ct * assert. CollectT ) {
127
+ _ , ok := findConnection (c .LocalAddr (), c .RemoteAddr (), getConnections (ct , tr ))
128
+ require . False ( ct , ok )
129
129
}, 5 * time .Second , 100 * time .Millisecond )
130
130
131
131
}
@@ -735,10 +735,10 @@ func (s *TracerSuite) TestGatewayLookupEnabled() {
735
735
dnsServerAddr := & net.UDPAddr {IP : dnsAddr , Port : 53 }
736
736
737
737
var conn * network.ConnectionStats
738
- require .Eventually (t , func () bool {
738
+ require .EventuallyWithT (t , func (ct * assert. CollectT ) {
739
739
var ok bool
740
- conn , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (t , tr ))
741
- return ok
740
+ conn , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (ct , tr ))
741
+ require . True ( ct , ok , "connection not found" )
742
742
}, 3 * time .Second , 100 * time .Millisecond )
743
743
744
744
require .NotNil (t , conn .Via , "connection is missing via: %s" , conn )
@@ -791,10 +791,10 @@ func (s *TracerSuite) TestGatewayLookupSubnetLookupError() {
791
791
dnsClientAddr := & net.UDPAddr {IP : net .ParseIP (clientIP ), Port : clientPort }
792
792
dnsServerAddr := & net.UDPAddr {IP : destAddr , Port : 53 }
793
793
var c * network.ConnectionStats
794
- require .Eventually (t , func () bool {
794
+ require .EventuallyWithT (t , func (ct * assert. CollectT ) {
795
795
var ok bool
796
- c , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (t , tr ))
797
- return ok
796
+ c , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (ct , tr ))
797
+ require . True ( ct , ok , "connection not found" )
798
798
}, 3 * time .Second , 100 * time .Millisecond , "connection not found" )
799
799
require .Nil (t , c .Via )
800
800
@@ -804,10 +804,10 @@ func (s *TracerSuite) TestGatewayLookupSubnetLookupError() {
804
804
}, 6 * time .Second , 100 * time .Millisecond , "failed to send dns query" )
805
805
806
806
dnsClientAddr = & net.UDPAddr {IP : net .ParseIP (clientIP ), Port : clientPort }
807
- require .Eventually (t , func () bool {
807
+ require .EventuallyWithT (t , func (ct * assert. CollectT ) {
808
808
var ok bool
809
- c , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (t , tr ))
810
- return ok
809
+ c , ok = findConnection (dnsClientAddr , dnsServerAddr , getConnections (ct , tr ))
810
+ require . True ( ct , ok , "connection not found" )
811
811
}, 3 * time .Second , 100 * time .Millisecond , "connection not found" )
812
812
require .Nil (t , c .Via )
813
813
@@ -1529,25 +1529,25 @@ func testUDPReusePort(t *testing.T, udpnet string, ip string) {
1529
1529
1530
1530
assert .EventuallyWithT (t , func (ct * assert.CollectT ) { //nolint:revive // TODO
1531
1531
// use t instead of ct because getConnections uses require (not assert), and we get a better error message that way
1532
- connections := getConnections (t , tr )
1532
+ connections := getConnections (ct , tr )
1533
1533
1534
1534
incoming , ok := findConnection (c .RemoteAddr (), c .LocalAddr (), connections )
1535
- if assert .True (t , ok , "unable to find incoming connection" ) {
1536
- assert .Equal (t , network .INCOMING , incoming .Direction )
1535
+ if assert .True (ct , ok , "unable to find incoming connection" ) {
1536
+ assert .Equal (ct , network .INCOMING , incoming .Direction )
1537
1537
1538
1538
// make sure the inverse values are seen for the other message
1539
- assert .Equal (t , serverMessageSize , int (incoming .Monotonic .SentBytes ), "incoming sent" )
1540
- assert .Equal (t , clientMessageSize , int (incoming .Monotonic .RecvBytes ), "incoming recv" )
1541
- assert .True (t , incoming .IntraHost , "incoming intrahost" )
1539
+ assert .Equal (ct , serverMessageSize , int (incoming .Monotonic .SentBytes ), "incoming sent" )
1540
+ assert .Equal (ct , clientMessageSize , int (incoming .Monotonic .RecvBytes ), "incoming recv" )
1541
+ assert .True (ct , incoming .IntraHost , "incoming intrahost" )
1542
1542
}
1543
1543
1544
1544
outgoing , ok := findConnection (c .LocalAddr (), c .RemoteAddr (), connections )
1545
- if assert .True (t , ok , "unable to find outgoing connection" ) {
1546
- assert .Equal (t , network .OUTGOING , outgoing .Direction )
1545
+ if assert .True (ct , ok , "unable to find outgoing connection" ) {
1546
+ assert .Equal (ct , network .OUTGOING , outgoing .Direction )
1547
1547
1548
- assert .Equal (t , clientMessageSize , int (outgoing .Monotonic .SentBytes ), "outgoing sent" )
1549
- assert .Equal (t , serverMessageSize , int (outgoing .Monotonic .RecvBytes ), "outgoing recv" )
1550
- assert .True (t , outgoing .IntraHost , "outgoing intrahost" )
1548
+ assert .Equal (ct , clientMessageSize , int (outgoing .Monotonic .SentBytes ), "outgoing sent" )
1549
+ assert .Equal (ct , serverMessageSize , int (outgoing .Monotonic .RecvBytes ), "outgoing recv" )
1550
+ assert .True (ct , outgoing .IntraHost , "outgoing intrahost" )
1551
1551
}
1552
1552
}, 3 * time .Second , 100 * time .Millisecond )
1553
1553
@@ -1660,16 +1660,17 @@ func (s *TracerSuite) TestSendfileRegression() {
1660
1660
1661
1661
t .Logf ("looking for connections %+v <-> %+v" , c .LocalAddr (), c .RemoteAddr ())
1662
1662
var outConn , inConn * network.ConnectionStats
1663
- assert .Eventually (t , func () bool {
1664
- conns := getConnections (t , tr )
1663
+ assert .EventuallyWithT (t , func (ct * assert. CollectT ) {
1664
+ conns := getConnections (ct , tr )
1665
1665
t .Log (conns )
1666
1666
if outConn == nil {
1667
1667
outConn = network .FirstConnection (conns , network .ByType (connType ), network .ByFamily (family ), network .ByTuple (c .LocalAddr (), c .RemoteAddr ()))
1668
1668
}
1669
1669
if inConn == nil {
1670
1670
inConn = network .FirstConnection (conns , network .ByType (connType ), network .ByFamily (family ), network .ByTuple (c .RemoteAddr (), c .LocalAddr ()))
1671
1671
}
1672
- return outConn != nil && inConn != nil
1672
+ require .NotNil (ct , outConn )
1673
+ require .NotNil (ct , inConn )
1673
1674
}, 3 * time .Second , 100 * time .Millisecond , "couldn't find connections used by sendfile(2)" )
1674
1675
1675
1676
if assert .NotNil (t , outConn , "couldn't find outgoing connection used by sendfile(2)" ) {
@@ -2433,7 +2434,7 @@ LOOP:
2433
2434
2434
2435
require .NoError (t , c .Close (), "error closing client connection" )
2435
2436
require .EventuallyWithT (t , func (collect * assert.CollectT ) {
2436
- conn , found := findConnection (c .LocalAddr (), srv .Addr (), getConnections (t , tr ))
2437
+ conn , found := findConnection (c .LocalAddr (), srv .Addr (), getConnections (collect , tr ))
2437
2438
require .True (collect , found , "could not find connection" )
2438
2439
require .True (collect , conn .IsClosed , "connection should be closed" )
2439
2440
// after closing the client connection, the duration should be
0 commit comments