From b5289f13bbea74f338ce1962b7c029bf865afe3f Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Wed, 18 May 2022 13:44:50 -0700 Subject: [PATCH] tcp: limit the number of connections in tcp suite test on non-linux hosts (#1507) * Only run the 50 connection test on linux * Only one stress test on linux instead of both --- p2p/transport/testsuite/stream_suite.go | 11 +++++++++-- p2p/transport/testsuite/utils_suite.go | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/p2p/transport/testsuite/stream_suite.go b/p2p/transport/testsuite/stream_suite.go index e7770bfa7..7056dbf1d 100644 --- a/p2p/transport/testsuite/stream_suite.go +++ b/p2p/transport/testsuite/stream_suite.go @@ -7,6 +7,7 @@ import ( "io" "io/ioutil" "os" + "runtime" "strconv" "sync" "testing" @@ -417,9 +418,15 @@ func SubtestStress1Conn100Stream100Msg(t *testing.T, ta, tb transport.Transport, }) } -func SubtestStress50Conn10Stream50Msg(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID) { +func SubtestStressManyConn10Stream50Msg(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID) { + connNum := 5 + if runtime.GOOS == "linux" { + // Linux can handle a higher number of conns here than other platforms in CI. + // See https://github.com/libp2p/go-libp2p/issues/1498. + connNum = 50 + } SubtestStress(t, ta, tb, maddr, peerA, Options{ - ConnNum: 50, + ConnNum: connNum, StreamNum: 10, MsgNum: 50, MsgMax: 100, diff --git a/p2p/transport/testsuite/utils_suite.go b/p2p/transport/testsuite/utils_suite.go index 1d520ff26..201d43d9d 100644 --- a/p2p/transport/testsuite/utils_suite.go +++ b/p2p/transport/testsuite/utils_suite.go @@ -21,7 +21,7 @@ var Subtests = []func(t *testing.T, ta, tb transport.Transport, maddr ma.Multiad SubtestStress1Conn1Stream1Msg, SubtestStress1Conn1Stream100Msg, SubtestStress1Conn100Stream100Msg, - SubtestStress50Conn10Stream50Msg, + SubtestStressManyConn10Stream50Msg, SubtestStress1Conn1000Stream10Msg, SubtestStress1Conn100Stream100Msg10MB, SubtestStreamOpenStress, @@ -37,6 +37,7 @@ func SubtestTransport(t *testing.T, ta, tb transport.Transport, addr string, pee if err != nil { t.Fatal(err) } + for _, f := range Subtests { t.Run(getFunctionName(f), func(t *testing.T) { f(t, ta, tb, maddr, peerA)