mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-13 00:49:07 +02:00
update some tests
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
nblog "github.com/netbirdio/netbird/client/firewall/uspfilter/log"
|
||||
nftypes "github.com/netbirdio/netbird/client/internal/netflow/types"
|
||||
@@ -220,10 +219,8 @@ func (t *UDPTracker) sendEvent(typ nftypes.Type, conn *UDPConnTrack, ruleID []by
|
||||
})
|
||||
}
|
||||
|
||||
func (t *UDPTracker) getConnections() map[ConnKey]*UDPConnTrack {
|
||||
func (t *UDPTracker) getConnectionsLen() int {
|
||||
t.mutex.RLock()
|
||||
defer t.mutex.RUnlock()
|
||||
copyConn := make(map[ConnKey]*UDPConnTrack, len(t.connections))
|
||||
maps.Copy(copyConn, t.connections)
|
||||
return copyConn
|
||||
return len(t.connections)
|
||||
}
|
||||
|
||||
@@ -202,13 +202,13 @@ func TestUDPTracker_Cleanup(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify initial connections
|
||||
assert.Len(t, tracker.getConnections(), 2)
|
||||
assert.Equal(t, 2, tracker.getConnectionsLen())
|
||||
|
||||
// Wait for connection timeout and cleanup interval
|
||||
time.Sleep(timeout + 2*cleanupInterval)
|
||||
|
||||
tracker.mutex.RLock()
|
||||
connCount := len(tracker.getConnections())
|
||||
connCount := tracker.getConnectionsLen()
|
||||
tracker.mutex.RUnlock()
|
||||
|
||||
// Verify connections were cleaned up
|
||||
|
||||
Reference in New Issue
Block a user