From 73211b7ea687c4d22706e5e78d5c2c66d1832c69 Mon Sep 17 00:00:00 2001 From: Prakash M Bailkeri Date: Fri, 22 Jan 2016 15:47:05 +0530 Subject: [PATCH] Introspect support for route aggregation Enhanced UT cases to invoke route-aggregation introspect Change-Id: Ib244faf3b30323c5b032fd4f079410e94da3ce81 Related-bug: #1500698 --- src/bgp/bgp_config.cc | 8 +- src/bgp/bgp_show_config.cc | 2 +- src/bgp/routing-instance/SConscript | 3 + src/bgp/routing-instance/iroute_aggregator.h | 5 + src/bgp/routing-instance/route_aggregate.cc | 43 ++++++ src/bgp/routing-instance/route_aggregate.h | 3 + .../routing-instance/route_aggregate.sandesh | 29 ++++ .../route_aggregate_internal.sandesh | 6 + .../routing-instance/show_route_aggregate.cc | 129 ++++++++++++++++++ src/bgp/test/route_aggregation_test.cc | 127 ++++++++++++++++- 10 files changed, 349 insertions(+), 6 deletions(-) create mode 100644 src/bgp/routing-instance/route_aggregate.sandesh create mode 100644 src/bgp/routing-instance/route_aggregate_internal.sandesh create mode 100644 src/bgp/routing-instance/show_route_aggregate.cc diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index 11337043bec..23d170bcabc 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -341,7 +341,7 @@ std::string RoutingPolicyMatchConfig::ToString() const { return oss.str(); } -static void PutCommunityMatch(ostringstream &oss, const CommunityList &list) { +static void PutCommunityList(ostringstream &oss, const CommunityList &list) { copy(list.begin(), list.end(), ostream_iterator(oss,",")); oss.seekp(-1, oss.cur); } @@ -351,17 +351,17 @@ string RoutingPolicyActionConfig::ToString() const { oss << "then {" << std::endl; if (!update.community_set.empty()) { oss << " community set [ "; - PutCommunityMatch(oss, update.community_set); + PutCommunityList(oss, update.community_set); oss << " ]" << std::endl; } if (!update.community_add.empty()) { oss << " community add [ "; - PutCommunityMatch(oss, update.community_add); + PutCommunityList(oss, update.community_add); oss << " ]" << std::endl; } if (!update.community_remove.empty()) { oss << " community remove [ "; - PutCommunityMatch(oss, update.community_remove); + PutCommunityList(oss, update.community_remove); oss << " ]" << std::endl; } if (update.local_pref) { diff --git a/src/bgp/bgp_show_config.cc b/src/bgp/bgp_show_config.cc index 9056ec6b7a0..1c283ce9ac7 100644 --- a/src/bgp/bgp_show_config.cc +++ b/src/bgp/bgp_show_config.cc @@ -245,7 +245,7 @@ bool BgpShowHandler::set_aggregate_route(BgpRoute *aggregate) { aggregate_route_ = aggregate; } +template +void AggregateRoute::FillShowInfo(AggregateRouteInfo *info) const { + BgpTable *table = bgp_table(); + info->set_deleted(deleted()); + info->set_prefix(aggregate_route_prefix_.ToString()); + if (aggregate_route_) { + ShowRouteBrief show_route; + aggregate_route_->FillRouteInfo(table, &show_route); + info->set_aggregate_rt(show_route); + } + + info->set_nexthop(nexthop_.to_string()); + + std::vector contributor_list; + BOOST_FOREACH(const RouteList &list, contribute_route_list()) { + BOOST_FOREACH(BgpRoute *rt, list) { + contributor_list.push_back(rt->ToString()); + } + } + info->set_contributors(contributor_list); +} + template class RouteAggregator::DeleteActor : public LifetimeActor { public: @@ -672,6 +697,24 @@ bool RouteAggregator::IsContributingRoute(const BgpRoute *route) const { return false; } +template +bool RouteAggregator::FillAggregateRouteInfo(RoutingInstance *ri, + AggregateRouteEntriesInfo *info) const { + if (aggregate_route_map().empty()) return false; + + info->set_ri_name(ri->name()); + + for (typename AggregateRouteMap::const_iterator it = aggregate_route_map_.begin(); + it != aggregate_route_map_.end(); it++) { + AggregateRouteT *aggregate = + static_cast(it->second.get()); + AggregateRouteInfo aggregate_info; + aggregate->FillShowInfo(&aggregate_info); + info->aggregate_route_list.push_back(aggregate_info); + } + return true; +} + template void RouteAggregator::LocateAggregateRoutePrefix(const AggregateRouteConfig &cfg) { diff --git a/src/bgp/routing-instance/route_aggregate.h b/src/bgp/routing-instance/route_aggregate.h index 6c59cff9c37..43cffb9a648 100644 --- a/src/bgp/routing-instance/route_aggregate.h +++ b/src/bgp/routing-instance/route_aggregate.h @@ -198,6 +198,9 @@ class RouteAggregator : public IRouteAggregator { virtual bool IsAggregateRoute(const BgpRoute *route) const; virtual bool IsContributingRoute(const BgpRoute *route) const; + virtual bool FillAggregateRouteInfo(RoutingInstance *ri, + AggregateRouteEntriesInfo *info) const; + private: friend class RouteAggregationTest; class DeleteActor; diff --git a/src/bgp/routing-instance/route_aggregate.sandesh b/src/bgp/routing-instance/route_aggregate.sandesh new file mode 100644 index 00000000000..31e2b7c83da --- /dev/null +++ b/src/bgp/routing-instance/route_aggregate.sandesh @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. + */ + +include "bgp/bgp_peer.sandesh" +include "bgp/routing-instance/route_aggregate_internal.sandesh" + +struct AggregateRouteInfo { + 1: string prefix; + 2: bgp_peer.ShowRouteBrief aggregate_rt; + 3: string nexthop; + 4: list contributors; + 5: bool deleted; +} + +struct AggregateRouteEntriesInfo { + 1: string ri_name; + 2: list aggregate_route_list; +} + +response sandesh ShowRouteAggregateResp { + 1: list aggregate_route_entries; + 2: optional string next_batch (link="ShowRouteAggregateReqIterate", + link_title="next_batch"); +} + +request sandesh ShowRouteAggregateReq { + 1: string search_string; +} diff --git a/src/bgp/routing-instance/route_aggregate_internal.sandesh b/src/bgp/routing-instance/route_aggregate_internal.sandesh new file mode 100644 index 00000000000..c95766b524a --- /dev/null +++ b/src/bgp/routing-instance/route_aggregate_internal.sandesh @@ -0,0 +1,6 @@ +/* + * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. + */ +request sandesh ShowRouteAggregateReqIterate { + 1: string iterate_info; +} diff --git a/src/bgp/routing-instance/show_route_aggregate.cc b/src/bgp/routing-instance/show_route_aggregate.cc new file mode 100644 index 00000000000..3f3d5137ae1 --- /dev/null +++ b/src/bgp/routing-instance/show_route_aggregate.cc @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. + */ + +#include "bgp/bgp_show_handler.h" + + +#include "bgp/bgp_show_handler.h" +#include "bgp/routing-instance/routing_instance.h" +#include "bgp/routing-instance/route_aggregate.h" +#include "bgp/routing-instance/route_aggregate_types.h" + +using std::string; +using std::vector; + +static bool FillRouteAggregateInfo(Address::Family family, + const string search_string, + AggregateRouteEntriesInfo &info, + RoutingInstance *rtinstance) { + const BgpTable *table = + static_cast(rtinstance->GetTable(family)); + if (!table) + return false; + if (!search_string.empty() && + (table->name().find(search_string) == string::npos) && + (search_string != "deleted" || !table->IsDeleted())) { + return false; + } + + IRouteAggregator *iroute_aggregator = rtinstance->route_aggregator(family); + if (!iroute_aggregator) + return false; + return iroute_aggregator->FillAggregateRouteInfo(rtinstance, &info); +} + +// Specialization of BgpShowHandler<>::CallbackCommon. +template <> +bool BgpShowHandler::CallbackCommon( + const BgpSandeshContext *bsc, Data *data) { + uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit; + uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit; + RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr(); + + RoutingInstanceMgr::const_name_iterator it = + rim->name_clower_bound(data->next_entry); + AggregateRouteEntriesInfo info; + for (uint32_t iter_count = 0; it != rim->name_cend(); ++it, ++iter_count) { + RoutingInstance *rinstance = it->second; + if (FillRouteAggregateInfo(Address::INET, data->search_string, info, + rinstance)) { + data->show_list.push_back(info); + } + if (FillRouteAggregateInfo(Address::INET6, data->search_string, info, + rinstance)) { + data->show_list.push_back(info); + } + + if (data->show_list.size() >= page_limit) + break; + if (iter_count >= iter_limit) + break; + } + + // All done if we've looked at all instances. + if (it == rim->name_cend() || ++it == rim->name_cend()) + return true; + + // Return true if we've reached the page limit, false if we've reached the + // iteration limit. + bool done = data->show_list.size() >= page_limit; + SaveContextToData(it->second->name(), done, data); + return done; +} + +// Specialization of BgpShowHandler<>::FillShowList. +template <> +void BgpShowHandler::FillShowList( + ShowRouteAggregateResp *resp, + const vector &show_list) { + resp->set_aggregate_route_entries(show_list); +} + +// Handler for ShowRouteAggregateReq. +void ShowRouteAggregateReq::HandleRequest() const { + RequestPipeline::PipeSpec ps(this); + RequestPipeline::StageSpec s1; + TaskScheduler *scheduler = TaskScheduler::GetInstance(); + + s1.taskId_ = scheduler->GetTaskId("bgp::RouteAggregate"); + s1.cbFn_ = boost::bind(&BgpShowHandler< + ShowRouteAggregateReq, + ShowRouteAggregateReqIterate, + ShowRouteAggregateResp, + AggregateRouteEntriesInfo>::Callback, _1, _2, _3, _4, _5); + s1.allocFn_ = BgpShowHandler< + ShowRouteAggregateReq, + ShowRouteAggregateReqIterate, + ShowRouteAggregateResp, + AggregateRouteEntriesInfo>::CreateData; + s1.instances_.push_back(0); + ps.stages_.push_back(s1); + RequestPipeline rp(ps); +} + +// +// Handler for ShowRouteAggregateReqIterate. +// +void ShowRouteAggregateReqIterate::HandleRequest() const { + RequestPipeline::PipeSpec ps(this); + RequestPipeline::StageSpec s1; + TaskScheduler *scheduler = TaskScheduler::GetInstance(); + + s1.taskId_ = scheduler->GetTaskId("bgp::RouteAggregate"); + s1.cbFn_ = boost::bind(&BgpShowHandler< + ShowRouteAggregateReq, + ShowRouteAggregateReqIterate, + ShowRouteAggregateResp, + AggregateRouteEntriesInfo>::CallbackIterate, _1, _2, _3, _4, _5); + s1.allocFn_ = BgpShowHandler< + ShowRouteAggregateReq, + ShowRouteAggregateReqIterate, + ShowRouteAggregateResp, + AggregateRouteEntriesInfo>::CreateData; + s1.instances_.push_back(0); + ps.stages_.push_back(s1); + RequestPipeline rp(ps); +} diff --git a/src/bgp/test/route_aggregation_test.cc b/src/bgp/test/route_aggregation_test.cc index 968b63ced4c..a29c4b148d8 100644 --- a/src/bgp/test/route_aggregation_test.cc +++ b/src/bgp/test/route_aggregation_test.cc @@ -12,11 +12,13 @@ #include "bgp/bgp_config_ifmap.h" #include "bgp/bgp_config_parser.h" #include "bgp/bgp_factory.h" +#include "bgp/bgp_sandesh.h" #include "bgp/inet/inet_table.h" #include "bgp/inet6/inet6_table.h" #include "bgp/l3vpn/inetvpn_table.h" #include "bgp/origin-vn/origin_vn.h" #include "bgp/routing-instance/rtarget_group_mgr.h" +#include "bgp/routing-instance/route_aggregate_types.h" #include "bgp/test/bgp_server_test_util.h" #include "bgp/test/bgp_test_util.h" #include "control-node/control_node.h" @@ -118,7 +120,8 @@ static const char *bgp_server_config = "\ class RouteAggregationTest : public ::testing::Test { protected: RouteAggregationTest() : bgp_server_(new BgpServer(&evm_)), - parser_(&config_db_) { + parser_(&config_db_), + validate_done_(false) { IFMapLinkTable_Init(&config_db_, &config_graph_); vnc_cfg_Server_ModuleInit(&config_db_, &config_graph_); bgp_schema_Server_ModuleInit(&config_db_, &config_graph_); @@ -362,12 +365,48 @@ class RouteAggregationTest : public ::testing::Test { return list; } + static void ValidateShowRouteAggregationResponse(Sandesh *sandesh, + string &result, RouteAggregationTest *self, bool empty) { + ShowRouteAggregateResp *resp = + dynamic_cast(sandesh); + TASK_UTIL_EXPECT_NE((ShowRouteAggregateResp *)NULL, resp); + self->validate_done_ = true; + + if (empty) + TASK_UTIL_EXPECT_EQ(0, resp->get_aggregate_route_entries().size()); + else + TASK_UTIL_EXPECT_EQ(1, resp->get_aggregate_route_entries().size()); + int i = 0; + BOOST_FOREACH(const AggregateRouteEntriesInfo &info, + resp->get_aggregate_route_entries()) { + TASK_UTIL_EXPECT_EQ(info.get_ri_name(), result); + i++; + } + } + + void VerifyRouteAggregateSandesh(std::string ri_name, bool empty=false) { + BgpSandeshContext sandesh_context; + sandesh_context.bgp_server = bgp_server_.get(); + sandesh_context.xmpp_peer_manager = NULL; + Sandesh::set_client_context(&sandesh_context); + Sandesh::set_response_callback( + boost::bind(ValidateShowRouteAggregationResponse, _1, ri_name, + this, empty)); + ShowRouteAggregateReq *req = new ShowRouteAggregateReq; + req->set_search_string(ri_name); + validate_done_ = false; + req->HandleRequest(); + req->Release(); + TASK_UTIL_EXPECT_EQ(true, validate_done_); + } + EventManager evm_; DB config_db_; DBGraph config_graph_; boost::scoped_ptr bgp_server_; vector peers_; BgpConfigParser parser_; + bool validate_done_; }; // @@ -404,6 +443,9 @@ TEST_F(RouteAggregationTest, Basic) { "test.inet.0", "2.2.1.1/32")); TASK_UTIL_EXPECT_FALSE(IsContributingRoute("test", "test.inet.0", "1.1.1.1/32")); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "1.1.1.1/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); task_util::WaitForIdle(); @@ -442,6 +484,9 @@ TEST_F(RouteAggregationTest, Basic_0) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + TASK_UTIL_EXPECT_TRUE(IsAggregateRoute("test", "test.inet.0", "2.2.0.0/16")); TASK_UTIL_EXPECT_FALSE(IsAggregateRoute("test", @@ -604,6 +649,9 @@ TEST_F(RouteAggregationTest, Basic_MultipleAggregatePrefix) { TASK_UTIL_EXPECT_EQ(rt->count(), 1); TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "3.3.0.1/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.0.1/32"); task_util::WaitForIdle(); @@ -639,6 +687,9 @@ TEST_F(RouteAggregationTest, Basic_ErrConfig_DiffFamily) { TASK_UTIL_EXPECT_EQ(rt->count(), 1); TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + // Verify that inet6 route aggregation is not done VERIFY_EQ(1, RouteCount("test.inet6.0")); @@ -728,10 +779,14 @@ TEST_F(RouteAggregationTest, Basic_DeleteNexthop) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible() == false); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); task_util::WaitForIdle(); VERIFY_EQ(0, RouteCount("test.inet.0")); + rt = RouteLookup("test.inet.0", "2.2.0.0/16"); ASSERT_TRUE(rt == NULL); } @@ -764,6 +819,9 @@ TEST_F(RouteAggregationTest, Basic_MoreSpecificDelete) { DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); task_util::WaitForIdle(); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + VERIFY_EQ(1, RouteCount("test.inet.0")); rt = RouteLookup("test.inet.0", "2.2.0.0/16"); ASSERT_TRUE(rt == NULL); @@ -809,14 +867,23 @@ TEST_F(RouteAggregationTest, Basic_LastMoreSpecificDelete) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "2.2.2.1/32"); task_util::WaitForIdle(); VERIFY_EQ(3, RouteCount("test.inet.0")); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "2.2.3.1/32"); task_util::WaitForIdle(); VERIFY_EQ(1, RouteCount("test.inet.0")); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "1.1.1.1/32"); task_util::WaitForIdle(); } @@ -846,6 +913,9 @@ TEST_F(RouteAggregationTest, ConfigDelete) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + // Unlink the route aggregate config from vrf ifmap_test_util::IFMapMsgUnlink(&config_db_, "routing-instance", "test", "route-aggregate", "vn_subnet", "route-aggregate-routing-instance"); @@ -885,6 +955,9 @@ TEST_F(RouteAggregationTest, ConfigUpdatePrefix) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + content = FileRead("controller/src/bgp/testdata/route_aggregate_0b.xml"); EXPECT_TRUE(parser_.Parse(content)); task_util::WaitForIdle(); @@ -902,6 +975,9 @@ TEST_F(RouteAggregationTest, ConfigUpdatePrefix) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "1.1.1.254/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); DeleteRoute(peers_[0], "test.inet.0", "3.3.1.1/32"); @@ -989,10 +1065,15 @@ TEST_F(RouteAggregationTest, ConfigDelete_Add) { "route-aggregate", "vn_subnet", "route-aggregate-routing-instance"); task_util::WaitForIdle(); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + // Link the route aggregate config from vrf ifmap_test_util::IFMapMsgLink(&config_db_, "routing-instance", "test", "route-aggregate", "vn_subnet", "route-aggregate-routing-instance"); task_util::WaitForIdle(); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); EnableUnregResolveTask("test", Address::INET); TASK_UTIL_EXPECT_EQ(GetUnregResolveListSize("test", Address::INET), 0); @@ -1004,6 +1085,8 @@ TEST_F(RouteAggregationTest, ConfigDelete_Add) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); DeleteRoute(peers_[0], "test.inet.0", "1.1.1.254/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); task_util::WaitForIdle(); @@ -1205,6 +1288,9 @@ TEST_F(RouteAggregationTest, OverlappingPrefixes) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "2.2.2.1/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.2.2/32"); task_util::WaitForIdle(); @@ -1233,6 +1319,9 @@ TEST_F(RouteAggregationTest, ConfigUpdate_OverlappingPrefixes) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + content = FileRead("controller/src/bgp/testdata/route_aggregate_3c.xml"); EXPECT_TRUE(parser_.Parse(content)); task_util::WaitForIdle(); @@ -1255,6 +1344,8 @@ TEST_F(RouteAggregationTest, ConfigUpdate_OverlappingPrefixes) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); DeleteRoute(peers_[0], "test.inet.0", "2.2.2.1/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.2.2/32"); @@ -1297,6 +1388,8 @@ TEST_F(RouteAggregationTest, ConfigUpdate_RemoveOverlappingPrefixes) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); ifmap_test_util::IFMapMsgUnlink(&config_db_, "routing-instance", "test", "route-aggregate", "vn_subnet_1", "routing-instance-route-aggregate"); @@ -1319,6 +1412,9 @@ TEST_F(RouteAggregationTest, ConfigUpdate_RemoveOverlappingPrefixes) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "2.2.2.1/32"); DeleteRoute(peers_[0], "test.inet.0", "2.2.2.2/32"); task_util::WaitForIdle(); @@ -1348,6 +1444,9 @@ TEST_F(RouteAggregationTest, ConfigUpdate_UpdateExisting_1) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); + content = FileRead("controller/src/bgp/testdata/route_aggregate_3a.xml"); EXPECT_TRUE(parser_.Parse(content)); task_util::WaitForIdle(); @@ -1375,6 +1474,8 @@ TEST_F(RouteAggregationTest, ConfigUpdate_UpdateExisting_1) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test"); DeleteRoute(peers_[0], "test.inet.0", "4.3.2.1/32"); DeleteRoute(peers_[0], "test.inet.0", "3.3.0.1/32"); DeleteRoute(peers_[0], "test.inet.0", "1.1.1.1/32"); @@ -1475,6 +1576,9 @@ TEST_F(RouteAggregationTest, ConfigUpdatePrefix_MultipleInstanceRef) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + // Verify the sandesh + VerifyRouteAggregateSandesh("test_0"); + VerifyRouteAggregateSandesh("test_1"); content = FileRead("controller/src/bgp/testdata/route_aggregate_2a.xml"); EXPECT_TRUE(parser_.Parse(content)); task_util::WaitForIdle(); @@ -1503,6 +1607,9 @@ TEST_F(RouteAggregationTest, ConfigUpdatePrefix_MultipleInstanceRef) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + VerifyRouteAggregateSandesh("test_0"); + VerifyRouteAggregateSandesh("test_1"); + DeleteRoute(peers_[0], "test_0.inet.0", "1.1.1.1/32"); DeleteRoute(peers_[0], "test_0.inet.0", "2.2.1.1/32"); DeleteRoute(peers_[0], "test_0.inet.0", "3.3.0.1/32"); @@ -1543,6 +1650,8 @@ TEST_F(RouteAggregationTest, MultipleRoutes_DifferentPartition) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet.0", "1.1.1.1/32"); for (int i = 0; i < 255; i++) { ostringstream oss; @@ -1575,12 +1684,15 @@ TEST_F(RouteAggregationTest, ConfigDelete_DelayedRouteProcessing) { AddRoute(peers_[0], "test.inet.0", "2.2.1.1/32", 100); task_util::WaitForIdle(); + VerifyRouteAggregateSandesh("test"); + // Unlink the route aggregate config from vrf ifmap_test_util::IFMapMsgUnlink(&config_db_, "routing-instance", "test", "route-aggregate", "vn_subnet", "route-aggregate-routing-instance"); task_util::WaitForIdle(); TASK_UTIL_EXPECT_EQ(GetUnregResolveListSize("test", Address::INET), 0); + VerifyRouteAggregateSandesh("test", true); EnableRouteAggregateUpdate("test", Address::INET); TASK_UTIL_EXPECT_EQ(GetUpdateAggregateListSize("test", Address::INET), 0); @@ -1620,12 +1732,16 @@ TEST_F(RouteAggregationTest, ConfigDelete_DelayedRouteProcessing_1) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + VerifyRouteAggregateSandesh("test"); + DisableRouteAggregateUpdate("test", Address::INET); // Unlink the route aggregate config from vrf ifmap_test_util::IFMapMsgUnlink(&config_db_, "routing-instance", "test", "route-aggregate", "vn_subnet", "route-aggregate-routing-instance"); task_util::WaitForIdle(); + VerifyRouteAggregateSandesh("test", true); + EnableRouteAggregateUpdate("test", Address::INET); TASK_UTIL_EXPECT_EQ(GetUpdateAggregateListSize("test", Address::INET), 0); @@ -1667,6 +1783,8 @@ TEST_F(RouteAggregationTest, ConfigDelete_DelayedRouteProcessing_2) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + VerifyRouteAggregateSandesh("test"); + DisableRouteAggregateUpdate("test", Address::INET); DeleteRoute(peers_[0], "test.inet.0", "2.2.1.1/32"); @@ -1681,12 +1799,17 @@ TEST_F(RouteAggregationTest, ConfigDelete_DelayedRouteProcessing_2) { TASK_UTIL_EXPECT_TRUE(rti->route_aggregator(Address::INET6) == NULL); TASK_UTIL_EXPECT_TRUE(rti->route_aggregator(Address::INET) != NULL); + VerifyRouteAggregateSandesh("test", true); + EnableRouteAggregateUpdate("test", Address::INET); TASK_UTIL_EXPECT_TRUE(bgp_server_->database()->FindTable("test.inet.0") == NULL); + TASK_UTIL_EXPECT_TRUE( bgp_server_->routing_instance_mgr()->GetRoutingInstance("test") == NULL); + + VerifyRouteAggregateSandesh("test", true); } // @@ -1718,6 +1841,8 @@ TEST_F(RouteAggregationTest, BasicInet6) { TASK_UTIL_EXPECT_TRUE(rt->BestPath() != NULL); TASK_UTIL_EXPECT_TRUE(rt->BestPath()->IsFeasible()); + VerifyRouteAggregateSandesh("test"); + DeleteRoute(peers_[0], "test.inet6.0", "2001:db8:85a3::8a2e:370:7334/128"); DeleteRoute(peers_[0], "test.inet6.0",