From e482bdd44735e7912002eb4fee6e8a5740bee97a Mon Sep 17 00:00:00 2001
From: Maximilian Wilhelm <max@sdn.clinic>
Date: Wed, 4 Jul 2018 17:12:16 +0200
Subject: [PATCH] Add test case for reflecting already reflected route.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
---
 routingtable/adjRIBOut/adj_rib_out_test.go | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/routingtable/adjRIBOut/adj_rib_out_test.go b/routingtable/adjRIBOut/adj_rib_out_test.go
index 87e1f854..26eceeee 100644
--- a/routingtable/adjRIBOut/adj_rib_out_test.go
+++ b/routingtable/adjRIBOut/adj_rib_out_test.go
@@ -776,6 +776,72 @@ func TestBestPathOnlyRRClient(t *testing.T) {
 			},
 			expectedCount: 1,
 		},
+		{
+			name: "Remove NO_EXPORT route added before",
+			routesRemove: []*route.Route{
+				route.NewRoute(net.NewPfx(net.IPv4FromOctets(10, 0, 0, 0), 8), &route.Path{
+					Type: route.BGPPathType,
+					BGPPath: &route.BGPPath{
+						ASPath:    types.ASPath{},
+						ASPathLen: 0,
+						Origin:    0,
+						MED:       0,
+						EBGP:      false,
+						Communities: []uint32{
+							types.WellKnownCommunityNoExport,
+						},
+						LargeCommunities:  []types.LargeCommunity{},
+						UnknownAttributes: nil,
+						PathIdentifier:    0,
+						LocalPref:         0,
+						Source:            net.IP{},
+						ClusterList: []uint32{
+							neighborBestOnlyRR.ClusterID,
+						},
+					},
+				}),
+			},
+			expected:      []*route.Route{},
+			expectedCount: 0,
+		},
+		{
+			name: "Add route with one entry in ClusterList and OriginatorID set (with success)",
+			routesAdd: []*route.Route{
+				route.NewRoute(net.NewPfx(net.IPv4FromOctets(10, 0, 0, 0), 8), &route.Path{
+					Type: route.BGPPathType,
+					BGPPath: &route.BGPPath{
+						OriginatorID: 42,
+						ClusterList: []uint32{
+							23,
+						},
+					},
+				}),
+			},
+			expected: []*route.Route{
+				route.NewRoute(net.NewPfx(net.IPv4FromOctets(10, 0, 0, 0), 8), &route.Path{
+					Type: route.BGPPathType,
+					BGPPath: &route.BGPPath{
+						ASPath:            types.ASPath{},
+						ASPathLen:         0,
+						Origin:            0,
+						MED:               0,
+						EBGP:              false,
+						Communities:       []uint32{},
+						LargeCommunities:  []types.LargeCommunity{},
+						UnknownAttributes: nil,
+						PathIdentifier:    0,
+						LocalPref:         0,
+						Source:            net.IP{},
+						ClusterList: []uint32{
+							neighborBestOnlyRR.ClusterID,
+							23,
+						},
+						OriginatorID: 42,
+					},
+				}),
+			},
+			expectedCount: 1,
+		},
 	}
 
 	for i, test := range tests {
-- 
GitLab