Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs committed Jan 21, 2025
1 parent eea6cfa commit 5a7da1f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/mock_tests/routeorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ namespace routeorch_test
{"mac_addr", "00:00:00:00:00:00" }});
intfTable.set("Ethernet4:11.0.0.1/32", { { "scope", "global" },
{ "family", "IPv4" }});
intfTable.set("Ethernet8", { {"NULL", "NULL" },
{"vrf_name", "Vrf1"},
{"mac_addr", "00:00:00:00:00:00" }});
intfTable.set("Ethernet8:20.0.0.1/24", { { "scope", "global" },
{ "family", "IPv4" }});
gIntfsOrch->addExistingData(&intfTable);
static_cast<Orch *>(gIntfsOrch)->doTask();

Expand Down Expand Up @@ -552,4 +557,30 @@ namespace routeorch_test
ASSERT_EQ(current_create_count, create_route_count);
ASSERT_EQ(current_set_count, set_route_count);
}

TEST_F(RouteOrchTest, RouteOrchTestVrfRoute)
{
std::deque<KeyOpFieldsValuesTuple> entries;
entries.push_back({"Vrf2", "SET", { {"vni", "500200"}}});
auto vrfConsumer = dynamic_cast<Consumer *>(gVrfOrch->getExecutor(APP_VRF_TABLE_NAME));
vrfConsumer->addToSync(entries);
static_cast<Orch *>(gVrfOrch)->doTask();
entries.clear();
entries.push_back({"Ethernet8", "SET", { {"vrf_name", "Vrf2"}}});
auto intfConsumer = dynamic_cast<Consumer *>(gIntfsOrch->getExecutor(APP_INTF_TABLE_NAME));
intfConsumer->addToSync(entries);
static_cast<Orch *>(gIntfsOrch)->doTask();
auto routeConsumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
entries.clear();
entries.push_back({"Vrf2:fe80::/64", "DEL", {}});
entries.push_back({"Vrf2:20.0.0.0/24", "DEL", {}});
entries.push_back({"Vrf2:fe80::/64", "SET", { {"protocol", "kernel"},
{"nexthop", "::"},
{"ifname", "Ethernet8"}}});
entries.push_back({"Vrf2:20.0.0.0/24", "SET", { {"protocol", "kernel"},
{"nexthop", "0.0.0.0"},
{"ifname", "Ethernet8"}}});
routeConsumer->addToSync(entries);
static_cast<Orch *>(gRouteOrch)->doTask();
}
}

0 comments on commit 5a7da1f

Please sign in to comment.