summaryrefslogtreecommitdiffhomepage
path: root/server/server_test.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-05-18 15:34:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-06-05 14:24:45 +0900
commit6e9d5b56c41904fbc63928888d3437f88f05f473 (patch)
tree624e993941e6e032ba1d33d47466d95f4de0a4ba /server/server_test.go
parent8fd9530ff9602912c57c18faf86e4144533c1f05 (diff)
*: Support Peer-Group Configuration
This patch enables to create peer-groups, also supports dynamic configuration to peer-groups. Manually set fields in neighbor configs have priority over its peer-group's config, except some fields, like "peer-as", or "minimum-advertisement-interval" and so on. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'server/server_test.go')
-rw-r--r--server/server_test.go81
1 files changed, 81 insertions, 0 deletions
diff --git a/server/server_test.go b/server/server_test.go
index 9caf8a62..99e63f54 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -343,3 +343,84 @@ func TestFilterpathWithRejectPolicy(t *testing.T) {
}
}
+
+func TestPeerGroup(test *testing.T) {
+ log.SetLevel(log.DebugLevel)
+ s := NewBgpServer()
+ go s.Serve()
+ s.Start(&config.Global{
+ Config: config.GlobalConfig{
+ As: 1,
+ RouterId: "1.1.1.1",
+ Port: 10180,
+ },
+ })
+ g := &config.PeerGroup{
+ Config: config.PeerGroupConfig{
+ PeerAs: 2,
+ PeerGroupName: "g",
+ },
+ }
+ if err := s.AddPeerGroup(g); err != nil {
+ log.Fatal(err)
+ }
+ n := &config.Neighbor{
+ Config: config.NeighborConfig{
+ NeighborAddress: "127.0.0.1",
+ PeerGroup: "g",
+ },
+ Transport: config.Transport{
+ Config: config.TransportConfig{
+ PassiveMode: true,
+ },
+ },
+ }
+ configured := map[string]interface{}{
+ "config": map[string]interface{}{
+ "neigbor-address": "127.0.0.1",
+ "peer-group": "g",
+ },
+ "transport": map[string]interface{}{
+ "config": map[string]interface{}{
+ "passive-mode": true,
+ },
+ },
+ }
+ config.RegisterConfiguredFields("127.0.0.1", configured)
+
+ if err := s.AddNeighbor(n); err != nil {
+ log.Fatal(err)
+ }
+
+ t := NewBgpServer()
+ go t.Serve()
+ t.Start(&config.Global{
+ Config: config.GlobalConfig{
+ As: 2,
+ RouterId: "2.2.2.2",
+ Port: -1,
+ },
+ })
+
+ m := &config.Neighbor{
+ Config: config.NeighborConfig{
+ NeighborAddress: "127.0.0.1",
+ PeerAs: 1,
+ },
+ Transport: config.Transport{
+ Config: config.TransportConfig{
+ RemotePort: 10180,
+ },
+ },
+ }
+ if err := t.AddNeighbor(m); err != nil {
+ log.Fatal(err)
+ }
+
+ for {
+ time.Sleep(time.Second)
+ if t.GetNeighbor("", false)[0].State.SessionState == config.SESSION_STATE_ESTABLISHED {
+ break
+ }
+ }
+}