diff --git a/src/sonic_ax_impl/mibs/__init__.py b/src/sonic_ax_impl/mibs/__init__.py index dbe4d6f4f..86a7be12d 100644 --- a/src/sonic_ax_impl/mibs/__init__.py +++ b/src/sonic_ax_impl/mibs/__init__.py @@ -25,6 +25,23 @@ TABLE_NAME_SEPARATOR_COLON = ':' TABLE_NAME_SEPARATOR_VBAR = '|' +RIF_COUNTERS_AGGR_MAP = { + "SAI_PORT_STAT_IF_IN_OCTETS": "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS", + "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS", + "SAI_PORT_STAT_IF_IN_ERRORS": "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS", + "SAI_PORT_STAT_IF_OUT_OCTETS": "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS", + "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS", + "SAI_PORT_STAT_IF_OUT_ERRORS": "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS" +} + +RIF_DROPS_AGGR_MAP = { + "SAI_PORT_STAT_IF_IN_ERRORS": "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS", + "SAI_PORT_STAT_IF_OUT_ERRORS": "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS" +} + +# IfIndex to OID multiplier for transceiver +IFINDEX_SUB_ID_MULTIPLIER = 1000 + redis_kwargs = {'unix_socket_path': '/var/run/redis/redis.sock'} @@ -134,6 +151,14 @@ def if_entry_table(if_name): return 'PORT_TABLE:' + if_name +def vlan_entry_table(if_name): + """ + :param if_name: given interface to cast. + :return: VLAN_TABLE key. + """ + return b'VLAN_TABLE:' + if_name + + def lag_entry_table(lag_name): """ :param lag_name: given lag to cast. @@ -290,6 +315,46 @@ def init_sync_d_interface_tables(db_conn): return if_name_map, if_alias_map, if_id_map, oid_name_map + +def init_sync_d_rif_tables(db_conn): + """ + Initializes map of RIF SAI oids to port SAI oid. + :return: dict + """ + rif_port_map = {get_sai_id_key(db_conn.namespace, rif): get_sai_id_key(db_conn.namespace, port) + for rif, port in port_util.get_rif_port_map(db_conn).items()} + port_rif_map = {port: rif for rif, port in rif_port_map.items()} + logger.debug("Rif port map:\n" + pprint.pformat(rif_port_map, indent=2)) + + return rif_port_map, port_rif_map + + +def init_sync_d_vlan_tables(db_conn): + """ + Initializes vlan interface maps for SyncD-connected MIB(s). + :return: tuple(vlan_name_map, oid_sai_map, oid_name_map) + """ + + vlan_name_map = port_util.get_vlan_interface_oid_map(db_conn) + + logger.debug("Vlan oid map:\n" + pprint.pformat(vlan_name_map, indent=2)) + + # { OID -> sai_id } + oid_sai_map = {get_index_from_str(if_name): sai_id for sai_id, if_name in vlan_name_map.items() + # only map the interface if it's a style understood to be a SONiC interface. + if get_index_from_str(if_name) is not None} + logger.debug("OID sai map:\n" + pprint.pformat(oid_sai_map, indent=2)) + + # { OID -> if_name (SONiC) } + oid_name_map = {get_index_from_str(if_name): if_name for sai_id, if_name in vlan_name_map.items() + # only map the interface if it's a style understood to be a SONiC interface. + if get_index_from_str(if_name) is not None} + + logger.debug("OID name map:\n" + pprint.pformat(oid_name_map, indent=2)) + + return vlan_name_map, oid_sai_map, oid_name_map + + def init_sync_d_lag_tables(db_conn): """ Helper method. Connects to and initializes LAG interface maps for SyncD-connected MIB(s). @@ -304,13 +369,19 @@ def init_sync_d_lag_tables(db_conn): if_name_lag_name_map = {} # { OID -> lag_name (SONiC) } oid_lag_name_map = {} + # { lag_name (SONiC) -> lag_oid (SAI) } + lag_sai_map = {} db_conn.connect(APPL_DB) lag_entries = db_conn.keys(APPL_DB, "LAG_TABLE:*") if not lag_entries: - return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map + return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map, lag_sai_map + + db_conn.connect(COUNTERS_DB) + lag_sai_map = db_conn.get_all(COUNTERS_DB, "COUNTERS_LAG_NAME_MAP") + lag_sai_map = {name: get_sai_id_key(db_conn.namespace, sai_id.lstrip("oid:0x")) for name, sai_id in lag_sai_map.items()} for lag_entry in lag_entries: lag_name = lag_entry[len("LAG_TABLE:"):] @@ -332,7 +403,7 @@ def member_name_str(val, lag_name): if idx: oid_lag_name_map[idx] = if_name - return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map + return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map, lag_sai_map def init_sync_d_queue_tables(db_conn): """ @@ -347,7 +418,7 @@ def init_sync_d_queue_tables(db_conn): # Parse the queue_name_map and create the following maps: # port_queues_map -> {"port_index : queue_index" : sai_oid} - # queue_stat_map -> {"port_index : queue stat table name" : {counter name : value}} + # queue_stat_map -> {"port_index : queue stat table name" : {counter name : value}} # port_queue_list_map -> {port_index: [sorted queue list]} port_queues_map = {} queue_stat_map = {} @@ -411,7 +482,7 @@ class RedisOidTreeUpdater(MIBUpdater): def __init__(self, prefix_str): super().__init__() - self.db_conn = Namespace.init_namespace_dbs() + self.db_conn = Namespace.init_namespace_dbs() if prefix_str.startswith('.'): prefix_str = prefix_str[1:] self.prefix_str = prefix_str @@ -524,7 +595,7 @@ def dbs_get_all(dbs, db_name, _hash, *args, **kwargs): db get_all function executed on global and all namespace DBs. """ result = {} - # If there are multiple namespaces, _hash might not be + # If there are multiple namespaces, _hash might not be # present in all namespace, ignore if not present in a # specfic namespace. if len(dbs) > 1: diff --git a/src/sonic_ax_impl/mibs/ietf/rfc1213.py b/src/sonic_ax_impl/mibs/ietf/rfc1213.py index 52c8b82b8..0fee186a5 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc1213.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc1213.py @@ -49,7 +49,8 @@ class DbTables(int, Enum): class IfTypes(int, Enum): """ IANA ifTypes """ ethernetCsmacd = 6 - ieee8023adLag = 161 + l3ipvlan = 136 + ieee8023adLag = 161 class ArpUpdater(MIBUpdater): def __init__(self): @@ -191,8 +192,13 @@ def __init__(self): self.lag_name_if_name_map = {} self.if_name_lag_name_map = {} self.oid_lag_name_map = {} + self.lag_sai_map = {} self.mgmt_oid_name_map = {} self.mgmt_alias_map = {} + self.vlan_oid_name_map = {} + self.vlan_name_map = {} + self.rif_port_map = {} + self.port_rif_map = {} # cache of interface counters self.if_counters = {} @@ -201,6 +207,8 @@ def __init__(self): self.if_alias_map = {} self.if_id_map = {} self.oid_name_map = {} + self.rif_counters = {} + self.namespace_db_map = Namespace.get_namespace_db_map(self.db_conn) def reinit_data(self): @@ -219,26 +227,50 @@ def reinit_data(self): self.mgmt_oid_name_map, \ self.mgmt_alias_map = mibs.init_mgmt_interface_tables(self.db_conn[0]) + self.vlan_name_map, \ + self.vlan_oid_sai_map, \ + self.vlan_oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_vlan_tables, self.db_conn) + + self.rif_port_map, \ + self.port_rif_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_rif_tables, self.db_conn) + def update_data(self): """ Update redis (caches config) Pulls the table references for each interface. """ - for sai_id_key in self.if_id_map: - namespace, sai_id = mibs.split_sai_id_key(sai_id_key) - if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) - self.if_counters[if_idx] = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ - mibs.counter_table(sai_id), blocking=True) + + self.update_if_counters() + self.update_rif_counters() + + self.aggregate_counters() self.lag_name_if_name_map, \ self.if_name_lag_name_map, \ - self.oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) + self.oid_lag_name_map, \ + self.lag_sai_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) self.if_range = sorted(list(self.oid_name_map.keys()) + list(self.oid_lag_name_map.keys()) + - list(self.mgmt_oid_name_map.keys())) + list(self.mgmt_oid_name_map.keys()) + + list(self.vlan_oid_name_map.keys())) self.if_range = [(i,) for i in self.if_range] + def update_if_counters(self): + for sai_id_key in self.if_id_map: + namespace, sai_id = mibs.split_sai_id_key(sai_id_key) + if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) + self.if_counters[if_idx] = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, \ + mibs.counter_table(sai_id), blocking=True) + + def update_rif_counters(self): + rif_sai_ids = list(self.rif_port_map) + list(self.vlan_name_map) + self.rif_counters = \ + {sai_id: Namespace.dbs_get_all(self.db_conn, mibs.COUNTERS_DB, + mibs.counter_table(mibs.split_sai_id_key(sai_id)[1]), + blocking=False) + for sai_id in rif_sai_ids} + def get_next(self, sub_id): """ :param sub_id: The 1-based sub-identifier query. @@ -280,6 +312,8 @@ def interface_description(self, sub_id): return self.oid_lag_name_map[oid] elif oid in self.mgmt_oid_name_map: return self.mgmt_alias_map[self.mgmt_oid_name_map[oid]] + elif oid in self.vlan_oid_name_map: + return self.vlan_oid_name_map[oid] return self.if_alias_map[self.oid_name_map[oid]] @@ -302,6 +336,31 @@ def _get_counter(self, oid, table_name): mibs.logger.warning("SyncD 'COUNTERS_DB' missing attribute '{}'.".format(e)) return None + def aggregate_counters(self): + """ + For ports with l3 router interfaces l3 drops may be counted separately (RIF counters) + add l3 drops to l2 drop counters cache according to mapping + + For l3vlan map l3 counters to l2 counters + """ + for rif_sai_id, port_sai_id in self.rif_port_map.items(): + if port_sai_id in self.if_id_map: + port_idx = mibs.get_index_from_str(self.if_id_map[port_sai_id]) + for port_counter_name, rif_counter_name in mibs.RIF_DROPS_AGGR_MAP.items(): + self.if_counters[port_idx][port_counter_name] = \ + int(self.if_counters[port_idx][port_counter_name]) + \ + int(self.rif_counters[rif_sai_id][rif_counter_name]) + + for vlan_sai_id, vlan_name in self.vlan_name_map.items(): + for port_counter_name, rif_counter_name in mibs.RIF_COUNTERS_AGGR_MAP.items(): + vlan_idx = mibs.get_index_from_str(vlan_name) + vlan_rif_counters = self.rif_counters[vlan_sai_id] + if rif_counter_name in vlan_rif_counters: + self.if_counters.setdefault(vlan_idx, {}) + self.if_counters[vlan_idx][port_counter_name] = \ + int(vlan_rif_counters[rif_counter_name]) + + def get_counter(self, sub_id, table_name): """ :param sub_id: The 1-based sub-identifier query. @@ -321,7 +380,13 @@ def get_counter(self, sub_id, table_name): counter_value = 0 for lag_member in self.lag_name_if_name_map[self.oid_lag_name_map[oid]]: counter_value += self._get_counter(mibs.get_index_from_str(lag_member), table_name) - + sai_lag_id = self.lag_sai_map[self.oid_lag_name_map[oid]] + sai_lag_rif_id = self.port_rif_map[sai_lag_id] + if sai_lag_rif_id in self.rif_port_map: + table_name = getattr(table_name, 'name', table_name) + if table_name in mibs.RIF_DROPS_AGGR_MAP: + rif_table_name = mibs.RIF_DROPS_AGGR_MAP[table_name] + counter_value += int(self.rif_counters[sai_lag_rif_id].get(rif_table_name, 0)) # truncate to 32-bit counter return counter_value & 0x00000000ffffffff else: @@ -351,6 +416,8 @@ def _get_if_entry(self, sub_id): elif oid in self.mgmt_oid_name_map: if_table = mibs.mgmt_if_entry_table(self.mgmt_oid_name_map[oid]) db = mibs.CONFIG_DB + elif oid in self.vlan_oid_name_map: + if_table = mibs.vlan_entry_table(self.vlan_oid_name_map[oid]) elif oid in self.oid_name_map: if_table = mibs.if_entry_table(self.oid_name_map[oid]) else: @@ -455,6 +522,7 @@ def get_if_type(self, sub_id): ethernetCsmacd(6), -- for all ethernet-like interfaces, -- regardless of speed, as per RFC3635 + l3ipvlan(136) -- Layer 3 Virtual LAN using IP ieee8023adLag(161) -- IEEE 802.3ad Link Aggregate """ oid = self.get_oid(sub_id) @@ -463,6 +531,8 @@ def get_if_type(self, sub_id): if oid in self.oid_lag_name_map: return IfTypes.ieee8023adLag + elif oid in self.vlan_oid_name_map: + return IfTypes.l3ipvlan else: return IfTypes.ethernetCsmacd diff --git a/src/sonic_ax_impl/mibs/ietf/rfc2863.py b/src/sonic_ax_impl/mibs/ietf/rfc2863.py index 931c560f8..1bfa4a588 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc2863.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc2863.py @@ -79,7 +79,7 @@ def reinit_data(self): self.lag_name_if_name_map, \ self.if_name_lag_name_map, \ - self.oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) + self.oid_lag_name_map, _ = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) """ db_conn - will have db_conn to all namespace DBs and global db. First db in the list is global db. diff --git a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py index ca2516cd5..4fbc53650 100644 --- a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py +++ b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py @@ -52,7 +52,7 @@ def update_data(self): self.lag_name_if_name_map, \ self.if_name_lag_name_map, \ - self.oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) + self.oid_lag_name_map, _ = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) self.if_range = sorted(list(self.oid_name_map.keys()) + list(self.oid_lag_name_map.keys())) self.if_range = [(i,) for i in self.if_range] @@ -94,7 +94,7 @@ def _get_counter(self, oid, counter_name): _counter_name = getattr(counter_name, 'name', counter_name) try: - counter_value = self.if_counters[oid][_counter_name] + counter_value = self.if_counters[oid][_counter_name] counter_value = int(counter_value) & 0xffffffffffffffff # done! return counter_value diff --git a/tests/mock_tables/asic0/asic_db.json b/tests/mock_tables/asic0/asic_db.json index 590918051..81f5ca798 100644 --- a/tests/mock_tables/asic0/asic_db.json +++ b/tests/mock_tables/asic0/asic_db.json @@ -23,5 +23,12 @@ "SAI_BRIDGE_PORT_ATTR_TYPE": "SAI_BRIDGE_PORT_TYPE_PORT", "SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x1000000000005", "SAI_BRIDGE_PORT_ATTR_ADMIN_STATE": "true" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000006": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000007" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x1000000000007": { + "NULL": "NULL" } } diff --git a/tests/mock_tables/asic0/counters_db.json b/tests/mock_tables/asic0/counters_db.json index 282a4b952..f1748c808 100644 --- a/tests/mock_tables/asic0/counters_db.json +++ b/tests/mock_tables/asic0/counters_db.json @@ -206,14 +206,14 @@ "COUNTERS:oid:0x1000000000005": { "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_IF_OUT_ERRORS": "100", "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_IF_IN_ERRORS": "100", "SAI_PORT_STAT_ETHER_STATS_PKTS": "0", "SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0", "SAI_PORT_STAT_IF_IN_DISCARDS": "0", @@ -245,7 +245,7 @@ "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_OUT_OCTETS": "100", "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", @@ -260,17 +260,17 @@ "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_IF_OUT_UCAST_PKTS": "100", "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_IF_IN_UCAST_PKTS": "100", "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_IF_IN_OCTETS": "100", "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", @@ -314,6 +314,46 @@ "COUNTERS_LAG_NAME_MAP": { "PortChannel01": "oid:0x1000000000007" }, + "COUNTERS_RIF_NAME_MAP": { + "Ethernet0": "oid:0x6000000000015", + "PortChannel01": "oid:0x6000000000006", + "Vlan1000": "oid:0x60000000005d0" + }, + "COUNTERS_RIF_TYPE_MAP": { + "oid:0x6000000000015": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000000006": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x60000000005d0": "SAI_ROUTER_INTERFACE_TYPE_VLAN" + }, + "COUNTERS:oid:0x6000000000006": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "116", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "226", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "12", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "212", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "336" + }, + "COUNTERS:oid:0x6000000000015": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "10", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "2048", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "1", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "55", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "20", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "4096", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "2", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "110" + }, + "COUNTERS:oid:0x60000000005d0": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "10", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "2048", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "1", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "55", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "20", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "4096", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "2", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "110" + }, "COUNTERS:oid:0x1000000000004": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", diff --git a/tests/mock_tables/asic1/appl_db.json b/tests/mock_tables/asic1/appl_db.json index 3c03bcc12..aa91c5382 100644 --- a/tests/mock_tables/asic1/appl_db.json +++ b/tests/mock_tables/asic1/appl_db.json @@ -45,13 +45,17 @@ "speed": 1000, "alias": "etp6" }, + "PORT_TABLE:Ethernet16": { + "speed": 1000, + "alias": "etp16" + }, "PORT_TABLE:Ethernet-BP8": { "alias": "etp7" }, "PORT_TABLE:Ethernet-BP12": { "description": "snowflake", "alias": "etp8", - "speed": 1000 + "speed": 1000 }, "ROUTE_TABLE:0.0.0.0/0": { "ifname": "Ethernet8,Ethernet12", diff --git a/tests/mock_tables/asic1/asic_db.json b/tests/mock_tables/asic1/asic_db.json index 9da04af83..4650923fb 100644 --- a/tests/mock_tables/asic1/asic_db.json +++ b/tests/mock_tables/asic1/asic_db.json @@ -7,5 +7,19 @@ "SAI_BRIDGE_PORT_ATTR_TYPE": "SAI_BRIDGE_PORT_TYPE_PORT", "SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x1000000000005", "SAI_BRIDGE_PORT_ATTR_ADMIN_STATE": "true" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000015": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000003" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000001abc": { + "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "101", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000010", + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000001abd": { + "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "102", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000010", + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT" } } diff --git a/tests/mock_tables/asic1/counters_db.json b/tests/mock_tables/asic1/counters_db.json index 86289526d..7304ffe10 100644 --- a/tests/mock_tables/asic1/counters_db.json +++ b/tests/mock_tables/asic1/counters_db.json @@ -309,12 +309,27 @@ "Ethernet8": "oid:0x1000000000003", "Ethernet12": "oid:0x1000000000004", "Ethernet-BP8": "oid:0x1000000000005", - "Ethernet-BP12": "oid:0x1000000000006" + "Ethernet-BP12": "oid:0x1000000000006", + "Ethernet16": "oid:0x1000000000010" }, "COUNTERS_LAG_NAME_MAP": { "PortChannel02": "oid:0x1000000000007" }, - "COUNTERS:oid:0x1000000000004": { + "COUNTERS_RIF_TYPE_MAP": { + "oid:0x6000000000015": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000000012": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000001abc": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT", + "oid:0x6000000001abd": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT", + "oid:0x60000000005d1": "SAI_ROUTER_INTERFACE_TYPE_VLAN" + }, + "COUNTERS_RIF_NAME_MAP": { + "Ethernet8": "oid:0x6000000000015", + "PortChannel02": "oid:0x6000000000012", + "Vlan1001": "oid:0x60000000005d1", + "Ethernet16.101": "oid:0x6000000001abc", + "Ethernet16.102": "oid:0x6000000001abd" + }, + "COUNTERS:oid:0x1000000000010": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", "SAI_PORT_STAT_IF_OUT_ERRORS": "0", @@ -416,7 +431,37 @@ "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" }, - "COUNTERS:oid:0x1000000000003": { + "COUNTERS:oid:0x6000000001abc": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "101" + }, + "COUNTERS:oid:0x6000000001abd": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "102" + }, + "COUNTERS:oid:0x6000000000015": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "10", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "2048", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "1", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "55", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "20", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "4096", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "2", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "110" + }, + "COUNTERS:oid:0x1000000000004": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", "SAI_PORT_STAT_IF_OUT_ERRORS": "0", @@ -502,6 +547,108 @@ "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:0x1000000000003": { + "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", + "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_ERRORS": "100", + "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": "100", + "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": "100", + "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": "100", + "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": "100", + "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": "100", + "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": "209347219842134092490", "SAI_PORT_STAT_PFC_1_RX_PKTS": "2", "SAI_PORT_STAT_PFC_1_TX_PKTS": "2", diff --git a/tests/mock_tables/asic2/counters_db.json b/tests/mock_tables/asic2/counters_db.json index 6b8058da0..36b0ff839 100644 --- a/tests/mock_tables/asic2/counters_db.json +++ b/tests/mock_tables/asic2/counters_db.json @@ -315,6 +315,12 @@ "PortChannel03": "oid:0x1000000000007", "PortChannel04": "oid:0x1000000000008" }, + "COUNTERS_RIF_NAME_MAP": { + "PortChannel03": "oid:0x6000000000017" + }, + "COUNTERS_RIF_TYPE_MAP": { + "oid:0x6000000000017": "SAI_ROUTER_INTERFACE_TYPE_PORT" + }, "COUNTERS:oid:0x1000000000004": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", diff --git a/tests/mock_tables/asic_db.json b/tests/mock_tables/asic_db.json index bdec0aeb5..1eaa2e4c4 100644 --- a/tests/mock_tables/asic_db.json +++ b/tests/mock_tables/asic_db.json @@ -16,5 +16,51 @@ "SAI_BRIDGE_PORT_ATTR_TYPE": "SAI_BRIDGE_PORT_TYPE_PORT", "SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x1000000000008", "SAI_BRIDGE_PORT_ATTR_ADMIN_STATE": "true" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000015": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000015" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000005d0": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_VLAN", + "SAI_ROUTER_INTERFACE_ATTR_VLAN_ID": "oid:0x26000000005d0" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000006": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x2000000000006" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000005": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x2000000000005" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000004": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x2000000000004" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000001abc": { + "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "101", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000017", + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000001abd": { + "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "102", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x1000000000017", + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000003": { + "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": "oid:0x2000000000003" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000006": { + "NULL": "NULL" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000005": { + "NULL": "NULL" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000004": { + "NULL": "NULL" + }, + "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000003": { + "NULL": "NULL" } } diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 0ec1fa1c7..5003e4f12 100644 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -920,14 +920,14 @@ "COUNTERS:oid:0x1000000000006": { "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_IF_OUT_ERRORS": "100", "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_IF_IN_ERRORS": "100", "SAI_PORT_STAT_ETHER_STATS_PKTS": "0", "SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0", "SAI_PORT_STAT_IF_IN_DISCARDS": "0", @@ -959,7 +959,7 @@ "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_OUT_OCTETS": "100", "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", @@ -974,17 +974,17 @@ "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_IF_OUT_UCAST_PKTS": "100", "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_IF_IN_UCAST_PKTS": "100", "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_IF_IN_OCTETS": "100", "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", @@ -2278,7 +2278,110 @@ "Ethernet68": "oid:0x1000000000020" }, "COUNTERS_LAG_NAME_MAP": { - "PortChannel01": "oid:0x1000000000023" + "PortChannel01": "oid:0x2000000000006", + "PortChannel02": "oid:0x2000000000005", + "PortChannel03": "oid:0x2000000000004", + "PortChannel04": "oid:0x2000000000003" + }, + "COUNTERS_RIF_NAME_MAP": { + "Ethernet20": "oid:0x6000000000015", + "Ethernet8.101": "oid:0x6000000001abc", + "Ethernet8.102": "oid:0x6000000001abd", + "PortChannel01": "oid:0x6000000000006", + "PortChannel02": "oid:0x6000000000005", + "PortChannel03": "oid:0x6000000000004", + "PortChannel04": "oid:0x6000000000003", + "Vlan1000": "oid:0x60000000005d0" + }, + "COUNTERS_RIF_TYPE_MAP": { + "oid:0x6000000000015": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000001abc": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT", + "oid:0x6000000001abd": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT", + "oid:0x6000000000006": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000000005": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000000004": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x6000000000003": "SAI_ROUTER_INTERFACE_TYPE_PORT", + "oid:0x60000000005d0": "SAI_ROUTER_INTERFACE_TYPE_VLAN" + }, + "COUNTERS:oid:0x6000000000015": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "10", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "2048", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "1", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "55", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "20", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "4096", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "2", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "110" + }, + "COUNTERS:oid:0x60000000005d0": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "10", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "2048", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "1", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "55", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "20", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "4096", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "2", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "110" + }, + "COUNTERS:oid:0x6000000000006": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "116", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "226", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "12", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "212", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "6", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "336" + }, + "COUNTERS:oid:0x6000000000005": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "0" + }, + "COUNTERS:oid:0x6000000000004": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "0" + }, + "COUNTERS:oid:0x6000000001abc": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "101", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "101" + }, + "COUNTERS:oid:0x6000000001abd": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "102", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "102" + }, + "COUNTERS:oid:0x6000000000003": { + "SAI_ROUTER_INTERFACE_STAT_IN_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS": "0", + "SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS": "0" }, "COUNTERS:oid:0x1000000000009": { "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", @@ -2997,14 +3100,14 @@ "COUNTERS:oid:0x1000000000015": { "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_IF_OUT_ERRORS": "100", "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_IF_IN_ERRORS": "100", "SAI_PORT_STAT_ETHER_STATS_PKTS": "0", "SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0", "SAI_PORT_STAT_IF_IN_DISCARDS": "0", @@ -3036,7 +3139,7 @@ "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_OUT_OCTETS": "100", "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", @@ -3051,17 +3154,17 @@ "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_IF_OUT_UCAST_PKTS": "100", "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_IF_IN_UCAST_PKTS": "100", "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_IF_IN_OCTETS": "100", "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", diff --git a/tests/namespace/test_interfaces.py b/tests/namespace/test_interfaces.py index ea51339f8..b9b0c192f 100644 --- a/tests/namespace/test_interfaces.py +++ b/tests/namespace/test_interfaces.py @@ -237,7 +237,7 @@ def test_if_type_portchannel(self): self.assertEqual(value0.data, 161) def test_getnextpdu_first_bp_ifindex(self): - oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1,1004)) + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 8999)) get_pdu = GetNextPDU( header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -367,6 +367,495 @@ def test_in_octets_override(self): self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1)))) self.assertEqual(value0.data, 54321) + def test_vlan_iface(self): + """ + Test that vlan interface is present in the MIB + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 2999)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 3000)))) + self.assertEqual(value0.data, 2999) + + def test_vlan_iface_description(self): + """ + Test vlan interface description (which is simply the name) + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 2, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.OCTET_STRING) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 2, 3000)))) + self.assertEqual(str(value0.data), 'Vlan1000') + + def test_if_type_l3vlan(self): + """ + For l3vlan the type shpuld be 136 + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 3, 2000)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 3, 3000)))) + self.assertEqual(value0.data, 136) + + def test_in_octets_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 9)))) + self.assertEqual(value0.data, 100) + + def test_in_ucast_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 9)))) + self.assertEqual(value0.data, 100) + + def test_in_errors_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9)))) + self.assertEqual(value0.data, 101) + + def test_out_octets_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 9)))) + self.assertEqual(value0.data, 100) + + def test_out_ucast_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 9)))) + self.assertEqual(value0.data, 100) + + def test_out_errors_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9)))) + self.assertEqual(value0.data, 102) + + def test_in_octets_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 3000)))) + self.assertEqual(value0.data, 2048) + + def test_in_ucast_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 3000)))) + self.assertEqual(value0.data, 10) + + def test_in_errors_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 3000)))) + self.assertEqual(value0.data, 1) + + def test_out_octets_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 3000)))) + self.assertEqual(value0.data, 4096) + + def test_out_ucast_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 3000)))) + self.assertEqual(value0.data, 20) + + def test_out_errors_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 3000)))) + self.assertEqual(value0.data, 2) + + def test_in_octets_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 17)))) + self.assertEqual(value0.data, 0) + + def test_in_ucast_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 17)))) + self.assertEqual(value0.data, 0) + + def test_in_errors_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 17)))) + self.assertEqual(value0.data, 203) + + def test_out_octets_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 17)))) + self.assertEqual(value0.data, 0) + + def test_out_ucast_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 17)))) + self.assertEqual(value0.data, 0) + + def test_out_errors_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 17)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 17)))) + self.assertEqual(value0.data, 203) + + def test_in_octets_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1001)))) + self.assertEqual(value0.data, 100) + + def test_in_ucast_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)))) + self.assertEqual(value0.data, 100) + + def test_in_errors_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)))) + self.assertEqual(value0.data, 106) + + def test_out_octets_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)))) + self.assertEqual(value0.data, 100) + + def test_out_ucast_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)))) + self.assertEqual(value0.data, 100) + + def test_out_errors_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)))) + self.assertEqual(value0.data, 106) + @classmethod def tearDownClass(cls): tests.mock_tables.dbconnector.clean_up_config() diff --git a/tests/namespace/test_mibs.py b/tests/namespace/test_mibs.py index 3e76485cd..3699c04d5 100644 --- a/tests/namespace/test_mibs.py +++ b/tests/namespace/test_mibs.py @@ -21,7 +21,8 @@ def test_init_namespace_sync_d_lag_tables(self): lag_name_if_name_map, \ if_name_lag_name_map, \ - oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, dbs) + oid_lag_name_map, \ + lag_sai_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, dbs) #PortChannel in asic0 Namespace self.assertTrue("PortChannel01" in lag_name_if_name_map) self.assertTrue("Ethernet-BP0" in lag_name_if_name_map["PortChannel01"]) diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py index ae4ee53c4..cb654c642 100644 --- a/tests/test_interfaces.py +++ b/tests/test_interfaces.py @@ -365,3 +365,492 @@ def test_in_octets_override(self): self.assertEqual(value0.type_, ValueType.COUNTER_32) self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1)))) self.assertEqual(value0.data, 54321) + + def test_vlan_iface(self): + """ + Test that vlan interface is present in the MIB + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 2999)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 1, 3000)))) + self.assertEqual(value0.data, 2999) + + def test_vlan_iface_description(self): + """ + Test vlan interface description (which is simply the name) + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 2, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.OCTET_STRING) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 2, 3000)))) + self.assertEqual(str(value0.data), 'Vlan1000') + + def test_if_type_l3vlan(self): + """ + For l3vlan the type shpuld be 136 + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 3, 2000)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + encoded = get_pdu.encode() + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 3, 3000)))) + self.assertEqual(value0.data, 136) + + def test_in_octets_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 21)))) + self.assertEqual(value0.data, 100) + + def test_in_ucast_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 21)))) + self.assertEqual(value0.data, 100) + + def test_in_errors_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 21)))) + self.assertEqual(value0.data, 101) + + def test_out_octets_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 21)))) + self.assertEqual(value0.data, 100) + + def test_out_ucast_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 21)))) + self.assertEqual(value0.data, 100) + + def test_out_errors_rif(self): + """ + For a port with RIF the counter values are aggregated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 21)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 21)))) + self.assertEqual(value0.data, 102) + + def test_in_octets_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 3000)))) + self.assertEqual(value0.data, 2048) + + def test_in_ucast_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 3000)))) + self.assertEqual(value0.data, 10) + + def test_in_errors_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 3000)))) + self.assertEqual(value0.data, 1) + + def test_out_octets_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 3000)))) + self.assertEqual(value0.data, 4096) + + def test_out_ucast_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 3000)))) + self.assertEqual(value0.data, 20) + + def test_out_errors_vlan(self): + """ + For a l3 Vlan values are mapped from RIF stats + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 3000)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 3000)))) + self.assertEqual(value0.data, 2) + + def test_in_octets_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 9)))) + self.assertEqual(value0.data, 0) + + def test_in_ucast_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 9)))) + self.assertEqual(value0.data, 0) + + def test_in_errors_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9)))) + self.assertEqual(value0.data, 203) + + def test_out_octets_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 9)))) + self.assertEqual(value0.data, 0) + + def test_out_ucast_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 9)))) + self.assertEqual(value0.data, 0) + + def test_out_errors_vlan_subinterface(self): + """ + For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9)))) + self.assertEqual(value0.data, 203) + + def test_in_octets_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1001)))) + self.assertEqual(value0.data, 100) + + def test_in_ucast_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)))) + self.assertEqual(value0.data, 100) + + def test_in_errors_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)))) + self.assertEqual(value0.data, 106) + + def test_out_octets_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)))) + self.assertEqual(value0.data, 100) + + def test_out_ucast_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)))) + self.assertEqual(value0.data, 100) + + def test_out_errors_portchannel(self): + """ + For a l3 portchannel interface value is accumulated on members plus added Rif counters + """ + oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)) + get_pdu = GetPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + print(response) + + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.COUNTER_32) + self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)))) + self.assertEqual(value0.data, 106) diff --git a/tests/test_mibs.py b/tests/test_mibs.py index 6fb461760..5ad938a04 100644 --- a/tests/test_mibs.py +++ b/tests/test_mibs.py @@ -14,14 +14,15 @@ class TestGetNextPDU(TestCase): @classmethod def setUpClass(cls): #For single namespace scenario, load database_config.json - tests.mock_tables.dbconnector.load_database_config() + tests.mock_tables.dbconnector.load_database_config() def test_init_sync_d_lag_tables(self): db_conn = Namespace.init_namespace_dbs() lag_name_if_name_map, \ if_name_lag_name_map, \ - oid_lag_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, db_conn) + oid_lag_name_map, \ + lag_sai_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, db_conn) self.assertTrue("PortChannel04" in lag_name_if_name_map) self.assertTrue(lag_name_if_name_map["PortChannel04"] == ["Ethernet124"]) @@ -30,3 +31,4 @@ def test_init_sync_d_lag_tables(self): self.assertTrue("PortChannel_Temp" in lag_name_if_name_map) self.assertTrue(lag_name_if_name_map["PortChannel_Temp"] == []) + self.assertTrue(lag_sai_map["PortChannel01"] == "2000000000006")