Skip to content

Commit

Permalink
add mock tables for LAG_NAME_MAP_TABLE in COUNTERS_DB (#114)
Browse files Browse the repository at this point in the history
* add mock tables for LAG_NAME_MAP_TABLE in COUNTERS_DB
* Fix init_sync_d_interface_tables(): only return ports and no
portchannels
* Fix mock_tables: counters_db portchannel name follows app_db
  • Loading branch information
anilkpandey authored Apr 12, 2020
1 parent a81b402 commit 7632ee8
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def init_mgmt_interface_tables(db_conn):
return oid_name_map, if_alias_map


# TODO: the function name include interface, but only return port by design. Fix the design or the name
def init_sync_d_interface_tables(db_conn):
"""
Initializes interface maps for SyncD-connected MIB(s).
Expand All @@ -195,6 +196,9 @@ def init_sync_d_interface_tables(db_conn):
# { if_name (SONiC) -> sai_id }
# ex: { "Ethernet76" : "1000000000023" }
if_name_map, if_id_map = port_util.get_interface_oid_map(db_conn)
if_name_map = {if_name: sai_id for if_name, sai_id in if_name_map.items() if re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name.decode())}
if_id_map = {sai_id: if_name for sai_id, if_name in if_id_map.items() if re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name.decode())}

logger.debug("Port name map:\n" + pprint.pformat(if_name_map, indent=2))
logger.debug("Interface name map:\n" + pprint.pformat(if_id_map, indent=2))

Expand Down
105 changes: 105 additions & 0 deletions tests/mock_tables/counters_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,108 @@
"SAI_PORT_STAT_PFC_7_RX_PKTS": "8",
"SAI_PORT_STAT_PFC_7_TX_PKTS": "8"
},
"COUNTERS:oid:0x1000000000023": {
"SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0",
"SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0",
"SAI_PORT_STAT_IF_OUT_ERRORS": "0",
"SAI_PORT_STAT_ETHER_TX_OVERSIZE_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_1519_TO_2047_OCTETS": "0",
"SAI_PORT_STAT_IP_IN_RECEIVES": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0",
"SAI_PORT_STAT_IPV6_OUT_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0",
"SAI_PORT_STAT_IF_IN_ERRORS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0",
"SAI_PORT_STAT_IF_IN_DISCARDS": "0",
"SAI_PORT_STAT_IP_OUT_DISCARDS": "0",
"SAI_PORT_STAT_IF_IN_UNKNOWN_PROTOS": "0",
"SAI_PORT_STAT_IPV6_IN_DISCARDS": "0",
"SAI_PORT_STAT_IPV6_OUT_DISCARDS": "0",
"SAI_PORT_STAT_IPV6_IN_OCTETS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0",
"SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_256_TO_511_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_9217_TO_16383_OCTETS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0",
"SAI_PORT_STAT_IPV6_IN_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0",
"SAI_PORT_STAT_IPV6_OUT_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_IF_IN_VLAN_DISCARDS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0",
"SAI_PORT_STAT_IP_IN_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0",
"SAI_PORT_STAT_IPV6_IN_UCAST_PKTS": "0",
"SAI_PORT_STAT_IPV6_IN_RECEIVES": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_4096_TO_9216_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_DISCARDS": "0",
"SAI_PORT_STAT_ETHER_STATS_DROP_EVENTS": "0",
"SAI_PORT_STAT_IPV6_OUT_MCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_RX_OVERSIZE_PKTS": "0",
"SAI_PORT_STAT_IF_OUT_OCTETS": "0",
"SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_2048_TO_4095_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_512_TO_1023_OCTETS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_RX_NO_ERRORS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_COLLISIONS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_1024_TO_1518_OCTETS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_64_OCTETS": "0",
"SAI_PORT_STAT_IP_OUT_OCTETS": "0",
"SAI_PORT_STAT_IF_IN_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0",
"SAI_PORT_STAT_IP_OUT_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_JABBERS": "0",
"SAI_PORT_STAT_IF_IN_OCTETS": "0",
"SAI_PORT_STAT_IPV6_IN_MCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_65_TO_127_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_QLEN": "0",
"SAI_PORT_STAT_ETHER_STATS_PKTS_128_TO_255_OCTETS": "0",
"SAI_PORT_STAT_IP_IN_DISCARDS": "0",
"SAI_PORT_STAT_IPV6_OUT_OCTETS": "0",
"SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS": "0",
"SAI_PORT_STAT_IP_IN_OCTETS": "0",
"SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0",
"SAI_PORT_STAT_ETHER_STATS_CRC_ALIGN_ERRORS": "0",
"SAI_PORT_STAT_IP_OUT_UCAST_PKTS": "0",
"SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_STATS_MULTICAST_PKTS": "0",
"SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0",
"SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0",
"SAI_PORT_STAT_PAUSE_RX_PKTS": "0",
"SAI_PORT_STAT_PAUSE_TX_PKTS": "0",
"SAI_PORT_STAT_PFC_0_RX_PKTS": "1",
"SAI_PORT_STAT_PFC_0_TX_PKTS": "1",
"SAI_PORT_STAT_PFC_1_RX_PKTS": "2",
"SAI_PORT_STAT_PFC_1_TX_PKTS": "2",
"SAI_PORT_STAT_PFC_2_RX_PKTS": "3",
"SAI_PORT_STAT_PFC_2_TX_PKTS": "3",
"SAI_PORT_STAT_PFC_3_RX_PKTS": "4",
"SAI_PORT_STAT_PFC_3_TX_PKTS": "4",
"SAI_PORT_STAT_PFC_4_RX_PKTS": "5",
"SAI_PORT_STAT_PFC_4_TX_PKTS": "5",
"SAI_PORT_STAT_PFC_5_RX_PKTS": "6",
"SAI_PORT_STAT_PFC_5_TX_PKTS": "6",
"SAI_PORT_STAT_PFC_6_RX_PKTS": "7",
"SAI_PORT_STAT_PFC_6_TX_PKTS": "7",
"SAI_PORT_STAT_PFC_7_RX_PKTS": "8",
"SAI_PORT_STAT_PFC_7_TX_PKTS": "8"
},
"COUNTERS:oid:0x100000000000f": {
"SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0",
"SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0",
Expand Down Expand Up @@ -2175,6 +2277,9 @@
"Ethernet20": "oid:0x1000000000015",
"Ethernet68": "oid:0x1000000000020"
},
"COUNTERS_LAG_NAME_MAP": {
"PortChannel01": "oid:0x1000000000023"
},
"COUNTERS:oid:0x1000000000009": {
"SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0",
"SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0",
Expand Down

0 comments on commit 7632ee8

Please sign in to comment.