-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tcpreuse): add options for sharing TCP listeners amongst TCP, WS…
… and WSS transports (#2984) Allows the same socket to be shared amongst TCP,WS,WSS transports. --------- Co-authored-by: sukun <[email protected]> Co-authored-by: Marco Munizaga <[email protected]>
- Loading branch information
1 parent
362e583
commit 5a47a90
Showing
32 changed files
with
1,597 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// go:build: unix | ||
|
||
package tcp | ||
|
||
import ( | ||
"testing" | ||
|
||
tptu "github.com/libp2p/go-libp2p/p2p/net/upgrader" | ||
"github.com/libp2p/go-libp2p/p2p/transport/tcpreuse" | ||
ttransport "github.com/libp2p/go-libp2p/p2p/transport/testsuite" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTcpTransportCollectsMetricsWithSharedTcpSocket(t *testing.T) { | ||
|
||
peerA, ia := makeInsecureMuxer(t) | ||
_, ib := makeInsecureMuxer(t) | ||
|
||
sharedTCPSocketA := tcpreuse.NewConnMgr(false, nil, nil) | ||
sharedTCPSocketB := tcpreuse.NewConnMgr(false, nil, nil) | ||
|
||
ua, err := tptu.New(ia, muxers, nil, nil, nil) | ||
require.NoError(t, err) | ||
ta, err := NewTCPTransport(ua, nil, sharedTCPSocketA, WithMetrics()) | ||
require.NoError(t, err) | ||
ub, err := tptu.New(ib, muxers, nil, nil, nil) | ||
require.NoError(t, err) | ||
tb, err := NewTCPTransport(ub, nil, sharedTCPSocketB, WithMetrics()) | ||
require.NoError(t, err) | ||
|
||
zero := "/ip4/127.0.0.1/tcp/0" | ||
|
||
// Not running any test that needs more than 1 conn because the testsuite | ||
// opens multiple conns via multiple listeners, which is not expected to work | ||
// with the shared TCP socket. | ||
subtestsToRun := []ttransport.TransportSubTestFn{ | ||
ttransport.SubtestProtocols, | ||
ttransport.SubtestBasic, | ||
ttransport.SubtestCancel, | ||
ttransport.SubtestPingPong, | ||
|
||
// Stolen from the stream muxer test suite. | ||
ttransport.SubtestStress1Conn1Stream1Msg, | ||
ttransport.SubtestStress1Conn1Stream100Msg, | ||
ttransport.SubtestStress1Conn100Stream100Msg, | ||
ttransport.SubtestStress1Conn1000Stream10Msg, | ||
ttransport.SubtestStress1Conn100Stream100Msg10MB, | ||
ttransport.SubtestStreamOpenStress, | ||
ttransport.SubtestStreamReset, | ||
} | ||
|
||
ttransport.SubtestTransportWithFs(t, ta, tb, zero, peerA, subtestsToRun) | ||
} |
Oops, something went wrong.