|
7 | 7 | #include "ut_helper.h"
|
8 | 8 | #include "mock_orchagent_main.h"
|
9 | 9 | #include "mock_table.h"
|
| 10 | +#include "mock_response_publisher.h" |
10 | 11 | #include "bulker.h"
|
11 | 12 |
|
12 | 13 | extern string gMySwitchType;
|
13 | 14 |
|
| 15 | +extern std::unique_ptr<MockResponsePublisher> gMockResponsePublisher; |
| 16 | + |
| 17 | +using ::testing::_; |
14 | 18 |
|
15 | 19 | namespace routeorch_test
|
16 | 20 | {
|
@@ -282,6 +286,10 @@ namespace routeorch_test
|
282 | 286 | {"mac_addr", "00:00:00:00:00:00" }});
|
283 | 287 | intfTable.set("Ethernet0:10.0.0.1/24", { { "scope", "global" },
|
284 | 288 | { "family", "IPv4" }});
|
| 289 | + intfTable.set("Ethernet4", { {"NULL", "NULL" }, |
| 290 | + {"mac_addr", "00:00:00:00:00:00" }}); |
| 291 | + intfTable.set("Ethernet4:11.0.0.1/32", { { "scope", "global" }, |
| 292 | + { "family", "IPv4" }}); |
285 | 293 | gIntfsOrch->addExistingData(&intfTable);
|
286 | 294 | static_cast<Orch *>(gIntfsOrch)->doTask();
|
287 | 295 |
|
@@ -422,4 +430,58 @@ namespace routeorch_test
|
422 | 430 | ASSERT_EQ(current_set_count + 1, set_route_count);
|
423 | 431 | ASSERT_EQ(sai_fail_count, 0);
|
424 | 432 | }
|
| 433 | + |
| 434 | + TEST_F(RouteOrchTest, RouteOrchTestSetDelResponse) |
| 435 | + { |
| 436 | + gMockResponsePublisher = std::make_unique<MockResponsePublisher>(); |
| 437 | + |
| 438 | + std::deque<KeyOpFieldsValuesTuple> entries; |
| 439 | + std::string key = "2.2.2.0/24"; |
| 440 | + std::vector<FieldValueTuple> fvs{{"ifname", "Ethernet0,Ethernet0"}, {"nexthop", "10.0.0.2,10.0.0.3"}, {"protocol", "bgp"}}; |
| 441 | + entries.push_back({key, "SET", fvs}); |
| 442 | + |
| 443 | + auto consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME)); |
| 444 | + consumer->addToSync(entries); |
| 445 | + |
| 446 | + EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1); |
| 447 | + static_cast<Orch *>(gRouteOrch)->doTask(); |
| 448 | + |
| 449 | + // add entries again to the consumer queue (in case of rapid DEL/SET operations from fpmsyncd, routeorch just gets the last SET update) |
| 450 | + consumer->addToSync(entries); |
| 451 | + |
| 452 | + EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1); |
| 453 | + static_cast<Orch *>(gRouteOrch)->doTask(); |
| 454 | + |
| 455 | + entries.clear(); |
| 456 | + |
| 457 | + // Route deletion |
| 458 | + |
| 459 | + entries.clear(); |
| 460 | + entries.push_back({key, "DEL", {}}); |
| 461 | + |
| 462 | + consumer->addToSync(entries); |
| 463 | + |
| 464 | + EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1); |
| 465 | + static_cast<Orch *>(gRouteOrch)->doTask(); |
| 466 | + |
| 467 | + gMockResponsePublisher.reset(); |
| 468 | + } |
| 469 | + |
| 470 | + TEST_F(RouteOrchTest, RouteOrchSetFullMaskSubnetPrefix) |
| 471 | + { |
| 472 | + gMockResponsePublisher = std::make_unique<MockResponsePublisher>(); |
| 473 | + |
| 474 | + std::deque<KeyOpFieldsValuesTuple> entries; |
| 475 | + std::string key = "11.0.0.1/32"; |
| 476 | + std::vector<FieldValueTuple> fvs{{"ifname", "Ethernet4"}, {"nexthop", "0.0.0.0"}, {"protocol", "bgp"}}; |
| 477 | + entries.push_back({key, "SET", fvs}); |
| 478 | + |
| 479 | + auto consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME)); |
| 480 | + consumer->addToSync(entries); |
| 481 | + |
| 482 | + EXPECT_CALL(*gMockResponsePublisher, publish(APP_ROUTE_TABLE_NAME, key, std::vector<FieldValueTuple>{{"protocol", "bgp"}}, ReturnCode(SAI_STATUS_SUCCESS), false)).Times(1); |
| 483 | + static_cast<Orch *>(gRouteOrch)->doTask(); |
| 484 | + |
| 485 | + gMockResponsePublisher.reset(); |
| 486 | + } |
425 | 487 | }
|
0 commit comments