Skip to content

Commit

Permalink
Add more cases in reconnection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Jun 24, 2019
1 parent 44a3f38 commit 3aaa864
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/dmsg/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@ func testReconnect(t *testing.T, randomAddr bool) {
err = initiator.InitiateServerConnections(ctx, 1)
require.NoError(t, err)

initiatorTransport, err := initiator.Dial(ctx, remotePK)
require.NoError(t, err)

require.NoError(t, testWithTimeout(smallDelay, func() error {
if s.connCount() != 2 {
return errors.New("s.conns is not equal to 2")
Expand All @@ -713,6 +716,10 @@ func testReconnect(t *testing.T, randomAddr bool) {
err = s.Close()
assert.NoError(t, err)

initTr := initiatorTransport.(*Transport)
assert.False(t, isDoneChannelOpen(initTr.done))
assert.False(t, isReadChannelOpen(initTr.inCh))

assert.Equal(t, 0, s.connCount())

addr := ""
Expand All @@ -735,6 +742,21 @@ func testReconnect(t *testing.T, randomAddr bool) {
return nil
}))

remoteDone := make(chan struct{})
var remoteErr error
go func() {
_, remoteErr = remote.Accept(ctx)
close(remoteDone)
}()

require.NoError(t, testWithTimeout(smallDelay, func() error {
_, err = initiator.Dial(ctx, remotePK)
return err
}))

<-remoteDone
require.NoError(t, remoteErr)

err = s.Close()
assert.NoError(t, err)
}
Expand Down

0 comments on commit 3aaa864

Please sign in to comment.