summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/table_manager_test.go')
-rw-r--r--table/table_manager_test.go62
1 files changed, 35 insertions, 27 deletions
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index 0cb81b6e..24c506d4 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -41,13 +41,15 @@ func peerR1() *PeerInfo {
AS: 65000,
ID: net.ParseIP("10.0.0.3").To4(),
LocalID: net.ParseIP("10.0.0.1").To4(),
+ Address: net.ParseIP("10.0.0.1").To4(),
}
return peer
}
func peerR2() *PeerInfo {
peer := &PeerInfo{
- AS: 65100,
+ AS: 65100,
+ Address: net.ParseIP("10.0.0.2").To4(),
}
return peer
}
@@ -57,6 +59,7 @@ func peerR3() *PeerInfo {
AS: 65000,
ID: net.ParseIP("10.0.0.2").To4(),
LocalID: net.ParseIP("10.0.0.1").To4(),
+ Address: net.ParseIP("10.0.0.3").To4(),
}
return peer
}
@@ -64,7 +67,7 @@ func peerR3() *PeerInfo {
// test best path calculation and check the result path is from R1
func TestProcessBGPUpdate_0_select_onlypath_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_0_select_onlypath_ipv4")
bgpMessage := update_fromR1()
peer := peerR1()
@@ -115,7 +118,7 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv4(t *testing.T) {
// test best path calculation and check the result path is from R1
func TestProcessBGPUpdate_0_select_onlypath_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_0_select_onlypath_ipv6")
bgpMessage := update_fromR1_ipv6()
peer := peerR1()
@@ -167,7 +170,7 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv6(t *testing.T) {
// test: compare localpref
func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_1_select_high_localpref_ipv4")
var err error
// low localpref message
@@ -251,7 +254,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_1_select_high_localpref_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -339,7 +342,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
// test: compare localOrigin
func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_2_select_local_origin_ipv4")
var err error
// low localpref message
@@ -376,7 +379,9 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
assert.Equal(t, 0, len(wList))
assert.NoError(t, err)
- var peer2 *PeerInfo = nil
+ var peer2 *PeerInfo = &PeerInfo{
+ Address: net.ParseIP("0.0.0.0"),
+ }
pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
assert.Equal(t, 0, len(wList))
@@ -423,7 +428,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_2_select_local_origin_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -462,7 +467,10 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
assert.Equal(t, 0, len(wList))
assert.NoError(t, err)
- var peer2 *PeerInfo = nil
+ var peer2 *PeerInfo = &PeerInfo{
+ Address: net.ParseIP("0.0.0.0"),
+ }
+
pList, wList, err = tm.ProcessUpdate(peer2, bgpMessage2)
assert.Equal(t, 1, len(pList))
assert.Equal(t, 0, len(wList))
@@ -511,7 +519,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
// test: compare AS_PATH
func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_3_select_aspath_ipv4")
var err error
bgpMessage1 := update_fromR2viaR1()
@@ -568,7 +576,7 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_3_select_aspath_ipv6")
var err error
bgpMessage1 := update_fromR2viaR1_ipv6()
@@ -627,7 +635,7 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
// test: compare Origin
func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_4_select_low_origin_ipv4")
var err error
// low origin message
@@ -711,7 +719,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_4_select_low_origin_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(1)
@@ -799,7 +807,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
// test: compare MED
func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_5_select_low_med_ipv4")
var err error
// low origin message
@@ -883,7 +891,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_5_select_low_med_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -971,7 +979,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
// test: compare AS_NUMBER(prefer eBGP path)
func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_6_select_ebgp_path_ipv4")
tm.localAsn = uint32(65000)
var err error
@@ -1057,7 +1065,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_6_select_ebgp_path_ipv6")
tm.localAsn = uint32(65000)
var err error
@@ -1148,7 +1156,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
// test: compare Router ID
func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_7_select_low_routerid_path_ipv4")
tm.localAsn = uint32(65000)
var err error
@@ -1234,7 +1242,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_7_select_low_routerid_path_ipv6")
tm.localAsn = uint32(65000)
var err error
@@ -1323,7 +1331,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
// test: withdraw and mpunreach path
func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_8_withdraw_path_ipv4")
//setLogger(getLogger(log.DebugLevel))
var err error
@@ -1432,7 +1440,7 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
// TODO MP_UNREACH
func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_8_mpunreach_path_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -1568,7 +1576,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
// handle bestpath lost
func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_bestpath_lost_ipv4")
//setLogger(getLogger(log.DebugLevel))
var err error
@@ -1641,7 +1649,7 @@ func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_bestpath_lost_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -1717,7 +1725,7 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
// test: implicit withdrawal case
func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_implicit_withdrwal_ipv4")
//setLogger(getLogger(log.DebugLevel))
var err error
@@ -1803,7 +1811,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_implicit_withdrwal_ipv6")
var err error
origin1 := bgp.NewPathAttributeOrigin(0)
@@ -1916,7 +1924,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
// check multiple paths
func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_multiple_nlri_ipv4")
//setLogger(getLogger(log.DebugLevel))
var err error
@@ -2046,7 +2054,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
// check multiple paths
func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
- tm := NewTableManager()
+ tm := NewTableManager("TestProcessBGPUpdate_multiple_nlri_ipv6")
//setLogger(getLogger(log.DebugLevel))
var err error