Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run reconnect test using QUIC #1268

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions p2p/test/reconnects/reconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/protocol"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log/v2"
"github.com/stretchr/testify/require"
)

var log = logging.Logger("reconnect")
Expand Down Expand Up @@ -102,9 +104,11 @@ func newSender() (chan sendChans, func(s network.Stream)) {

// TestReconnect tests whether hosts are able to disconnect and reconnect.
func TestReconnect2(t *testing.T) {
h1, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
// TCP RST handling is flaky in OSX, see https://github.com/golang/go/issues/50254.
// We can avoid this by using QUIC in this test.
h1, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
require.NoError(t, err)
h2, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
h2, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
require.NoError(t, err)
hosts := []host.Host{h1, h2}

Expand All @@ -117,7 +121,7 @@ func TestReconnect2(t *testing.T) {
}
for i := 0; i < rounds; i++ {
log.Debugf("TestReconnect: %d/%d\n", i, rounds)
SubtestConnSendDisc(t, hosts)
subtestConnSendDisc(t, hosts)
}
}

Expand All @@ -126,7 +130,9 @@ func TestReconnect5(t *testing.T) {
const num = 5
hosts := make([]host.Host, 0, num)
for i := 0; i < num; i++ {
h, err := bhost.NewHost(swarmt.GenSwarm(t), nil)
// TCP RST handling is flaky in OSX, see https://github.com/golang/go/issues/50254.
// We can avoid this by using QUIC in this test.
h, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableTCP), nil)
require.NoError(t, err)
h.SetStreamHandler(protocol.TestingID, EchoStreamHandler)
hosts = append(hosts, h)
Expand All @@ -138,12 +144,11 @@ func TestReconnect5(t *testing.T) {
}
for i := 0; i < rounds; i++ {
log.Debugf("TestReconnect: %d/%d\n", i, rounds)
SubtestConnSendDisc(t, hosts)
subtestConnSendDisc(t, hosts)
}
}

func SubtestConnSendDisc(t *testing.T, hosts []host.Host) {

func subtestConnSendDisc(t *testing.T, hosts []host.Host) {
ctx := context.Background()
numStreams := 3 * len(hosts)
numMsgs := 10
Expand Down