From 29412028a7ab41fd953a0ea5cc87a728b212ab17 Mon Sep 17 00:00:00 2001 From: mageshgv Date: Wed, 16 Oct 2019 15:18:38 -0700 Subject: Fix adj-out display with add path enabled --- internal/pkg/table/adj_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/pkg/table/adj_test.go') 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)} -- cgit v1.2.3