From ad8f5e43951d6ab8cb2e777f45f4da5a9245a982 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jun 2022 15:06:18 -0700 Subject: [PATCH] Revert "[Counters] Improve performance by polling only configured ports buffer queue/pg counters (#2143)" (#2315) This reverts commit eba212d9cffa034c8e0fcef6e275fef6cc700604. --- orchagent/bufferorch.cpp | 32 +--- orchagent/flexcounterorch.cpp | 181 +-------------------- orchagent/flexcounterorch.h | 32 ---- orchagent/portsorch.cpp | 262 +++++++----------------------- orchagent/portsorch.h | 20 +-- tests/mock_tests/portsorch_ut.cpp | 13 +- tests/mock_tests/routeorch_ut.cpp | 6 +- tests/test_buffer_traditional.py | 18 +- tests/test_flex_counters.py | 122 +++++++------- tests/test_pg_drop_counter.py | 64 +++++++- tests/test_watermark.py | 29 ++-- 11 files changed, 223 insertions(+), 556 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index b9fbd096b43f..f9b91e7a16cb 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -1,6 +1,5 @@ #include "tokenize.h" #include "bufferorch.h" -#include "directory.h" #include "logger.h" #include "sai_serialize.h" #include "warm_restart.h" @@ -17,7 +16,6 @@ extern sai_switch_api_t *sai_switch_api; extern sai_buffer_api_t *sai_buffer_api; extern PortsOrch *gPortsOrch; -extern Directory gDirectory; extern sai_object_id_t gSwitchId; #define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000" @@ -950,20 +948,6 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple) return handle_status; } } - // create/remove a port queue counter for the queue buffer - else - { - auto flexCounterOrch = gDirectory.get(); - auto queues = tokens[1]; - if (op == SET_COMMAND && flexCounterOrch->getQueueCountersState()) - { - gPortsOrch->createPortBufferQueueCounters(port, queues); - } - else if (op == DEL_COMMAND && flexCounterOrch->getQueueCountersState()) - { - gPortsOrch->removePortBufferQueueCounters(port, queues); - } - } } } } @@ -1023,7 +1007,7 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup if (op == SET_COMMAND) { ref_resolve_status resolve_result = resolveFieldRefValue(m_buffer_type_maps, buffer_profile_field_name, - buffer_to_ref_table_map.at(buffer_profile_field_name), tuple, + buffer_to_ref_table_map.at(buffer_profile_field_name), tuple, sai_buffer_profile, buffer_profile_name); if (ref_resolve_status::success != resolve_result) { @@ -1103,20 +1087,6 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup return handle_status; } } - // create or remove a port PG counter for the PG buffer - else - { - auto flexCounterOrch = gDirectory.get(); - auto pgs = tokens[1]; - if (op == SET_COMMAND && flexCounterOrch->getPgWatermarkCountersState()) - { - gPortsOrch->createPortBufferPgCounters(port, pgs); - } - else if (op == DEL_COMMAND && flexCounterOrch->getPgWatermarkCountersState()) - { - gPortsOrch->removePortBufferPgCounters(port, pgs); - } - } } } } diff --git a/orchagent/flexcounterorch.cpp b/orchagent/flexcounterorch.cpp index f16312f750fd..29563d90a57c 100644 --- a/orchagent/flexcounterorch.cpp +++ b/orchagent/flexcounterorch.cpp @@ -10,7 +10,6 @@ #include "debugcounterorch.h" #include "directory.h" #include "copporch.h" -#include #include "routeorch.h" #include "flowcounterrouteorch.h" @@ -59,8 +58,6 @@ unordered_map flexCounterGroupMap = FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector &tableNames): Orch(db, tableNames), m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME), - m_bufferQueueConfigTable(db, CFG_BUFFER_QUEUE_TABLE_NAME), - m_bufferPgConfigTable(db, CFG_BUFFER_PG_TABLE_NAME), m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)), m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)) { @@ -147,13 +144,11 @@ void FlexCounterOrch::doTask(Consumer &consumer) } else if(key == QUEUE_KEY) { - gPortsOrch->generateQueueMap(getQueueConfigurations()); - m_queue_enabled = true; + gPortsOrch->generateQueueMap(); } else if(key == PG_WATERMARK_KEY) { - gPortsOrch->generatePriorityGroupMap(getPgConfigurations()); - m_pg_watermark_enabled = true; + gPortsOrch->generatePriorityGroupMap(); } } if(gIntfsOrch && (key == RIF_KEY) && (value == "enable")) @@ -235,16 +230,6 @@ bool FlexCounterOrch::getPortBufferDropCountersState() const return m_port_buffer_drop_counter_enabled; } -bool FlexCounterOrch::getPgWatermarkCountersState() const -{ - return m_pg_watermark_enabled; -} - -bool FlexCounterOrch::getQueueCountersState() const -{ - return m_queue_enabled; -} - bool FlexCounterOrch::bake() { /* @@ -286,165 +271,3 @@ bool FlexCounterOrch::bake() Consumer* consumer = dynamic_cast(getExecutor(CFG_FLEX_COUNTER_TABLE_NAME)); return consumer->addToSync(entries); } - -map FlexCounterOrch::getQueueConfigurations() -{ - SWSS_LOG_ENTER(); - - map queuesStateVector; - std::vector portQueueKeys; - m_bufferQueueConfigTable.getKeys(portQueueKeys); - - for (const auto& portQueueKey : portQueueKeys) - { - auto toks = tokenize(portQueueKey, '|'); - if (toks.size() != 2) - { - SWSS_LOG_ERROR("Invalid BUFFER_QUEUE key: [%s]", portQueueKey.c_str()); - continue; - } - - auto configPortNames = tokenize(toks[0], ','); - auto configPortQueues = toks[1]; - toks = tokenize(configPortQueues, '-'); - - for (const auto& configPortName : configPortNames) - { - uint32_t maxQueueNumber = gPortsOrch->getNumberOfPortSupportedQueueCounters(configPortName); - uint32_t maxQueueIndex = maxQueueNumber - 1; - uint32_t minQueueIndex = 0; - - if (!queuesStateVector.count(configPortName)) - { - FlexCounterQueueStates flexCounterQueueState(maxQueueNumber); - queuesStateVector.insert(make_pair(configPortName, flexCounterQueueState)); - } - - try { - auto startIndex = to_uint(toks[0], minQueueIndex, maxQueueIndex); - if (toks.size() > 1) - { - auto endIndex = to_uint(toks[1], minQueueIndex, maxQueueIndex); - queuesStateVector.at(configPortName).enableQueueCounters(startIndex, endIndex); - } - else - { - queuesStateVector.at(configPortName).enableQueueCounter(startIndex); - } - } catch (std::invalid_argument const& e) { - SWSS_LOG_ERROR("Invalid queue index [%s] for port [%s]", configPortQueues.c_str(), configPortName.c_str()); - continue; - } - } - } - - return queuesStateVector; -} - -map FlexCounterOrch::getPgConfigurations() -{ - SWSS_LOG_ENTER(); - - map pgsStateVector; - std::vector portPgKeys; - m_bufferPgConfigTable.getKeys(portPgKeys); - - for (const auto& portPgKey : portPgKeys) - { - auto toks = tokenize(portPgKey, '|'); - if (toks.size() != 2) - { - SWSS_LOG_ERROR("Invalid BUFFER_PG key: [%s]", portPgKey.c_str()); - continue; - } - - auto configPortNames = tokenize(toks[0], ','); - auto configPortPgs = toks[1]; - toks = tokenize(configPortPgs, '-'); - - for (const auto& configPortName : configPortNames) - { - uint32_t maxPgNumber = gPortsOrch->getNumberOfPortSupportedPgCounters(configPortName); - uint32_t maxPgIndex = maxPgNumber - 1; - uint32_t minPgIndex = 0; - - if (!pgsStateVector.count(configPortName)) - { - FlexCounterPgStates flexCounterPgState(maxPgNumber); - pgsStateVector.insert(make_pair(configPortName, flexCounterPgState)); - } - - try { - auto startIndex = to_uint(toks[0], minPgIndex, maxPgIndex); - if (toks.size() > 1) - { - auto endIndex = to_uint(toks[1], minPgIndex, maxPgIndex); - pgsStateVector.at(configPortName).enablePgCounters(startIndex, endIndex); - } - else - { - pgsStateVector.at(configPortName).enablePgCounter(startIndex); - } - } catch (std::invalid_argument const& e) { - SWSS_LOG_ERROR("Invalid pg index [%s] for port [%s]", configPortPgs.c_str(), configPortName.c_str()); - continue; - } - } - } - - return pgsStateVector; -} - -FlexCounterQueueStates::FlexCounterQueueStates(uint32_t maxQueueNumber) -{ - SWSS_LOG_ENTER(); - m_queueStates.resize(maxQueueNumber, false); -} - -bool FlexCounterQueueStates::isQueueCounterEnabled(uint32_t index) const -{ - SWSS_LOG_ENTER(); - return m_queueStates[index]; -} - -void FlexCounterQueueStates::enableQueueCounters(uint32_t startIndex, uint32_t endIndex) -{ - SWSS_LOG_ENTER(); - for (uint32_t queueIndex = startIndex; queueIndex <= endIndex; queueIndex++) - { - enableQueueCounter(queueIndex); - } -} - -void FlexCounterQueueStates::enableQueueCounter(uint32_t queueIndex) -{ - SWSS_LOG_ENTER(); - m_queueStates[queueIndex] = true; -} - -FlexCounterPgStates::FlexCounterPgStates(uint32_t maxPgNumber) -{ - SWSS_LOG_ENTER(); - m_pgStates.resize(maxPgNumber, false); -} - -bool FlexCounterPgStates::isPgCounterEnabled(uint32_t index) const -{ - SWSS_LOG_ENTER(); - return m_pgStates[index]; -} - -void FlexCounterPgStates::enablePgCounters(uint32_t startIndex, uint32_t endIndex) -{ - SWSS_LOG_ENTER(); - for (uint32_t pgIndex = startIndex; pgIndex <= endIndex; pgIndex++) - { - enablePgCounter(pgIndex); - } -} - -void FlexCounterPgStates::enablePgCounter(uint32_t pgIndex) -{ - SWSS_LOG_ENTER(); - m_pgStates[pgIndex] = true; -} diff --git a/orchagent/flexcounterorch.h b/orchagent/flexcounterorch.h index a8106720da05..4f9734c0e2d4 100644 --- a/orchagent/flexcounterorch.h +++ b/orchagent/flexcounterorch.h @@ -10,30 +10,6 @@ extern "C" { #include "sai.h" } -class FlexCounterQueueStates -{ -public: - FlexCounterQueueStates(uint32_t maxQueueNumber); - bool isQueueCounterEnabled(uint32_t index) const; - void enableQueueCounters(uint32_t startIndex, uint32_t endIndex); - void enableQueueCounter(uint32_t queueIndex); - -private: - std::vector m_queueStates{}; -}; - -class FlexCounterPgStates -{ -public: - FlexCounterPgStates(uint32_t maxPgNumber); - bool isPgCounterEnabled(uint32_t index) const; - void enablePgCounters(uint32_t startIndex, uint32_t endIndex); - void enablePgCounter(uint32_t pgIndex); - -private: - std::vector m_pgStates{}; -}; - class FlexCounterOrch: public Orch { public: @@ -42,10 +18,6 @@ class FlexCounterOrch: public Orch virtual ~FlexCounterOrch(void); bool getPortCountersState() const; bool getPortBufferDropCountersState() const; - bool getPgWatermarkCountersState() const; - bool getQueueCountersState() const; - map getQueueConfigurations(); - map getPgConfigurations(); bool getHostIfTrapCounterState() const {return m_hostif_trap_counter_enabled;} bool getRouteFlowCountersState() const {return m_route_flow_counter_enabled;} bool bake() override; @@ -55,13 +27,9 @@ class FlexCounterOrch: public Orch std::shared_ptr m_flexCounterGroupTable = nullptr; bool m_port_counter_enabled = false; bool m_port_buffer_drop_counter_enabled = false; - bool m_pg_watermark_enabled = false; - bool m_queue_enabled = false; bool m_hostif_trap_counter_enabled = false; bool m_route_flow_counter_enabled = false; Table m_flexCounterConfigTable; - Table m_bufferQueueConfigTable; - Table m_bufferPgConfigTable; }; #endif diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index dc1be1b3b679..6d06c6318f3e 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2457,6 +2457,18 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats); } + /* when a port is added and priority group map counter is enabled --> we need to add pg counter for it */ + if (m_isPriorityGroupMapGenerated) + { + generatePriorityGroupMapPerPort(p); + } + + /* when a port is added and queue map counter is enabled --> we need to add queue map counter for it */ + if (m_isQueueMapGenerated) + { + generateQueueMapPerPort(p); + } + PortUpdate update = { p, true }; notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); @@ -2509,6 +2521,18 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id) port_buffer_drop_stat_manager.clearCounterIdList(p.m_port_id); } + /* remove pg port counters */ + if (m_isPriorityGroupMapGenerated) + { + removePriorityGroupMapPerPort(p); + } + + /* remove queue port counters */ + if (m_isQueueMapGenerated) + { + removeQueueMapPerPort(p); + } + /* remove port name map from counter table */ m_counterTable->hdel("", alias); @@ -5463,7 +5487,7 @@ bool PortsOrch::removeTunnel(Port tunnel) return true; } -void PortsOrch::generateQueueMap(map queuesStateVector) +void PortsOrch::generateQueueMap() { if (m_isQueueMapGenerated) { @@ -5474,87 +5498,53 @@ void PortsOrch::generateQueueMap(map queuesState { if (it.second.m_type == Port::PHY) { - if (!queuesStateVector.count(it.second.m_alias)) - { - auto maxQueueNumber = getNumberOfPortSupportedQueueCounters(it.second.m_alias); - FlexCounterQueueStates flexCounterQueueState(maxQueueNumber); - queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState)); - } - generateQueueMapPerPort(it.second, queuesStateVector.at(it.second.m_alias)); + generateQueueMapPerPort(it.second); } } m_isQueueMapGenerated = true; } -void PortsOrch::generateQueueMapPerPort(const Port& port, FlexCounterQueueStates& queuesState) +void PortsOrch::removeQueueMapPerPort(const Port& port) { - /* Create the Queue map in the Counter DB */ - /* Add stat counters to flex_counter */ - vector queueVector; - vector queuePortVector; - vector queueIndexVector; - vector queueTypeVector; + /* Remove the Queue map in the Counter DB */ for (size_t queueIndex = 0; queueIndex < port.m_queue_ids.size(); ++queueIndex) { std::ostringstream name; name << port.m_alias << ":" << queueIndex; + std::unordered_set counter_stats; const auto id = sai_serialize_object_id(port.m_queue_ids[queueIndex]); + m_queueTable->hdel("",name.str()); + m_queuePortTable->hdel("",id); + string queueType; uint8_t queueRealIndex = 0; if (getQueueTypeAndIndex(port.m_queue_ids[queueIndex], queueType, queueRealIndex)) { - if (!queuesState.isQueueCounterEnabled(queueRealIndex)) - { - continue; - } - queueTypeVector.emplace_back(id, queueType); - queueIndexVector.emplace_back(id, to_string(queueRealIndex)); + m_queueTypeTable->hdel("",id); + m_queueIndexTable->hdel("",id); } - queueVector.emplace_back(name.str(), id); - queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id)); - - // Install a flex counter for this queue to track stats - std::unordered_set counter_stats; for (const auto& it: queue_stat_ids) { counter_stats.emplace(sai_serialize_queue_stat(it)); } - queue_stat_manager.setCounterIdList(port.m_queue_ids[queueIndex], CounterType::QUEUE, counter_stats); + queue_stat_manager.clearCounterIdList(port.m_queue_ids[queueIndex]); - /* add watermark queue counters */ + /* remove watermark queue counters */ string key = getQueueWatermarkFlexCounterTableKey(id); - string delimiter(""); - std::ostringstream counters_stream; - for (const auto& it: queueWatermarkStatIds) - { - counters_stream << delimiter << sai_serialize_queue_stat(it); - delimiter = comma; - } - - vector fieldValues; - fieldValues.emplace_back(QUEUE_COUNTER_ID_LIST, counters_stream.str()); - - m_flexCounterTable->set(key, fieldValues); + m_flexCounterTable->del(key); } - m_queueTable->set("", queueVector); - m_queuePortTable->set("", queuePortVector); - m_queueIndexTable->set("", queueIndexVector); - m_queueTypeTable->set("", queueTypeVector); - - CounterCheckOrch::getInstance().addPort(port); + CounterCheckOrch::getInstance().removePort(port); } -void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) +void PortsOrch::generateQueueMapPerPort(const Port& port) { - SWSS_LOG_ENTER(); - /* Create the Queue map in the Counter DB */ /* Add stat counters to flex_counter */ vector queueVector; @@ -5562,21 +5552,16 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) vector queueIndexVector; vector queueTypeVector; - auto toks = tokenize(queues, '-'); - auto startIndex = to_uint(toks[0]); - auto endIndex = startIndex; - if (toks.size() > 1) - { - endIndex = to_uint(toks[1]); - } - - for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++) + for (size_t queueIndex = 0; queueIndex < port.m_queue_ids.size(); ++queueIndex) { std::ostringstream name; name << port.m_alias << ":" << queueIndex; const auto id = sai_serialize_object_id(port.m_queue_ids[queueIndex]); + queueVector.emplace_back(name.str(), id); + queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id)); + string queueType; uint8_t queueRealIndex = 0; if (getQueueTypeAndIndex(port.m_queue_ids[queueIndex], queueType, queueRealIndex)) @@ -5585,9 +5570,6 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) queueIndexVector.emplace_back(id, to_string(queueRealIndex)); } - queueVector.emplace_back(name.str(), id); - queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id)); - // Install a flex counter for this queue to track stats std::unordered_set counter_stats; for (const auto& it: queue_stat_ids) @@ -5621,42 +5603,7 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues) CounterCheckOrch::getInstance().addPort(port); } -void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues) -{ - SWSS_LOG_ENTER(); - - /* Remove the Queues maps in the Counter DB */ - /* Remove stat counters from flex_counter DB */ - auto toks = tokenize(queues, '-'); - auto startIndex = to_uint(toks[0]); - auto endIndex = startIndex; - if (toks.size() > 1) - { - endIndex = to_uint(toks[1]); - } - - for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++) - { - std::ostringstream name; - name << port.m_alias << ":" << queueIndex; - const auto id = sai_serialize_object_id(port.m_queue_ids[queueIndex]); - - /* Remove watermark queue counters */ - string key = getQueueWatermarkFlexCounterTableKey(id); - m_flexCounterTable->del(key); - - // Remove the flex counter for this queue - queue_stat_manager.clearCounterIdList(port.m_queue_ids[queueIndex]); - - // Remove the queue counter from counters DB maps - m_queueTable->hdel("", name.str()); - m_queuePortTable->hdel("", id); - m_queueIndexTable->hdel("", id); - m_queueTypeTable->hdel("", id); - } -} - -void PortsOrch::generatePriorityGroupMap(map pgsStateVector) +void PortsOrch::generatePriorityGroupMap() { if (m_isPriorityGroupMapGenerated) { @@ -5667,100 +5614,48 @@ void PortsOrch::generatePriorityGroupMap(map pgsSta { if (it.second.m_type == Port::PHY) { - if (!pgsStateVector.count(it.second.m_alias)) - { - auto maxPgNumber = getNumberOfPortSupportedPgCounters(it.second.m_alias); - FlexCounterPgStates flexCounterPgState(maxPgNumber); - pgsStateVector.insert(make_pair(it.second.m_alias, flexCounterPgState)); - } - generatePriorityGroupMapPerPort(it.second, pgsStateVector.at(it.second.m_alias)); + generatePriorityGroupMapPerPort(it.second); } } m_isPriorityGroupMapGenerated = true; } -void PortsOrch::generatePriorityGroupMapPerPort(const Port& port, FlexCounterPgStates& pgsState) +void PortsOrch::removePriorityGroupMapPerPort(const Port& port) { - /* Create the PG map in the Counter DB */ - /* Add stat counters to flex_counter */ - vector pgVector; - vector pgPortVector; - vector pgIndexVector; + /* Remove the PG map in the Counter DB */ for (size_t pgIndex = 0; pgIndex < port.m_priority_group_ids.size(); ++pgIndex) { - if (!pgsState.isPgCounterEnabled(static_cast(pgIndex))) - { - continue; - } std::ostringstream name; name << port.m_alias << ":" << pgIndex; const auto id = sai_serialize_object_id(port.m_priority_group_ids[pgIndex]); - - pgVector.emplace_back(name.str(), id); - pgPortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id)); - pgIndexVector.emplace_back(id, to_string(pgIndex)); - string key = getPriorityGroupWatermarkFlexCounterTableKey(id); - std::string delimiter = ""; - std::ostringstream counters_stream; - /* Add watermark counters to flex_counter */ - for (const auto& it: ingressPriorityGroupWatermarkStatIds) - { - counters_stream << delimiter << sai_serialize_ingress_priority_group_stat(it); - delimiter = comma; - } + m_pgTable->hdel("",name.str()); + m_pgPortTable->hdel("",id); + m_pgIndexTable->hdel("",id); - vector fieldValues; - fieldValues.emplace_back(PG_COUNTER_ID_LIST, counters_stream.str()); - m_flexCounterTable->set(key, fieldValues); + m_flexCounterTable->del(key); - delimiter = ""; - std::ostringstream ingress_pg_drop_packets_counters_stream; key = getPriorityGroupDropPacketsFlexCounterTableKey(id); - /* Add dropped packets counters to flex_counter */ - for (const auto& it: ingressPriorityGroupDropStatIds) - { - ingress_pg_drop_packets_counters_stream << delimiter << sai_serialize_ingress_priority_group_stat(it); - if (delimiter.empty()) - { - delimiter = comma; - } - } - fieldValues.clear(); - fieldValues.emplace_back(PG_COUNTER_ID_LIST, ingress_pg_drop_packets_counters_stream.str()); - m_flexCounterTable->set(key, fieldValues); + /* remove dropped packets counters to flex_counter */ + m_flexCounterTable->del(key); } - m_pgTable->set("", pgVector); - m_pgPortTable->set("", pgPortVector); - m_pgIndexTable->set("", pgIndexVector); - - CounterCheckOrch::getInstance().addPort(port); + CounterCheckOrch::getInstance().removePort(port); } -void PortsOrch::createPortBufferPgCounters(const Port& port, string pgs) +void PortsOrch::generatePriorityGroupMapPerPort(const Port& port) { - SWSS_LOG_ENTER(); - /* Create the PG map in the Counter DB */ /* Add stat counters to flex_counter */ vector pgVector; vector pgPortVector; vector pgIndexVector; - auto toks = tokenize(pgs, '-'); - auto startIndex = to_uint(toks[0]); - auto endIndex = startIndex; - if (toks.size() > 1) - { - endIndex = to_uint(toks[1]); - } - - for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++) + for (size_t pgIndex = 0; pgIndex < port.m_priority_group_ids.size(); ++pgIndex) { std::ostringstream name; name << port.m_alias << ":" << pgIndex; @@ -5810,41 +5705,6 @@ void PortsOrch::createPortBufferPgCounters(const Port& port, string pgs) CounterCheckOrch::getInstance().addPort(port); } -void PortsOrch::removePortBufferPgCounters(const Port& port, string pgs) -{ - SWSS_LOG_ENTER(); - - /* Remove the Pgs maps in the Counter DB */ - /* Remove stat counters from flex_counter DB */ - auto toks = tokenize(pgs, '-'); - auto startIndex = to_uint(toks[0]); - auto endIndex = startIndex; - if (toks.size() > 1) - { - endIndex = to_uint(toks[1]); - } - - for (auto pgIndex = startIndex; pgIndex <= endIndex; pgIndex++) - { - std::ostringstream name; - name << port.m_alias << ":" << pgIndex; - const auto id = sai_serialize_object_id(port.m_priority_group_ids[pgIndex]); - - /* Remove dropped packets counters from flex_counter */ - string key = getPriorityGroupDropPacketsFlexCounterTableKey(id); - m_flexCounterTable->del(key); - - /* Remove watermark counters from flex_counter */ - key = getPriorityGroupWatermarkFlexCounterTableKey(id); - m_flexCounterTable->del(key); - - // Remove the pg counter from counters DB maps - m_pgTable->hdel("", name.str()); - m_pgPortTable->hdel("", id); - m_pgIndexTable->hdel("", id); - } -} - void PortsOrch::generatePortCounterMap() { if (m_isPortCounterMapGenerated) @@ -5895,16 +5755,6 @@ void PortsOrch::generatePortBufferDropCounterMap() m_isPortBufferDropCounterMapGenerated = true; } -uint32_t PortsOrch::getNumberOfPortSupportedPgCounters(string port) -{ - return static_cast(m_portList[port].m_priority_group_ids.size()); -} - -uint32_t PortsOrch::getNumberOfPortSupportedQueueCounters(string port) -{ - return static_cast(m_portList[port].m_queue_ids.size()); -} - void PortsOrch::doTask(NotificationConsumer &consumer) { SWSS_LOG_ENTER(); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 6291231ae70e..ab35277d80c6 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -128,17 +128,9 @@ class PortsOrch : public Orch, public Subject bool setPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t pfc_bitmask); bool getPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t *pfc_bitmask); - - void generateQueueMap(map queuesStateVector); - uint32_t getNumberOfPortSupportedQueueCounters(string port); - void createPortBufferQueueCounters(const Port &port, string queues); - void removePortBufferQueueCounters(const Port &port, string queues); - - void generatePriorityGroupMap(map pgsStateVector); - uint32_t getNumberOfPortSupportedPgCounters(string port); - void createPortBufferPgCounters(const Port &port, string pgs); - void removePortBufferPgCounters(const Port& port, string pgs); + void generateQueueMap(); + void generatePriorityGroupMap(); void generatePortCounterMap(); void generatePortBufferDropCounterMap(); @@ -333,9 +325,13 @@ class PortsOrch : public Orch, public Subject bool getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index); bool m_isQueueMapGenerated = false; - void generateQueueMapPerPort(const Port& port, FlexCounterQueueStates& queuesState); + void generateQueueMapPerPort(const Port& port); + void removeQueueMapPerPort(const Port& port); + bool m_isPriorityGroupMapGenerated = false; - void generatePriorityGroupMapPerPort(const Port& port, FlexCounterPgStates& pgsState); + void generatePriorityGroupMapPerPort(const Port& port); + void removePriorityGroupMapPerPort(const Port& port); + bool m_isPortCounterMapGenerated = false; bool m_isPortBufferDropCounterMapGenerated = false; diff --git a/tests/mock_tests/portsorch_ut.cpp b/tests/mock_tests/portsorch_ut.cpp index 7d867396d226..28df6610fdf6 100644 --- a/tests/mock_tests/portsorch_ut.cpp +++ b/tests/mock_tests/portsorch_ut.cpp @@ -163,14 +163,13 @@ namespace portsorch_test ASSERT_EQ(gPortsOrch, nullptr); - gPortsOrch = new PortsOrch(m_app_db.get(), m_state_db.get(), ports_tables, m_chassis_app_db.get()); - vector flex_counter_tables = { CFG_FLEX_COUNTER_TABLE_NAME }; auto* flexCounterOrch = new FlexCounterOrch(m_config_db.get(), flex_counter_tables); gDirectory.set(flexCounterOrch); + gPortsOrch = new PortsOrch(m_app_db.get(), m_state_db.get(), ports_tables, m_chassis_app_db.get()); vector buffer_tables = { APP_BUFFER_POOL_TABLE_NAME, APP_BUFFER_PROFILE_TABLE_NAME, APP_BUFFER_QUEUE_TABLE_NAME, @@ -863,7 +862,7 @@ namespace portsorch_test * updated to DB. */ TEST_F(PortsOrchTest, PortOperStatusIsUpAndOperSpeedIsZero) - { + { Table portTable = Table(m_app_db.get(), APP_PORT_TABLE_NAME); // Get SAI default ports to populate DB @@ -888,7 +887,7 @@ namespace portsorch_test Port port; gPortsOrch->getPort("Ethernet0", port); ASSERT_TRUE(port.m_oper_status != SAI_PORT_OPER_STATUS_UP); - + // save original api since we will spy auto orig_port_api = sai_port_api; sai_port_api = new sai_port_api_t(); @@ -906,14 +905,14 @@ namespace portsorch_test // Return 0 for port operational speed attrs[0].value.u32 = 0; } - + return (sai_status_t)SAI_STATUS_SUCCESS; } ); auto exec = static_cast(gPortsOrch->getExecutor("PORT_STATUS_NOTIFICATIONS")); auto consumer = exec->getNotificationConsumer(); - + // mock a redis reply for notification, it notifies that Ehernet0 is going to up mockReply = (redisReply *)calloc(sizeof(redisReply), 1); mockReply->type = REDIS_REPLY_ARRAY; @@ -935,7 +934,7 @@ namespace portsorch_test // trigger the notification consumer->readData(); gPortsOrch->doTask(*consumer); - mockReply = nullptr; + mockReply = nullptr; gPortsOrch->getPort("Ethernet0", port); ASSERT_TRUE(port.m_oper_status == SAI_PORT_OPER_STATUS_UP); diff --git a/tests/mock_tests/routeorch_ut.cpp b/tests/mock_tests/routeorch_ut.cpp index 2c1c4b8535cf..66df4bfbcc82 100644 --- a/tests/mock_tests/routeorch_ut.cpp +++ b/tests/mock_tests/routeorch_ut.cpp @@ -176,15 +176,15 @@ namespace routeorch_test { APP_LAG_MEMBER_TABLE_NAME, portsorch_base_pri } }; - ASSERT_EQ(gPortsOrch, nullptr); - gPortsOrch = new PortsOrch(m_app_db.get(), m_state_db.get(), ports_tables, m_chassis_app_db.get()); - vector flex_counter_tables = { CFG_FLEX_COUNTER_TABLE_NAME }; auto* flexCounterOrch = new FlexCounterOrch(m_config_db.get(), flex_counter_tables); gDirectory.set(flexCounterOrch); + ASSERT_EQ(gPortsOrch, nullptr); + gPortsOrch = new PortsOrch(m_app_db.get(), m_state_db.get(), ports_tables, m_chassis_app_db.get()); + static const vector route_pattern_tables = { CFG_FLOW_COUNTER_ROUTE_PATTERN_TABLE_NAME, }; diff --git a/tests/test_buffer_traditional.py b/tests/test_buffer_traditional.py index 071217b4e3b4..3d2285fd7b07 100644 --- a/tests/test_buffer_traditional.py +++ b/tests/test_buffer_traditional.py @@ -77,15 +77,16 @@ def get_pg_name_map(self): @pytest.fixture def setup_teardown_test(self, dvs): - self.setup_db(dvs) - self.set_port_qos_table(self.INTF, '2,3,4,6') - time.sleep(2) - - yield - - self.teardown() + try: + self.setup_db(dvs) + self.set_port_qos_table(self.INTF, '2,3,4,6') + pg_name_map = self.get_pg_name_map() + yield pg_name_map + finally: + self.teardown() def test_zero_cable_len_profile_update(self, dvs, setup_teardown_test): + self.pg_name_map = setup_teardown_test orig_cable_len = None orig_speed = None try: @@ -111,7 +112,6 @@ def test_zero_cable_len_profile_update(self, dvs, setup_teardown_test): # Make sure the buffer PG has been created orig_lossless_profile = "pg_lossless_{}_{}_profile".format(orig_speed, cable_len_before_test) self.app_db.wait_for_entry("BUFFER_PROFILE_TABLE", orig_lossless_profile) - self.pg_name_map = self.get_pg_name_map() self.orig_profiles = self.get_asic_buf_profile() # check if the lossless profile for the test speed is already present @@ -174,6 +174,7 @@ def test_zero_cable_len_profile_update(self, dvs, setup_teardown_test): # To verify the BUFFER_PG is not hardcoded to 3,4 # buffermgrd will read 'pfc_enable' entry and apply lossless profile to that queue def test_buffer_pg_update(self, dvs, setup_teardown_test): + self.pg_name_map = setup_teardown_test orig_cable_len = None orig_speed = None test_speed = None @@ -202,7 +203,6 @@ def test_buffer_pg_update(self, dvs, setup_teardown_test): # Make sure the buffer PG has been created orig_lossless_profile = "pg_lossless_{}_{}_profile".format(orig_speed, cable_len_for_test) self.app_db.wait_for_entry("BUFFER_PROFILE_TABLE", orig_lossless_profile) - self.pg_name_map = self.get_pg_name_map() self.orig_profiles = self.get_asic_buf_profile() # get the orig buf profiles attached to the pgs diff --git a/tests/test_flex_counters.py b/tests/test_flex_counters.py index f5a0b146b231..76a1a535f9a6 100644 --- a/tests/test_flex_counters.py +++ b/tests/test_flex_counters.py @@ -7,6 +7,8 @@ ROUTE_TO_PATTERN_MAP = "COUNTERS_ROUTE_TO_PATTERN_MAP" NUMBER_OF_RETRIES = 10 CPU_PORT_OID = "0x0" +PORT = "Ethernet0" +PORT_MAP = "COUNTERS_PORT_NAME_MAP" counter_group_meta = { 'port_counter': { @@ -71,6 +73,7 @@ } } +@pytest.mark.usefixtures('dvs_port_manager') class TestFlexCounters(object): def setup_dbs(self, dvs): @@ -130,18 +133,6 @@ def wait_for_interval_set(self, group, interval): assert False, "Polling interval is not applied to FLEX_COUNTER_GROUP_TABLE for group {}, expect={}, actual={}".format(group, interval, interval_value) - def wait_for_buffer_pg_queue_counter(self, map, port, index, isSet): - for retry in range(NUMBER_OF_RETRIES): - counter_oid = self.counters_db.db_connection.hget(map, port + ':' + index) - if (isSet and counter_oid): - return counter_oid - elif (not isSet and not counter_oid): - return None - else: - time.sleep(1) - - assert False, "Counter not {} for port: {}, type: {}, index: {}".format("created" if isSet else "removed", port, map, index) - def verify_no_flex_counters_tables(self, counter_stat): counters_stat_keys = self.flex_db.get_keys("FLEX_COUNTER_TABLE:" + counter_stat) assert len(counters_stat_keys) == 0, "FLEX_COUNTER_TABLE:" + str(counter_stat) + " tables exist before enabling the flex counter group" @@ -701,53 +692,64 @@ def remove_ip_address(self, interface, ip): def set_admin_status(self, interface, status): self.config_db.update_entry("PORT", interface, {"admin_status": status}) - - def test_create_remove_buffer_pg_counter(self, dvs): - """ - Test steps: - 1. Enable PG flex counters. - 2. Configure new buffer prioriy group for a port - 3. Verify counter is automatically created - 4. Remove the new buffer prioriy group for the port - 5. Verify counter is automatically removed - - Args: - dvs (object): virtual switch object - """ - self.setup_dbs(dvs) - meta_data = counter_group_meta['pg_watermark_counter'] - - self.set_flex_counter_group_status(meta_data['key'], meta_data['name_map']) - - self.config_db.update_entry('BUFFER_PG', 'Ethernet0|1', {'profile': 'ingress_lossy_profile'}) - counter_oid = self.wait_for_buffer_pg_queue_counter(meta_data['name_map'], 'Ethernet0', '1', True) - self.wait_for_id_list(meta_data['group_name'], "Ethernet0", counter_oid) - - self.config_db.delete_entry('BUFFER_PG', 'Ethernet0|1') - self.wait_for_buffer_pg_queue_counter(meta_data['name_map'], 'Ethernet0', '1', False) - self.wait_for_id_list_remove(meta_data['group_name'], "Ethernet0", counter_oid) - - def test_create_remove_buffer_queue_counter(self, dvs): - """ - Test steps: - 1. Enable Queue flex counters. - 2. Configure new buffer queue for a port - 3. Verify counter is automatically created - 4. Remove the new buffer queue for the port - 5. Verify counter is automatically removed - - Args: - dvs (object): virtual switch object - """ + + def test_add_remove_ports(self, dvs): self.setup_dbs(dvs) - meta_data = counter_group_meta['queue_counter'] - - self.set_flex_counter_group_status(meta_data['key'], meta_data['name_map']) - - self.config_db.update_entry('BUFFER_QUEUE', 'Ethernet0|7', {'profile': 'egress_lossless_profile'}) - counter_oid = self.wait_for_buffer_pg_queue_counter(meta_data['name_map'], 'Ethernet0', '7', True) - self.wait_for_id_list(meta_data['group_name'], "Ethernet0", counter_oid) + + # set flex counter + counter_key = counter_group_meta['queue_counter']['key'] + counter_stat = counter_group_meta['queue_counter']['group_name'] + counter_map = counter_group_meta['queue_counter']['name_map'] + self.set_flex_counter_group_status(counter_key, counter_map) - self.config_db.delete_entry('BUFFER_QUEUE', 'Ethernet0|7') - self.wait_for_buffer_pg_queue_counter(meta_data['name_map'], 'Ethernet0', '7', False) - self.wait_for_id_list_remove(meta_data['group_name'], "Ethernet0", counter_oid) + # receive port info + fvs = self.config_db.get_entry("PORT", PORT) + assert len(fvs) > 0 + + # save all the oids of the pg drop counters + oid_list = [] + counters_queue_map = self.counters_db.get_entry("COUNTERS_QUEUE_NAME_MAP", "") + for key, oid in counters_queue_map.items(): + if PORT in key: + oid_list.append(oid) + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", counter_stat + ":%s" % oid) + assert len(fields) == 1 + oid_list_len = len(oid_list) + + # get port oid + port_oid = self.counters_db.get_entry(PORT_MAP, "")[PORT] + + # remove port and verify that it was removed properly + self.dvs_port.remove_port(PORT) + dvs.get_asic_db().wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_PORT", port_oid) + + # verify counters were removed from flex counter table + for oid in oid_list: + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", counter_stat + ":%s" % oid) + assert len(fields) == 0 + + # verify that port counter maps were removed from counters db + counters_queue_map = self.counters_db.get_entry("COUNTERS_QUEUE_NAME_MAP", "") + for key in counters_queue_map.keys(): + if PORT in key: + assert False + + # add port and wait until the port is added on asic db + num_of_keys_without_port = len(dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT")) + + self.config_db.create_entry("PORT", PORT, fvs) + + dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_keys_without_port + 1) + dvs.get_counters_db().wait_for_fields("COUNTERS_QUEUE_NAME_MAP", "", ["%s:0"%(PORT)]) + + # verify queue counters were added + oid_list = [] + counters_queue_map = self.counters_db.get_entry("COUNTERS_QUEUE_NAME_MAP", "") + + for key, oid in counters_queue_map.items(): + if PORT in key: + oid_list.append(oid) + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", counter_stat + ":%s" % oid) + assert len(fields) == 1 + # the number of the oids needs to be the same as the original number of oids (before removing a port and adding) + assert oid_list_len == len(oid_list) diff --git a/tests/test_pg_drop_counter.py b/tests/test_pg_drop_counter.py index 6d97af5f5c31..b3682881dec3 100644 --- a/tests/test_pg_drop_counter.py +++ b/tests/test_pg_drop_counter.py @@ -2,12 +2,16 @@ import re import time import json +import pytest import redis from swsscommon import swsscommon pg_drop_attr = "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" +PORT = "Ethernet0" + +@pytest.mark.usefixtures('dvs_port_manager') class TestPGDropCounter(object): DEFAULT_POLL_INTERVAL = 10 pgs = {} @@ -57,11 +61,14 @@ def verify_value(self, dvs, obj_ids, entry_name, expected_value): assert found, "entry name %s not found" % (entry_name) def set_up_flex_counter(self): + pg_stats_entry = {"PG_COUNTER_ID_LIST": "{}".format(pg_drop_attr)} + for pg in self.pgs: + self.flex_db.create_entry("FLEX_COUNTER_TABLE", "PG_DROP_STAT_COUNTER:{}".format(pg), pg_stats_entry) + fc_status_enable = {"FLEX_COUNTER_STATUS": "enable"} + self.config_db.create_entry("FLEX_COUNTER_TABLE", "PG_DROP", fc_status_enable) self.config_db.create_entry("FLEX_COUNTER_TABLE", "PG_WATERMARK", fc_status_enable) - # Wait for DB's to populate by orchagent - time.sleep(2) def clear_flex_counter(self): for pg in self.pgs: @@ -72,12 +79,10 @@ def clear_flex_counter(self): def test_pg_drop_counters(self, dvs): self.setup_dbs(dvs) - self.set_up_flex_counter() - # Get all configured counters OID's - self.pgs = self.counters_db.db_connection.hgetall("COUNTERS_PG_NAME_MAP").values() - assert self.pgs is not None and len(self.pgs) > 0 - + self.pgs = self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP") try: + self.set_up_flex_counter() + self.populate_asic(dvs, "0") time.sleep(self.DEFAULT_POLL_INTERVAL) self.verify_value(dvs, self.pgs, pg_drop_attr, "0") @@ -92,3 +97,48 @@ def test_pg_drop_counters(self, dvs): finally: self.clear_flex_counter() + def test_pg_drop_counter_port_add_remove(self, dvs): + self.setup_dbs(dvs) + + try: + # configure pg drop flex counter + self.set_up_flex_counter() + + # receive port info + fvs = self.config_db.get_entry("PORT", PORT) + assert len(fvs) > 0 + + # save all the oids of the pg drop counters + oid_list = [] + for priority in range(0,7): + oid_list.append(dvs.get_counters_db().get_entry("COUNTERS_PG_NAME_MAP", "")["%s:%d"%(PORT, priority)]) + # verify that counters exists on flex counter + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", "PG_WATERMARK_STAT_COUNTER:%s"%oid_list[-1]) + assert len(fields) == 1 + + # remove port + port_oid = self.counters_db.get_entry("COUNTERS_PORT_NAME_MAP", "")[PORT] + self.dvs_port.remove_port(PORT) + dvs.get_asic_db().wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_PORT", port_oid) + + # verify counters were removed from flex counter table + for oid in oid_list: + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", "PG_WATERMARK_STAT_COUNTER:%s"%oid) + assert len(fields) == 0 + + # add port and wait until the port is added on asic db + num_of_keys_without_port = len(dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT")) + self.config_db.create_entry("PORT", PORT, fvs) + dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_keys_without_port + 1) + dvs.get_counters_db().wait_for_fields("COUNTERS_PG_NAME_MAP", "", ["%s:0"%(PORT)]) + + # verify counter was added + for priority in range(0,7): + oid = dvs.get_counters_db().get_entry("COUNTERS_PG_NAME_MAP", "")["%s:%d"%(PORT, priority)] + + # verify that counters exists on flex counter + fields = self.flex_db.get_entry("FLEX_COUNTER_TABLE", "PG_WATERMARK_STAT_COUNTER:%s"%oid) + assert len(fields) == 1 + + finally: + self.clear_flex_counter() diff --git a/tests/test_watermark.py b/tests/test_watermark.py index a8cee70aa147..23efedcb42df 100644 --- a/tests/test_watermark.py +++ b/tests/test_watermark.py @@ -104,8 +104,22 @@ def verify_value(self, dvs, obj_ids, table_name, watermark_name, expected_value) assert found, "no such watermark found" def set_up_flex_counter(self, dvs): - fc_status_enable = {"FLEX_COUNTER_STATUS": "enable"} + for q in self.qs: + self.flex_db.create_entry("FLEX_COUNTER_TABLE", + "QUEUE_WATERMARK_STAT_COUNTER:{}".format(q), + WmFCEntry.queue_stats_entry) + + for pg in self.pgs: + self.flex_db.create_entry("FLEX_COUNTER_TABLE", + "PG_WATERMARK_STAT_COUNTER:{}".format(pg), + WmFCEntry.pg_stats_entry) + + for buffer in self.buffers: + self.flex_db.create_entry("FLEX_COUNTER_TABLE", + "BUFFER_POOL_WATERMARK_STAT_COUNTER:{}".format(buffer), + WmFCEntry.buffer_stats_entry) + fc_status_enable = {"FLEX_COUNTER_STATUS": "enable"} self.config_db.create_entry("FLEX_COUNTER_TABLE", "PG_WATERMARK", fc_status_enable) @@ -116,8 +130,7 @@ def set_up_flex_counter(self, dvs): "BUFFER_POOL_WATERMARK", fc_status_enable) - # Wait for DB's to populate by orchagent - time.sleep(2) + self.populate_asic_all(dvs, "0") def clear_flex_counter(self, dvs): for q in self.qs: @@ -137,14 +150,10 @@ def clear_flex_counter(self, dvs): self.config_db.delete_entry("FLEX_COUNTER_TABLE", "BUFFER_POOL_WATERMARK") def set_up(self, dvs): - self.pgs = self.counters_db.db_connection.hgetall("COUNTERS_PG_NAME_MAP").values() - assert self.pgs is not None and len(self.pgs) > 0 - self.qs = self.counters_db.db_connection.hgetall("COUNTERS_QUEUE_NAME_MAP").values() - assert self.qs is not None and len(self.pgs) > 0 + self.qs = self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_QUEUE") + self.pgs = self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP") self.buffers = self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_POOL") - self.populate_asic_all(dvs, "0") - db = swsscommon.DBConnector(swsscommon.COUNTERS_DB, dvs.redis_sock, 0) tbl = swsscommon.Table(db, "COUNTERS_QUEUE_TYPE_MAP") @@ -171,9 +180,9 @@ def clear_watermark(self, dvs, data): def test_telemetry_period(self, dvs): self.setup_dbs(dvs) - self.set_up_flex_counter(dvs) self.set_up(dvs) try: + self.set_up_flex_counter(dvs) self.enable_unittests(dvs, "true") self.populate_asic_all(dvs, "100")