summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-02-25 05:34:01 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-02-25 05:34:01 -0800
commit908aab2ca39ae26fa1a7eb9030d30ed52858a748 (patch)
treea65584879fdc1077f62bb46b839bf26c77081772
parent8696863e0852a952375ed9d077169ff7e6abb5f5 (diff)
table: add Path's GetPathAttrs() test
1. clone 2. remote a specific attribute 3. clone and set the above attribute. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--table/path_test.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/table/path_test.go b/table/path_test.go
index 6c71cc05..5f625785 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -2,7 +2,6 @@
package table
import (
- //"fmt"
"fmt"
"testing"
"time"
@@ -17,6 +16,7 @@ func TestPathNewIPv4(t *testing.T) {
ipv4p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false, false)
assert.NotNil(t, ipv4p)
}
+
func TestPathNewIPv6(t *testing.T) {
peerP := PathCreatePeer()
pathP := PathCreatePath(peerP)
@@ -54,6 +54,7 @@ func TestPathGetPrefix(t *testing.T) {
r_prefix := pathP[0].getPrefix()
assert.Equal(t, r_prefix, prefix)
}
+
func TestPathGetAttribute(t *testing.T) {
peerP := PathCreatePeer()
pathP := PathCreatePath(peerP)
@@ -240,6 +241,16 @@ func TestPathPrependAsnToFullPathAttr(t *testing.T) {
fmt.Printf("asns: %v", p.GetAsSeqList())
}
+func TestGetPathAttrs(t *testing.T) {
+ paths := PathCreatePath(PathCreatePeer())
+ path0 := paths[0]
+ path1 := path0.Clone(false)
+ path1.delPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ path2 := path1.Clone(false)
+ path2.setPathAttr(bgp.NewPathAttributeNextHop("192.168.50.1"))
+ assert.NotNil(t, path2.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP))
+}
+
func PathCreatePeer() []*PeerInfo {
peerP1 := &PeerInfo{AS: 65000}
peerP2 := &PeerInfo{AS: 65001}
@@ -300,6 +311,7 @@ func updateMsgP2() *bgp.BGPMessage {
nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "20.20.20.0")}
return bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)
}
+
func updateMsgP3() *bgp.BGPMessage {
origin := bgp.NewPathAttributeOrigin(0)
aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65100})}