Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeng-arista committed Jun 1, 2024
1 parent 712ff3c commit 72dbc85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 10 additions & 3 deletions tests/test_fabric_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ def test_voq_switch_fabric_capacity(self, vst):
dvs = dvss[name]
# Get the config information and choose a linecard or fabric card to test.
config_db = dvs.get_config_db()
adb = dvs.get_app_db()
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")

cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'}, polling_config=max_poll)
# enable monitoring
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)

# get state_db infor
Expand All @@ -39,8 +42,12 @@ def test_voq_switch_fabric_capacity(self, vst):
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})

# get current fabric capacity
capacity = sdb.get_entry("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA")['operating_links']
if sdb.get_entry("FABRIC_PORT_TABLE", sdb_port)['STATUS'] == 'up':
fvs = sdb.wait_for_fields("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA",['operating_links'], polling_config=max_poll)
capacity = fvs['operating_links']

fvs = sdb.wait_for_fields("FABRIC_PORT_TABLE", sdb_port, ['STATUS'], polling_config=max_poll)
link_status = fvs['STATUS']
if link_status == 'up':
try:
# clean up the testing port.
# set TEST_CRC_ERRORS to 0
Expand Down
8 changes: 6 additions & 2 deletions tests/test_fabric_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ def test_voq_switch_fabric_rate(self, vst):
dvs = dvss[name]
# Get the config info
config_db = dvs.get_config_db()
adb = dvs.get_app_db()
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")

cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'}, polling_config=max_poll)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)
# get state_db infor
sdb = dvs.get_state_db()
Expand All @@ -35,7 +37,9 @@ def test_voq_switch_fabric_rate(self, vst):
portNum = random.randint(1, 16)
sdb_port = "PORT"+str(portNum)

tx_rate = sdb.get_entry("FABRIC_PORT_TABLE", sdb_port)['OLD_TX_DATA']
fvs = sdb.wait_for_fields("FABRIC_PORT_TABLE", sdb_port, ['OLD_TX_DATA'], polling_config=max_poll)
tx_rate = fvs['OLD_TX_DATA']

sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})
sdb.wait_for_field_negative_match("FABRIC_PORT_TABLE", sdb_port, {'OLD_TX_DATA': tx_rate}, polling_config=max_poll)
finally:
Expand Down

0 comments on commit 72dbc85

Please sign in to comment.