mirror of
https://github.com/netbirdio/ice-old.git
synced 2026-05-22 17:08:24 -07:00
Fix timeout check order
Timeout check must be inside the scope of routine leak check. Routine leak check internally has wait for routine exit which may causes timeout error in some case.
This commit is contained in:
committed by
Sean DuBois
parent
9f7c603344
commit
47186b5abd
+19
-19
@@ -228,13 +228,13 @@ func runAgentTest(t *testing.T, config *AgentConfig, task func(a *Agent)) {
|
||||
}
|
||||
|
||||
func TestHandlePeerReflexive(t *testing.T) {
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 2)
|
||||
defer lim.Stop()
|
||||
|
||||
t.Run("UDP pflx candidate from handleInbound()", func(t *testing.T) {
|
||||
var config AgentConfig
|
||||
runAgentTest(t, &config, func(a *Agent) {
|
||||
@@ -466,12 +466,12 @@ func TestConnectivityOnStartup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConnectivityLite(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
stunServerURL := &URL{
|
||||
Scheme: SchemeTypeSTUN,
|
||||
Host: "1.2.3.4",
|
||||
@@ -710,12 +710,12 @@ func TestInvalidAgentStarts(t *testing.T) {
|
||||
|
||||
// Assert that Agent emits Connecting/Connected/Disconnected/Failed/Closed messages
|
||||
func TestConnectionStateCallback(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
disconnectedDuration := time.Second
|
||||
failedDuration := time.Second
|
||||
KeepaliveInterval := time.Duration(0)
|
||||
@@ -1253,12 +1253,12 @@ func TestAgentCredentials(t *testing.T) {
|
||||
// Assert that Agent on Failure deletes all existing candidates
|
||||
// User can then do an ICE Restart to bring agent back
|
||||
func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
oneSecond := time.Second
|
||||
KeepaliveInterval := time.Duration(0)
|
||||
|
||||
@@ -1300,12 +1300,12 @@ func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
||||
|
||||
// Assert that the ICE Agent can go directly from Connecting -> Failed on both sides
|
||||
func TestConnectionStateConnectingToFailed(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
oneSecond := time.Second
|
||||
KeepaliveInterval := time.Duration(0)
|
||||
|
||||
@@ -1361,12 +1361,12 @@ func TestConnectionStateConnectingToFailed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentRestart(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
t.Run("Restart During Gather", func(t *testing.T) {
|
||||
agent, err := NewAgent(&AgentConfig{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
)
|
||||
|
||||
func TestServerReflexiveOnlyConnection(t *testing.T) {
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
serverPort := randomPort(t)
|
||||
serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort))
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -430,12 +430,12 @@ func TestConnectivityVNet(t *testing.T) {
|
||||
|
||||
// TestDisconnectedToConnected asserts that an agent can go to disconnected, and then return to connected successfully
|
||||
func TestDisconnectedToConnected(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 10)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 10)
|
||||
defer lim.Stop()
|
||||
|
||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||
|
||||
// Create a network with two interfaces
|
||||
@@ -526,12 +526,12 @@ func TestDisconnectedToConnected(t *testing.T) {
|
||||
|
||||
// Agent.Write should use the best valid pair if a selected pair is not yet available
|
||||
func TestWriteUseValidPair(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 10)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 10)
|
||||
defer lim.Stop()
|
||||
|
||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||
|
||||
// Create a network with two interfaces
|
||||
|
||||
+6
-6
@@ -80,12 +80,12 @@ func TestListenUDP(t *testing.T) {
|
||||
|
||||
// Assert that STUN gathering is done concurrently
|
||||
func TestSTUNConcurrency(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
serverPort := randomPort(t)
|
||||
serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort))
|
||||
assert.NoError(t, err)
|
||||
@@ -139,12 +139,12 @@ func TestSTUNConcurrency(t *testing.T) {
|
||||
|
||||
// Assert that TURN gathering is done concurrently
|
||||
func TestTURNConcurrency(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
runTest := func(protocol ProtoType, scheme SchemeType, packetConn net.PacketConn, listener net.Listener, serverPort int) {
|
||||
packetConnConfigs := []turn.PacketConnConfig{}
|
||||
if packetConn != nil {
|
||||
|
||||
+9
-9
@@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
func TestMulticastDNSOnlyConnection(t *testing.T) {
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
cfg := &AgentConfig{
|
||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||
CandidateTypes: []CandidateType{CandidateTypeHost},
|
||||
@@ -54,13 +54,13 @@ func TestMulticastDNSOnlyConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMulticastDNSMixedConnection(t *testing.T) {
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
aAgent, err := NewAgent(&AgentConfig{
|
||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||
CandidateTypes: []CandidateType{CandidateTypeHost},
|
||||
@@ -98,12 +98,12 @@ func TestMulticastDNSMixedConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMulticastDNSStaticHostName(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
lim := test.TimeOut(time.Second * 30)
|
||||
defer lim.Stop()
|
||||
|
||||
_, err := NewAgent(&AgentConfig{
|
||||
NetworkTypes: []NetworkType{NetworkTypeUDP4},
|
||||
CandidateTypes: []CandidateType{CandidateTypeHost},
|
||||
|
||||
+4
-4
@@ -14,14 +14,14 @@ import (
|
||||
)
|
||||
|
||||
func TestStressDuplex(t *testing.T) {
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 20)
|
||||
defer lim.Stop()
|
||||
|
||||
// Check for leaking routines
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
// Limit runtime in case of deadlocks
|
||||
lim := test.TimeOut(time.Second * 20)
|
||||
defer lim.Stop()
|
||||
|
||||
// Run the test
|
||||
stressDuplex(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user