mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Simplify usage of test.TimeOut()
Execute directly instead of allocating function
This commit is contained in:
+2
-4
@@ -37,8 +37,7 @@ func ipv6Available(t *testing.T) bool {
|
|||||||
func TestActiveTCP(t *testing.T) {
|
func TestActiveTCP(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
const listenPort = 7686
|
const listenPort = 7686
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
@@ -164,8 +163,7 @@ func TestActiveTCP(t *testing.T) {
|
|||||||
func TestActiveTCP_NonBlocking(t *testing.T) {
|
func TestActiveTCP_NonBlocking(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
cfg := &AgentConfig{
|
cfg := &AgentConfig{
|
||||||
NetworkTypes: supportedNetworkTypes(),
|
NetworkTypes: supportedNetworkTypes(),
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
func TestConnectionStateNotifier(t *testing.T) {
|
func TestConnectionStateNotifier(t *testing.T) {
|
||||||
t.Run("TestManyUpdates", func(t *testing.T) {
|
t.Run("TestManyUpdates", func(t *testing.T) {
|
||||||
|
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
updates := make(chan struct{}, 1)
|
updates := make(chan struct{}, 1)
|
||||||
|
|||||||
+13
-26
@@ -37,8 +37,7 @@ func TestHandlePeerReflexive(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 2)
|
defer test.TimeOut(time.Second * 2).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
t.Run("UDP prflx candidate from handleInbound()", func(t *testing.T) {
|
t.Run("UDP prflx candidate from handleInbound()", func(t *testing.T) {
|
||||||
a, err := NewAgent(&AgentConfig{})
|
a, err := NewAgent(&AgentConfig{})
|
||||||
@@ -184,8 +183,7 @@ func TestHandlePeerReflexive(t *testing.T) {
|
|||||||
func TestConnectivityOnStartup(t *testing.T) {
|
func TestConnectivityOnStartup(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
// Create a network with two interfaces
|
// Create a network with two interfaces
|
||||||
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
||||||
@@ -292,8 +290,7 @@ func TestConnectivityOnStartup(t *testing.T) {
|
|||||||
func TestConnectivityLite(t *testing.T) {
|
func TestConnectivityLite(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
stunServerURL := &stun.URI{
|
stunServerURL := &stun.URI{
|
||||||
Scheme: SchemeTypeSTUN,
|
Scheme: SchemeTypeSTUN,
|
||||||
@@ -535,8 +532,7 @@ func TestInvalidAgentStarts(t *testing.T) {
|
|||||||
func TestConnectionStateCallback(t *testing.T) {
|
func TestConnectionStateCallback(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
disconnectedDuration := time.Second
|
disconnectedDuration := time.Second
|
||||||
failedDuration := time.Second
|
failedDuration := time.Second
|
||||||
@@ -1074,8 +1070,7 @@ func TestAgentCredentials(t *testing.T) {
|
|||||||
func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
oneSecond := time.Second
|
oneSecond := time.Second
|
||||||
KeepaliveInterval := time.Duration(0)
|
KeepaliveInterval := time.Duration(0)
|
||||||
@@ -1119,8 +1114,7 @@ func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
|||||||
func TestConnectionStateConnectingToFailed(t *testing.T) {
|
func TestConnectionStateConnectingToFailed(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
oneSecond := time.Second
|
oneSecond := time.Second
|
||||||
KeepaliveInterval := time.Duration(0)
|
KeepaliveInterval := time.Duration(0)
|
||||||
@@ -1178,8 +1172,7 @@ func TestConnectionStateConnectingToFailed(t *testing.T) {
|
|||||||
func TestAgentRestart(t *testing.T) {
|
func TestAgentRestart(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
oneSecond := time.Second
|
oneSecond := time.Second
|
||||||
|
|
||||||
@@ -1375,8 +1368,7 @@ func TestGetLocalCandidates(t *testing.T) {
|
|||||||
func TestCloseInConnectionStateCallback(t *testing.T) {
|
func TestCloseInConnectionStateCallback(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
disconnectedDuration := time.Second
|
disconnectedDuration := time.Second
|
||||||
failedDuration := time.Second
|
failedDuration := time.Second
|
||||||
@@ -1428,8 +1420,7 @@ func TestCloseInConnectionStateCallback(t *testing.T) {
|
|||||||
func TestRunTaskInConnectionStateCallback(t *testing.T) {
|
func TestRunTaskInConnectionStateCallback(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
oneSecond := time.Second
|
oneSecond := time.Second
|
||||||
KeepaliveInterval := time.Duration(0)
|
KeepaliveInterval := time.Duration(0)
|
||||||
@@ -1472,8 +1463,7 @@ func TestRunTaskInConnectionStateCallback(t *testing.T) {
|
|||||||
func TestRunTaskInSelectedCandidatePairChangeCallback(t *testing.T) {
|
func TestRunTaskInSelectedCandidatePairChangeCallback(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 5)
|
defer test.TimeOut(time.Second * 5).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
oneSecond := time.Second
|
oneSecond := time.Second
|
||||||
KeepaliveInterval := time.Duration(0)
|
KeepaliveInterval := time.Duration(0)
|
||||||
@@ -1524,8 +1514,7 @@ func TestRunTaskInSelectedCandidatePairChangeCallback(t *testing.T) {
|
|||||||
func TestLiteLifecycle(t *testing.T) {
|
func TestLiteLifecycle(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
aNotifier, aConnected := onConnected()
|
aNotifier, aConnected := onConnected()
|
||||||
|
|
||||||
@@ -1598,8 +1587,7 @@ func TestNilCandidatePair(t *testing.T) {
|
|||||||
func TestGetSelectedCandidatePair(t *testing.T) {
|
func TestGetSelectedCandidatePair(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
||||||
CIDR: "0.0.0.0/0",
|
CIDR: "0.0.0.0/0",
|
||||||
@@ -1655,8 +1643,7 @@ func TestGetSelectedCandidatePair(t *testing.T) {
|
|||||||
func TestAcceptAggressiveNomination(t *testing.T) {
|
func TestAcceptAggressiveNomination(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
// Create a network with two interfaces
|
// Create a network with two interfaces
|
||||||
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
wan, err := vnet.NewRouter(&vnet.RouterConfig{
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ import (
|
|||||||
func TestMuxAgent(t *testing.T) {
|
func TestMuxAgent(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
const muxPort = 7686
|
const muxPort = 7686
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ func optimisticAuthHandler(string, string, net.Addr) (key []byte, ok bool) {
|
|||||||
|
|
||||||
func TestRelayOnlyConnection(t *testing.T) {
|
func TestRelayOnlyConnection(t *testing.T) {
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ func TestServerReflexiveOnlyConnection(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
serverPort := randomPort(t)
|
serverPort := randomPort(t)
|
||||||
serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort))
|
serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort))
|
||||||
|
|||||||
@@ -450,8 +450,7 @@ func TestConnectivityVNet(t *testing.T) {
|
|||||||
func TestDisconnectedToConnected(t *testing.T) {
|
func TestDisconnectedToConnected(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 10)
|
defer test.TimeOut(time.Second * 10).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||||
|
|
||||||
@@ -547,8 +546,7 @@ func TestDisconnectedToConnected(t *testing.T) {
|
|||||||
func TestWriteUseValidPair(t *testing.T) {
|
func TestWriteUseValidPair(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 10)
|
defer test.TimeOut(time.Second * 10).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||||
|
|
||||||
|
|||||||
+12
-25
@@ -92,8 +92,7 @@ func TestListenUDP(t *testing.T) {
|
|||||||
func TestGatherConcurrency(t *testing.T) {
|
func TestGatherConcurrency(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
a, err := NewAgent(&AgentConfig{
|
a, err := NewAgent(&AgentConfig{
|
||||||
NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6},
|
NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6},
|
||||||
@@ -119,8 +118,7 @@ func TestGatherConcurrency(t *testing.T) {
|
|||||||
func TestLoopbackCandidate(t *testing.T) {
|
func TestLoopbackCandidate(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
agentConfig *AgentConfig
|
agentConfig *AgentConfig
|
||||||
@@ -229,8 +227,7 @@ func TestLoopbackCandidate(t *testing.T) {
|
|||||||
func TestSTUNConcurrency(t *testing.T) {
|
func TestSTUNConcurrency(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
serverPort := randomPort(t)
|
serverPort := randomPort(t)
|
||||||
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
||||||
@@ -304,8 +301,7 @@ func TestSTUNConcurrency(t *testing.T) {
|
|||||||
func TestTURNConcurrency(t *testing.T) {
|
func TestTURNConcurrency(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
runTest := func(protocol stun.ProtoType, scheme stun.SchemeType, packetConn net.PacketConn, listener net.Listener, serverPort int) {
|
runTest := func(protocol stun.ProtoType, scheme stun.SchemeType, packetConn net.PacketConn, listener net.Listener, serverPort int) {
|
||||||
packetConnConfigs := []turn.PacketConnConfig{}
|
packetConnConfigs := []turn.PacketConnConfig{}
|
||||||
@@ -421,8 +417,7 @@ func TestTURNConcurrency(t *testing.T) {
|
|||||||
func TestSTUNTURNConcurrency(t *testing.T) {
|
func TestSTUNTURNConcurrency(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 8)
|
defer test.TimeOut(time.Second * 8).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
serverPort := randomPort(t)
|
serverPort := randomPort(t)
|
||||||
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
||||||
@@ -465,7 +460,7 @@ func TestSTUNTURNConcurrency(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
{
|
{
|
||||||
gatherLim := test.TimeOut(time.Second * 3) // As TURN and STUN should be checked in parallel, this should complete before the default STUN timeout (5s)
|
defer test.TimeOut(time.Second * 3).Stop() // As TURN and STUN should be checked in parallel, this should complete before the default STUN timeout (5s)
|
||||||
candidateGathered, candidateGatheredFunc := context.WithCancel(context.Background())
|
candidateGathered, candidateGatheredFunc := context.WithCancel(context.Background())
|
||||||
require.NoError(t, a.OnCandidate(func(c Candidate) {
|
require.NoError(t, a.OnCandidate(func(c Candidate) {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
@@ -475,8 +470,6 @@ func TestSTUNTURNConcurrency(t *testing.T) {
|
|||||||
require.NoError(t, a.GatherCandidates())
|
require.NoError(t, a.GatherCandidates())
|
||||||
|
|
||||||
<-candidateGathered.Done()
|
<-candidateGathered.Done()
|
||||||
|
|
||||||
gatherLim.Stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require.NoError(t, a.Close())
|
require.NoError(t, a.Close())
|
||||||
@@ -492,8 +485,7 @@ func TestSTUNTURNConcurrency(t *testing.T) {
|
|||||||
func TestTURNSrflx(t *testing.T) {
|
func TestTURNSrflx(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
serverPort := randomPort(t)
|
serverPort := randomPort(t)
|
||||||
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort))
|
||||||
@@ -577,8 +569,7 @@ func (m *mockProxy) Dial(string, string) (net.Conn, error) {
|
|||||||
func TestTURNProxyDialer(t *testing.T) {
|
func TestTURNProxyDialer(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
proxyWasDialed, proxyWasDialedFunc := context.WithCancel(context.Background())
|
proxyWasDialed, proxyWasDialedFunc := context.WithCancel(context.Background())
|
||||||
proxy.RegisterDialerType("tcp", func(*url.URL, proxy.Dialer) (proxy.Dialer, error) {
|
proxy.RegisterDialerType("tcp", func(*url.URL, proxy.Dialer) (proxy.Dialer, error) {
|
||||||
@@ -627,8 +618,7 @@ func TestTURNProxyDialer(t *testing.T) {
|
|||||||
func TestUDPMuxDefaultWithNAT1To1IPsUsage(t *testing.T) {
|
func TestUDPMuxDefaultWithNAT1To1IPsUsage(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
conn, err := net.ListenPacket("udp4", ":0")
|
conn, err := net.ListenPacket("udp4", ":0")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -670,8 +660,7 @@ func TestUDPMuxDefaultWithNAT1To1IPsUsage(t *testing.T) {
|
|||||||
func TestMultiUDPMuxUsage(t *testing.T) {
|
func TestMultiUDPMuxUsage(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
var expectedPorts []int
|
var expectedPorts []int
|
||||||
var udpMuxInstances []UDPMux
|
var udpMuxInstances []UDPMux
|
||||||
@@ -726,8 +715,7 @@ func TestMultiUDPMuxUsage(t *testing.T) {
|
|||||||
func TestMultiTCPMuxUsage(t *testing.T) {
|
func TestMultiTCPMuxUsage(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
var expectedPorts []int
|
var expectedPorts []int
|
||||||
var tcpMuxInstances []TCPMux
|
var tcpMuxInstances []TCPMux
|
||||||
@@ -785,8 +773,7 @@ func TestMultiTCPMuxUsage(t *testing.T) {
|
|||||||
func TestUniversalUDPMuxUsage(t *testing.T) {
|
func TestUniversalUDPMuxUsage(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
conn, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IP{127, 0, 0, 1}, Port: randomPort(t)})
|
conn, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IP{127, 0, 0, 1}, Port: randomPort(t)})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
+3
-6
@@ -20,8 +20,7 @@ func TestMulticastDNSOnlyConnection(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
cfg := &AgentConfig{
|
cfg := &AgentConfig{
|
||||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||||
@@ -61,8 +60,7 @@ func TestMulticastDNSMixedConnection(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
aAgent, err := NewAgent(&AgentConfig{
|
aAgent, err := NewAgent(&AgentConfig{
|
||||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||||
@@ -103,8 +101,7 @@ func TestMulticastDNSMixedConnection(t *testing.T) {
|
|||||||
func TestMulticastDNSStaticHostName(t *testing.T) {
|
func TestMulticastDNSStaticHostName(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
_, err := NewAgent(&AgentConfig{
|
_, err := NewAgent(&AgentConfig{
|
||||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||||
|
|||||||
+4
-8
@@ -22,8 +22,7 @@ func TestStressDuplex(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 20)
|
defer test.TimeOut(time.Second * 20).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
// Run the test
|
// Run the test
|
||||||
stressDuplex(t)
|
stressDuplex(t)
|
||||||
@@ -78,8 +77,7 @@ func TestTimeout(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 20)
|
defer test.TimeOut(time.Second * 20).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
t.Run("WithoutDisconnectTimeout", func(t *testing.T) {
|
t.Run("WithoutDisconnectTimeout", func(t *testing.T) {
|
||||||
ca, cb := pipe(nil)
|
ca, cb := pipe(nil)
|
||||||
@@ -109,8 +107,7 @@ func TestReadClosed(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 20)
|
defer test.TimeOut(time.Second * 20).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
ca, cb := pipe(nil)
|
ca, cb := pipe(nil)
|
||||||
|
|
||||||
@@ -321,8 +318,7 @@ func TestConnStats(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 20)
|
defer test.TimeOut(time.Second * 20).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
ca, cb := pipe(nil)
|
ca, cb := pipe(nil)
|
||||||
if _, err := ca.Write(make([]byte, 10)); err != nil {
|
if _, err := ca.Write(make([]byte, 10)); err != nil {
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ func TestRemoteLocalAddr(t *testing.T) {
|
|||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
// Limit runtime in case of deadlocks
|
// Limit runtime in case of deadlocks
|
||||||
lim := test.TimeOut(time.Second * 20)
|
defer test.TimeOut(time.Second * 20).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
// Agent0 is behind 1:1 NAT
|
// Agent0 is behind 1:1 NAT
|
||||||
natType0 := &vnet.NATType{Mode: vnet.NATModeNAT1To1}
|
natType0 := &vnet.NATType{Mode: vnet.NATModeNAT1To1}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ import (
|
|||||||
func TestMultiUDPMux(t *testing.T) {
|
func TestMultiUDPMux(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
conn1, err := net.ListenUDP(udp, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
conn1, err := net.ListenUDP(udp, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -112,8 +111,7 @@ func testMultiUDPMuxConnections(t *testing.T, udpMuxMulti *MultiUDPMuxDefault, u
|
|||||||
func TestUnspecifiedUDPMux(t *testing.T) {
|
func TestUnspecifiedUDPMux(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
muxPort := 7778
|
muxPort := 7778
|
||||||
udpMuxMulti, err := NewMultiUDPMuxFromPort(muxPort, UDPMuxFromPortWithInterfaceFilter(func(s string) bool {
|
udpMuxMulti, err := NewMultiUDPMuxFromPort(muxPort, UDPMuxFromPortWithInterfaceFilter(func(s string) bool {
|
||||||
|
|||||||
+1
-2
@@ -23,8 +23,7 @@ import (
|
|||||||
func TestUDPMux(t *testing.T) {
|
func TestUDPMux(t *testing.T) {
|
||||||
defer test.CheckRoutines(t)()
|
defer test.CheckRoutines(t)()
|
||||||
|
|
||||||
lim := test.TimeOut(time.Second * 30)
|
defer test.TimeOut(time.Second * 30).Stop()
|
||||||
defer lim.Stop()
|
|
||||||
|
|
||||||
conn4, err := net.ListenUDP(udp, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
conn4, err := net.ListenUDP(udp, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user