@@ -25,9 +25,9 @@ namespace flowcounterrouteorch_test
25
25
sai_remove_counter_fn old_remove_counter;
26
26
27
27
sai_status_t _ut_stub_create_counter (
28
- _Out_ sai_object_id_t *counter_id,
29
- _In_ sai_object_id_t switch_id,
30
- _In_ uint32_t attr_count,
28
+ _Out_ sai_object_id_t *counter_id,
29
+ _In_ sai_object_id_t switch_id,
30
+ _In_ uint32_t attr_count,
31
31
_In_ const sai_attribute_t *attr_list)
32
32
{
33
33
num_created_counter ++;
@@ -98,7 +98,7 @@ namespace flowcounterrouteorch_test
98
98
99
99
gVirtualRouterId = attr.value .oid ;
100
100
101
-
101
+
102
102
ASSERT_EQ (gCrmOrch , nullptr );
103
103
gCrmOrch = new CrmOrch (m_config_db.get (), CFG_CRM_TABLE_NAME);
104
104
@@ -200,6 +200,12 @@ namespace flowcounterrouteorch_test
200
200
};
201
201
gSrv6Orch = new Srv6Orch (m_app_db.get (), srv6_tables, gSwitchOrch , gVrfOrch , gNeighOrch );
202
202
203
+ // Start FlowCounterRouteOrch
204
+ static const vector<string> route_pattern_tables = {
205
+ CFG_FLOW_COUNTER_ROUTE_PATTERN_TABLE_NAME,
206
+ };
207
+ gFlowCounterRouteOrch = new FlowCounterRouteOrch (m_config_db.get (), route_pattern_tables);
208
+
203
209
ASSERT_EQ (gRouteOrch , nullptr );
204
210
const int routeorch_pri = 5 ;
205
211
vector<table_name_with_pri_t > route_tables = {
@@ -276,14 +282,7 @@ namespace flowcounterrouteorch_test
276
282
consumer->addToSync (entries);
277
283
static_cast <Orch *>(flexCounterOrch)->doTask ();
278
284
279
- // Start FlowCounterRouteOrch
280
- static const vector<string> route_pattern_tables = {
281
- CFG_FLOW_COUNTER_ROUTE_PATTERN_TABLE_NAME,
282
- };
283
- gFlowCounterRouteOrch = new FlowCounterRouteOrch (m_config_db.get (), route_pattern_tables);
284
-
285
285
static_cast <Orch *>(gFlowCounterRouteOrch )->doTask ();
286
-
287
286
return ;
288
287
}
289
288
@@ -311,7 +310,7 @@ namespace flowcounterrouteorch_test
311
310
312
311
delete gIntfsOrch ;
313
312
gIntfsOrch = nullptr ;
314
-
313
+
315
314
delete gFgNhgOrch ;
316
315
gFgNhgOrch = nullptr ;
317
316
@@ -358,4 +357,44 @@ namespace flowcounterrouteorch_test
358
357
ASSERT_TRUE (current_counter_num - num_created_counter == 1 );
359
358
360
359
}
360
+
361
+ TEST_F (FlowcounterRouteOrchTest, DelayAddVRF)
362
+ {
363
+ std::deque<KeyOpFieldsValuesTuple> entries;
364
+ // Setting route pattern with VRF does not exist
365
+ auto current_counter_num = num_created_counter;
366
+ entries.push_back ({" Vrf1|1.1.1.0/24" , " SET" , { {" max_match_count" , " 10" }}});
367
+ auto consumer = dynamic_cast <Consumer *>(gFlowCounterRouteOrch ->getExecutor (CFG_FLOW_COUNTER_ROUTE_PATTERN_TABLE_NAME));
368
+ consumer->addToSync (entries);
369
+ static_cast <Orch *>(gFlowCounterRouteOrch )->doTask ();
370
+ ASSERT_TRUE (num_created_counter - current_counter_num == 0 );
371
+
372
+ // Create VRF
373
+ entries.push_back ({" Vrf1" , " SET" , { {" v4" , " true" } }});
374
+ auto vrf_consumer = dynamic_cast <Consumer *>(gVrfOrch ->getExecutor (APP_VRF_TABLE_NAME));
375
+ vrf_consumer->addToSync (entries);
376
+ static_cast <Orch *>(gVrfOrch )->doTask ();
377
+ ASSERT_TRUE (num_created_counter - current_counter_num == 0 );
378
+
379
+ // Add route to VRF
380
+ Table routeTable = Table (m_app_db.get (), APP_ROUTE_TABLE_NAME);
381
+ routeTable.set (" Vrf1:1.1.1.1/32" , { {" ifname" , " Ethernet0" },
382
+ {" nexthop" , " 10.0.0.2" }});
383
+ gRouteOrch ->addExistingData (&routeTable);
384
+ static_cast <Orch *>(gRouteOrch )->doTask ();
385
+ ASSERT_TRUE (num_created_counter - current_counter_num == 1 );
386
+
387
+ // Deleting route pattern
388
+ current_counter_num = num_created_counter;
389
+ entries.clear ();
390
+ entries.push_back ({" Vrf1|1.1.1.0/24" , " DEL" , { {" max_match_count" , " 10" }}});
391
+ consumer->addToSync (entries);
392
+ static_cast <Orch *>(gFlowCounterRouteOrch )->doTask ();
393
+ ASSERT_TRUE (current_counter_num - num_created_counter == 1 );
394
+
395
+ // Deleting VRF
396
+ entries.push_back ({" Vrf1" , " DEL" , { {" v4" , " true" } }});
397
+ vrf_consumer->addToSync (entries);
398
+ static_cast <Orch *>(gVrfOrch )->doTask ();
399
+ }
361
400
}
0 commit comments