diff --git a/src/bgp/test/path_resolver_test.cc b/src/bgp/test/path_resolver_test.cc index 879422a94b8..d731da34123 100644 --- a/src/bgp/test/path_resolver_test.cc +++ b/src/bgp/test/path_resolver_test.cc @@ -1510,7 +1510,7 @@ TYPED_TEST(PathResolverTest, SinglePrefixWithEcmp) { // BGP has multiple paths for same prefix, each with a different nexthop. // Add and remove paths for the prefix. // -TYPED_TEST(PathResolverTest, SinglePrefixWithMultipath) { +TYPED_TEST(PathResolverTest, SinglePrefixWithMultipath1) { PeerMock *bgp_peer1 = this->bgp_peer1_; PeerMock *bgp_peer2 = this->bgp_peer2_; PeerMock *xmpp_peer1 = this->xmpp_peer1_; @@ -1571,11 +1571,55 @@ TYPED_TEST(PathResolverTest, SinglePrefixWithMultipath) { this->DeleteBgpPath(bgp_peer2, "blue", this->BuildPrefix(1)); } +// +// BGP has multiple paths for same prefix, each with the same nexthop. +// Add and remove paths for the prefix. +// +TYPED_TEST(PathResolverTest, SinglePrefixWithMultipath2) { + PeerMock *bgp_peer1 = this->bgp_peer1_; + PeerMock *bgp_peer2 = this->bgp_peer2_; + PeerMock *xmpp_peer1 = this->xmpp_peer1_; + + this->AddBgpPath(bgp_peer1, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + this->AddBgpPath(bgp_peer2, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.1"), 10001); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + + this->DeleteBgpPath(bgp_peer1, "blue", this->BuildPrefix(1)); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + + this->DeleteBgpPath(bgp_peer2, "blue", this->BuildPrefix(1)); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1")); + + this->AddBgpPath(bgp_peer1, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + this->AddBgpPath(bgp_peer2, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + + this->DeleteXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32)); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1")); + + this->DeleteBgpPath(bgp_peer1, "blue", this->BuildPrefix(1)); + this->DeleteBgpPath(bgp_peer2, "blue", this->BuildPrefix(1)); +} + // // BGP has multiple paths for same prefix, each with a different nexthop. // XMPP route for the nexthop is ECMP. // -TYPED_TEST(PathResolverTest, SinglePrefixWithMultipathAndEcmp) { +TYPED_TEST(PathResolverTest, SinglePrefixWithMultipathAndEcmp1) { PeerMock *bgp_peer1 = this->bgp_peer1_; PeerMock *bgp_peer2 = this->bgp_peer2_; PeerMock *xmpp_peer1 = this->xmpp_peer1_; @@ -1684,6 +1728,119 @@ TYPED_TEST(PathResolverTest, SinglePrefixWithMultipathAndEcmp) { this->DeleteBgpPath(bgp_peer2, "blue", this->BuildPrefix(1)); } +// +// BGP has multiple paths for same prefix, each with the same nexthop. +// XMPP route for the nexthop is ECMP. +// +TYPED_TEST(PathResolverTest, SinglePrefixWithMultipathAndEcmp2) { + PeerMock *bgp_peer1 = this->bgp_peer1_; + PeerMock *bgp_peer2 = this->bgp_peer2_; + PeerMock *xmpp_peer1 = this->xmpp_peer1_; + PeerMock *xmpp_peer2 = this->xmpp_peer2_; + + this->AddBgpPath(bgp_peer1, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + this->AddBgpPath(bgp_peer2, "blue", this->BuildPrefix(1), + this->BuildHostAddress("192.168.1.100")); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.1"), 10001, + this->BuildNextHopAddress("172.16.2.1")); + this->AddXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.2"), 10002, + this->BuildNextHopAddress("172.16.2.2")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1"), 10001); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2"), 10002); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2"), 10002); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.2.1"), 10001); + this->AddXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.2.2"), 10002); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1"), 10001); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2"), 10002); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.1"), 10001, + this->BuildNextHopAddress("172.16.2.1")); + this->AddXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.2"), 10002, + this->BuildNextHopAddress("172.16.2.2")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1"), 10001); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2"), 10002); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2"), 10002); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.1"), 10001); + this->AddXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.2"), 10002); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10001); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2"), 10002); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2")); + + this->AddXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.1"), 10003, + this->BuildNextHopAddress("172.16.2.1")); + this->AddXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32), + this->BuildNextHopAddress("172.16.1.2"), 10004, + this->BuildNextHopAddress("172.16.2.2")); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1"), 10003); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1"), 10003); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2"), 10004); + this->VerifyPathAttributes("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2"), 10004); + + this->DeleteXmppPath(xmpp_peer1, "blue", + this->BuildPrefix("192.168.1.100", 32)); + this->DeleteXmppPath(xmpp_peer2, "blue", + this->BuildPrefix("192.168.1.100", 32)); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.1")); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.1")); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.1.2")); + this->VerifyPathNoExists("blue", this->BuildPrefix(1), + this->BuildNextHopAddress("172.16.2.2")); + + this->DeleteBgpPath(bgp_peer1, "blue", this->BuildPrefix(1)); + this->DeleteBgpPath(bgp_peer2, "blue", this->BuildPrefix(1)); +} + // // BGP has multiple prefixes, each with the same nexthop. //