Skip to content

Commit

Permalink
Add PathResolver tests for multipath with same nexthop
Browse files Browse the repository at this point in the history
Note that the fix implemented for R3.0 i.e. to copy IPeer from the
original path into the resolved path, is already present in master.

Change-Id: I9df4a50df31aa604fc46ec03b70689f1475decb2
Closes-Bug: 1578504
  • Loading branch information
Nischal Sheth committed May 9, 2016
1 parent 32e3c39 commit 53dc731
Showing 1 changed file with 159 additions and 2 deletions.
161 changes: 159 additions & 2 deletions src/bgp/test/path_resolver_test.cc
Expand Up @@ -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_;
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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.
//
Expand Down

0 comments on commit 53dc731

Please sign in to comment.