Skip to content

Commit

Permalink
[intfutil_test.py]: Test for Flap Counuter and last flap time.
Browse files Browse the repository at this point in the history
Changes:
-- Test for Flap Counuter and last flap time.
-- handle exception is PORT_FLAP_COUNTER is not present in APP_DB.

Signed-off-by: Praveen Chaudhary <pchaudhary@linkedin.com>
  • Loading branch information
Praveen Chaudhary committed Aug 5, 2021
1 parent acc8073 commit 2691e60
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
5 changes: 4 additions & 1 deletion scripts/intfutil
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,12 @@ class IntfStatus(object):
if self.multi_asic.skip_display(constants.PORT_OBJ, key):
continue

db_flap = int(appl_db_port_status_get(self.db, key, PORT_FLAP_COUNTER))
try:
db_flap = int(appl_db_port_status_get(self.db, key, PORT_FLAP_COUNTER))
cache_flap = int(self.cnstat_cached_dict[key].flap_counter)
except ValueError as e:
db_flap = 0
cache_flap = 0
except Exception as e:
cache_flap = 0
final_flap = str(db_flap - cache_flap)
Expand Down
Binary file removed sonic-utilities-1.2.1.tar.gz
Binary file not shown.
22 changes: 11 additions & 11 deletions tests/intfutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
scripts_path = os.path.join(modules_path, "scripts")

show_interface_status_output="""\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- --------------- ------- ----- ----- --------- --------------- ------ ------- --------------- ----------
Ethernet0 0 25G 9100 rs Ethernet0 routed down up QSFP28 or later off
Ethernet32 13,14,15,16 40G 9100 rs etp9 PortChannel1001 up up N/A off
Ethernet112 93,94,95,96 40G 9100 rs etp29 PortChannel0001 up up N/A off
Ethernet116 89,90,91,92 40G 9100 rs etp30 PortChannel0002 up up N/A off
Ethernet120 101,102,103,104 40G 9100 rs etp31 PortChannel0003 up up N/A off
Ethernet124 97,98,99,100 40G 9100 rs etp32 PortChannel0004 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
--------------- --------------- ------- ----- ----- --------- --------------- ------ ------- --------------- ---------- ------- --------------------
Ethernet0 0 25G 9100 rs Ethernet0 routed down up QSFP28 or later off 0 N/A
Ethernet32 13,14,15,16 40G 9100 rs etp9 PortChannel1001 up up N/A off 0 N/A
Ethernet112 93,94,95,96 40G 9100 rs etp29 PortChannel0001 up up N/A off 0 N/A
Ethernet116 89,90,91,92 40G 9100 rs etp30 PortChannel0002 up up N/A off 0 N/A
Ethernet120 101,102,103,104 40G 9100 rs etp31 PortChannel0003 up up N/A off 0 N/A
Ethernet124 97,98,99,100 40G 9100 rs etp32 PortChannel0004 up up N/A off 0 N/A
PortChannel0001 N/A 40G 9100 N/A N/A routed down up N/A N/A
PortChannel0002 N/A 40G 9100 N/A N/A routed up up N/A N/A
PortChannel0003 N/A 40G 9100 N/A N/A routed up up N/A N/A
Expand All @@ -27,9 +27,9 @@
"""

show_interface_status_Ethernet32_output="""\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
----------- ----------- ------- ----- ----- ------- --------------- ------ ------- ------ ----------
Ethernet32 13,14,15,16 40G 9100 rs etp9 PortChannel1001 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
----------- ----------- ------- ----- ----- ------- --------------- ------ ------- ------ ---------- ------- --------------------
Ethernet32 13,14,15,16 40G 9100 rs etp9 PortChannel1001 up up N/A off 0 N/A
"""

show_interface_description_output="""\
Expand Down
46 changes: 23 additions & 23 deletions tests/multi_asic_intfutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@
scripts_path = os.path.join(modules_path, "scripts")

intf_status_all = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ------------ ------- ----- ----- -------------- --------------- ------ ------- --------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Ethernet64 29,30,31,32 40G 9100 N/A Ethernet1/17 routed up up QSFP28 or later off
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off
Ethernet-BP256 61,62,63,64 40G 9100 N/A Ethernet-BP256 PortChannel4009 up up N/A off
Ethernet-BP260 57,58,59,60 40G 9100 N/A Ethernet-BP260 PortChannel4009 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
--------------- ------------ ------- ----- ----- -------------- --------------- ------ ------- --------------- ---------- ------- --------------------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off 0 N/A
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off 0 N/A
Ethernet64 29,30,31,32 40G 9100 N/A Ethernet1/17 routed up up QSFP28 or later off 0 N/A
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off 0 N/A
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off 0 N/A
Ethernet-BP256 61,62,63,64 40G 9100 N/A Ethernet-BP256 PortChannel4009 up up N/A off 0 N/A
Ethernet-BP260 57,58,59,60 40G 9100 N/A Ethernet-BP260 PortChannel4009 up up N/A off 0 N/A
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A
PortChannel4009 N/A 80G 9100 N/A N/A routed up up N/A N/A
"""
intf_status = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
--------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ---------- ------- --------------------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off 0 N/A
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off 0 N/A
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
"""

intf_status_asic0 = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
--------------- ----------- ------- ----- ----- ----------- --------------- ------ ------- --------------- ---------- ------- --------------------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off 0 N/A
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off 0 N/A
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
"""

intf_status_asic0_all = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ------------ ------- ----- ----- ------------ --------------- ------ ------- --------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC Flaps Last Flap (in UTC)
--------------- ------------ ------- ----- ----- ------------ --------------- ------ ------- --------------- ---------- ------- --------------------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off 0 N/A
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off 0 N/A
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off 0 N/A
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off 0 N/A
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A
"""
Expand Down

0 comments on commit 2691e60

Please sign in to comment.