From 9a0323419e9481186340a6455553fbc515969258 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Fri, 31 Aug 2018 11:23:13 +0900 Subject: fix closing listening socket blocked with go v1.11, closing a listening socket is blocked and unittests fail due to timeout. Signed-off-by: FUJITA Tomonori --- pkg/server/server_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'pkg/server/server_test.go') diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index e56c6302..f1809e26 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -115,6 +115,7 @@ func TestListPolicyAssignment(t *testing.T) { }, }) assert.Nil(err) + defer s.StopBgp(context.Background(), &api.StopBgpRequest{}) for i := 1; i < 4; i++ { addr := fmt.Sprintf("127.0.0.%d", i) @@ -211,6 +212,11 @@ func TestMonitor(test *testing.T) { RemotePort: 10179, }, }, + Timers: config.Timers{ + Config: config.TimersConfig{ + ConnectRetry: 10, + }, + }, } err = t.AddPeer(context.Background(), &api.AddPeerRequest{Peer: NewPeerFromConfigStruct(m)}) assert.Nil(err) @@ -344,6 +350,11 @@ func TestNumGoroutineWithAddDeleteNeighbor(t *testing.T) { // wait goroutines to finish (e.g. internal goroutine for // InfiniteChannel) time.Sleep(time.Second * 5) + for i := 0; i < 5; i++ { + if num == runtime.NumGoroutine() { + return + } + } assert.Equal(num, runtime.NumGoroutine()) } @@ -580,6 +591,11 @@ func TestPeerGroup(test *testing.T) { RemotePort: 10179, }, }, + Timers: config.Timers{ + Config: config.TimersConfig{ + ConnectRetry: 10, + }, + }, } err = t.AddPeer(context.Background(), &api.AddPeerRequest{Peer: NewPeerFromConfigStruct(m)}) assert.Nil(err) @@ -647,6 +663,11 @@ func TestDynamicNeighbor(t *testing.T) { RemotePort: 10179, }, }, + Timers: config.Timers{ + Config: config.TimersConfig{ + ConnectRetry: 10, + }, + }, } err = s2.AddPeer(context.Background(), &api.AddPeerRequest{Peer: NewPeerFromConfigStruct(m)}) @@ -722,6 +743,11 @@ func TestGracefulRestartTimerExpired(t *testing.T) { RestartTime: 1, }, }, + Timers: config.Timers{ + Config: config.TimersConfig{ + ConnectRetry: 10, + }, + }, } err = s2.addNeighbor(m) assert.Nil(err) -- cgit v1.2.3