@@ -220,7 +220,13 @@ namespace flexcounter_test
220220 sai_switch_api = pold_sai_switch_api;
221221 }
222222
223- struct FlexCounterTest : public ::testing::TestWithParam<std::tuple<bool , bool >>
223+ enum class StartType
224+ {
225+ Cold,
226+ Warm,
227+ };
228+
229+ struct FlexCounterTest : public ::testing::TestWithParam<std::tuple<bool , bool , StartType>>
224230 {
225231 shared_ptr<swss::DBConnector> m_app_db;
226232 shared_ptr<swss::DBConnector> m_config_db;
@@ -230,6 +236,7 @@ namespace flexcounter_test
230236 shared_ptr<swss::DBConnector> m_asic_db;
231237 shared_ptr<swss::DBConnector> m_flex_counter_db;
232238 bool create_only_config_db_buffers;
239+ StartType m_start_type;
233240
234241 FlexCounterTest ()
235242 {
@@ -256,6 +263,8 @@ namespace flexcounter_test
256263
257264 gTraditionalFlexCounter = get<0 >(GetParam ());
258265 create_only_config_db_buffers = get<1 >(GetParam ());
266+ m_start_type = get<2 >(GetParam ());
267+
259268 if (gTraditionalFlexCounter )
260269 {
261270 initFlexCounterTables ();
@@ -300,7 +309,19 @@ namespace flexcounter_test
300309 vector<string> flex_counter_tables = {
301310 CFG_FLEX_COUNTER_TABLE_NAME
302311 };
312+
313+ if (m_start_type == StartType::Warm)
314+ {
315+ WarmStart::getInstance ().m_enabled = true ;
316+ }
317+
303318 auto * flexCounterOrch = new FlexCounterOrch (m_config_db.get (), flex_counter_tables);
319+
320+ if (m_start_type == StartType::Warm)
321+ {
322+ WarmStart::getInstance ().m_enabled = false ;
323+ }
324+
304325 gDirectory .set (flexCounterOrch);
305326
306327 vector<string> buffer_tables = { APP_BUFFER_POOL_TABLE_NAME,
@@ -542,8 +563,7 @@ namespace flexcounter_test
542563 ASSERT_TRUE (gPortsOrch ->allPortsReady ());
543564
544565 // Enable and check counters
545- const std::vector<FieldValueTuple> values ({ {FLEX_COUNTER_DELAY_STATUS_FIELD, " false" },
546- {FLEX_COUNTER_STATUS_FIELD, " enable" } });
566+ const std::vector<FieldValueTuple> values ({ {FLEX_COUNTER_STATUS_FIELD, " enable" } });
547567 flexCounterCfg.set (" PG_WATERMARK" , values);
548568 flexCounterCfg.set (" QUEUE_WATERMARK" , values);
549569 flexCounterCfg.set (" QUEUE" , values);
@@ -557,6 +577,13 @@ namespace flexcounter_test
557577 flexCounterOrch->addExistingData (&flexCounterCfg);
558578 static_cast <Orch *>(flexCounterOrch)->doTask ();
559579
580+ if (m_start_type == StartType::Warm)
581+ {
582+ // Expire timer
583+ flexCounterOrch->doTask (*flexCounterOrch->m_delayTimer );
584+ static_cast <Orch *>(flexCounterOrch)->doTask ();
585+ }
586+
560587 ASSERT_TRUE (checkFlexCounterGroup (BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
561588 {
562589 {POLL_INTERVAL_FIELD, " 60000" },
@@ -878,16 +905,28 @@ namespace flexcounter_test
878905 entries.clear ();
879906 static_cast <Orch *>(gBufferOrch )->doTask ();
880907 ASSERT_TRUE (checkFlexCounter (BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP, pool_oid));
908+
909+ // Warm/fast-boot case - no FC processing done before APPLY_VIEW
910+ std::vector<std::string> ts;
911+
912+ gDirectory .get <FlexCounterOrch*>()->bake ();
913+ gDirectory .get <FlexCounterOrch*>()->dumpPendingTasks (ts);
914+
915+ ASSERT_TRUE (ts.empty ());
881916 }
882917
883918 INSTANTIATE_TEST_CASE_P (
884919 FlexCounterTests,
885920 FlexCounterTest,
886921 ::testing::Values (
887- std::make_tuple (false , true ),
888- std::make_tuple(false , false ),
889- std::make_tuple(true , true ),
890- std::make_tuple(true , false ))
922+ std::make_tuple (false , true , StartType::Cold),
923+ std::make_tuple(false , false , StartType::Cold),
924+ std::make_tuple(true , true , StartType::Cold),
925+ std::make_tuple(true , false , StartType::Cold),
926+ std::make_tuple(false , true , StartType::Warm),
927+ std::make_tuple(false , false , StartType::Warm),
928+ std::make_tuple(true , true , StartType::Warm),
929+ std::make_tuple(true , false , StartType::Warm))
891930 );
892931
893932 using namespace mock_orch_test ;
0 commit comments