summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/adj_test.go
diff options
context:
space:
mode:
authormageshgv <mageshgv@gmail.com>2019-10-16 15:18:38 -0700
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-18 07:28:10 +0900
commit29412028a7ab41fd953a0ea5cc87a728b212ab17 (patch)
tree1c4bf290cac55484119820373f331967fc06eb61 /internal/pkg/table/adj_test.go
parent0794811562fdad2affbf48200b88e36cad88a578 (diff)
Fix adj-out display with add path enabled
Diffstat (limited to 'internal/pkg/table/adj_test.go')
-rw-r--r--internal/pkg/table/adj_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/pkg/table/adj_test.go b/internal/pkg/table/adj_test.go
index 9e48538f..99aba0ff 100644
--- a/internal/pkg/table/adj_test.go
+++ b/internal/pkg/table/adj_test.go
@@ -61,6 +61,35 @@ func TestAddPath(t *testing.T) {
assert.Equal(t, 0, len(adj.table[family].destinations))
}
+func TestAddPathAdjOut(t *testing.T) {
+ pi := &PeerInfo{}
+ attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}
+
+ nlri1 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
+ nlri1.SetPathIdentifier(1)
+ nlri1.SetPathLocalIdentifier(1)
+ p1 := NewPath(pi, nlri1, false, attrs, time.Now(), false)
+ nlri2 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
+ nlri2.SetPathIdentifier(1)
+ nlri2.SetPathLocalIdentifier(2)
+ p2 := NewPath(pi, nlri2, false, attrs, time.Now(), false)
+ nlri3 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
+ nlri3.SetPathIdentifier(2)
+ nlri3.SetPathLocalIdentifier(2)
+ p3 := NewPath(pi, nlri3, false, attrs, time.Now(), false)
+ nlri4 := bgp.NewIPAddrPrefix(24, "20.20.20.0")
+ nlri4.SetPathIdentifier(3)
+ nlri4.SetPathLocalIdentifier(2)
+ p4 := NewPath(pi, nlri4, false, attrs, time.Now(), false)
+ family := p1.GetRouteFamily()
+ families := []bgp.RouteFamily{family}
+
+ adj := NewAdjRib(families)
+ adj.UpdateAdjRibOut([]*Path{p1, p2, p3, p4})
+ assert.Equal(t, len(adj.table[family].destinations), 1)
+ assert.Equal(t, adj.Count([]bgp.RouteFamily{family}), 2)
+}
+
func TestStale(t *testing.T) {
pi := &PeerInfo{}
attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}