add race flag to client tests

using for now a temp fixed for ice
This commit is contained in:
Maycon Santos
2025-07-18 19:12:44 +02:00
parent 08fd460867
commit e66412da1b
12 changed files with 76 additions and 17 deletions

View File

@@ -7,6 +7,7 @@ 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"
@@ -218,3 +219,11 @@ func (t *UDPTracker) sendEvent(typ nftypes.Type, conn *UDPConnTrack, ruleID []by
TxBytes: conn.BytesTx.Load(),
})
}
func (t *UDPTracker) getConnections() map[ConnKey]*UDPConnTrack {
t.mutex.RLock()
defer t.mutex.RUnlock()
copyConn := make(map[ConnKey]*UDPConnTrack, len(t.connections))
maps.Copy(copyConn, t.connections)
return copyConn
}

View File

@@ -202,13 +202,13 @@ func TestUDPTracker_Cleanup(t *testing.T) {
}
// Verify initial connections
assert.Len(t, tracker.connections, 2)
assert.Len(t, tracker.getConnections(), 2)
// Wait for connection timeout and cleanup interval
time.Sleep(timeout + 2*cleanupInterval)
tracker.mutex.RLock()
connCount := len(tracker.connections)
connCount := len(tracker.getConnections())
tracker.mutex.RUnlock()
// Verify connections were cleaned up