diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 9156e2a8c0..6402a93c6f 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4714,6 +4714,10 @@ void PortsOrch::generatePortCounterMap() auto port_counter_stats = generateCounterStats(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP); for (const auto& it: m_portList) { + if (it.first == "CPU") + { + continue; + } port_stat_manager.setCounterIdList(it.second.m_port_id, CounterType::PORT, port_counter_stats); } diff --git a/tests/test_flex_counters.py b/tests/test_flex_counters.py index fca1c0527f..bfa933cbc6 100644 --- a/tests/test_flex_counters.py +++ b/tests/test_flex_counters.py @@ -26,6 +26,7 @@ PG_WATERMARK_MAP = "COUNTERS_PG_NAME_MAP" NUMBER_OF_RETRIES = 10 +CPU_PORT_OID = "0x0" counter_type_dict = {"port_counter":[PORT_KEY, PORT_STAT, PORT_MAP], "queue_counter":[QUEUE_KEY, QUEUE_STAT, QUEUE_MAP], @@ -72,6 +73,10 @@ def verify_flex_counters_populated(self, map, stat): oid = counter_entry[1] self.wait_for_id_list(stat, name, oid) + def verify_cpu_interface_not_in_db(self, stat): + cpu = self.flex_db.db_connection.hgetall("FLEX_COUNTER_TABLE:" + stat + ":" + CPU_PORT_OID) + assert cpu.size() == 0, "FLEX_COUNTER_TABLE:" + stat + ":" + CPU_PORT_OID + " - CPU port exist in DB" + def enable_flex_counter_group(self, group, map): group_stats_entry = {"FLEX_COUNTER_STATUS": "enable"} self.config_db.create_entry("FLEX_COUNTER_TABLE", group, group_stats_entry) @@ -98,5 +103,8 @@ def test_flex_counters(self, dvs, counter_type): self.enable_flex_counter_group(counter_key, counter_map) self.verify_flex_counters_populated(counter_map, counter_stat) + if counter_type == "port_counter": + self.verify_cpu_interface_not_in_db(counter_stat) + if counter_type == "rif_counter": self.config_db.db_connection.hdel('INTERFACE|Ethernet0|192.168.0.1/24', "NULL")