summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-11-24 14:29:50 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-11-24 14:29:50 +0900
commit8c7772f5d5a55d52cca2d4e8593f5884cdb6ea2a (patch)
tree3921f02ca8858281a7dbd3f001202b4a7c61e21c /server
parentdaca3cf3bcb855bab6f138e39fd78d2ee2bf9b22 (diff)
server: add unit test to check NumGoroutine with Neighbor configuration
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/server_test.go b/server/server_test.go
index c9f142f1..73eadb0a 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -21,6 +21,7 @@ import (
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/table"
"github.com/stretchr/testify/assert"
+ "runtime"
"testing"
"time"
)
@@ -144,3 +145,40 @@ func TestMonitor(test *testing.T) {
//stop the watcher still having an item.
w.Stop()
}
+
+func TestNumGoroutineWithAddDeleteNeighbor(t *testing.T) {
+ assert := assert.New(t)
+ s := NewBgpServer()
+ go s.Serve()
+ err := s.Start(&config.Global{
+ Config: config.GlobalConfig{
+ As: 1,
+ RouterId: "1.1.1.1",
+ Port: -1,
+ },
+ })
+ assert.Nil(err)
+
+ num := runtime.NumGoroutine()
+
+ n := &config.Neighbor{
+ Config: config.NeighborConfig{
+ NeighborAddress: "127.0.0.1",
+ PeerAs: 2,
+ },
+ Transport: config.Transport{
+ Config: config.TransportConfig{
+ PassiveMode: true,
+ },
+ },
+ }
+ err = s.AddNeighbor(n)
+ assert.Nil(err)
+
+ err = s.DeleteNeighbor(n)
+ assert.Nil(err)
+ // wait goroutines to finish (e.g. internal goroutine for
+ // InfiniteChannel)
+ time.Sleep(time.Second * 5)
+ assert.Equal(num, runtime.NumGoroutine())
+}