Skip to content

Commit

Permalink
[Chassis][voq] TC test_voq_chassis_app_db_consistency.py Modification…
Browse files Browse the repository at this point in the history
… Due to Lag ID Set Changes (#16116)

What is the motivation for this PR?
Changes by the Functionality sonic-net/sonic-buildimage#20369 of Lag ID assignment.
The TC Expectation and assertion is changed

How did you do it?
Ignoring the SYSTEM_LAG_ID_SET to be same as in case pre-dump.
But rather be assigned from SYSTEM_LAG_IDS_FREE_LIST in order.
Added a sanity of lag_id_set to ensure the functionality of PR sonic-net/sonic-buildimage#20369.

How did you verify/test it?
Tested and Verified on a T2 VOQ Chassis
  • Loading branch information
vikshaw-Nokia authored and Javier-Tan committed Jan 24, 2025
1 parent 9798170 commit 4bc227b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/voq/test_voq_chassis_app_db_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ def verify_data_in_db(post_change_db_dump, tmp_pc, pc_members, duthosts, pc_nbr_
key = "SYSTEM_INTERFACE|{}*{}".format(duthost.sonichost.hostname, tmp_pc)
pytest_assert(voqdb.get_keys(key),
"SYSTEM_INTERFACE in Chasiss_APP_DB is missing for portchannel {}".format(tmp_pc))
# Verfication on SYSTEM_LAG_ID_SET
if lag_id not in post_change_db_dump["SYSTEM_LAG_ID_SET"]:
pytest.fail(
"Portchannel Lag id {} is not allocatioed to tmp portchannel {} in SYSTEM_LAG_ID_SET".format(pc_nbr_ip,
tmp_pc))


@pytest.mark.parametrize("test_case", ["dut_reboot", "config_reload_with_config_save", "config_reload_no_config_save"])
Expand Down Expand Up @@ -252,11 +247,34 @@ def get_db_dump(duthosts, duthost):
"""

chassis_app_db_sysparams = {}
system_lag_id = {}
key = "*SYSTEM*|*" + duthost.sonichost.hostname + "*"
chassis_app_db_result = redis_get_keys(duthosts.supervisor_nodes[0], "CHASSIS_APP_DB", key)
if chassis_app_db_result is not None:
chassis_app_db_sysparams["CHASSIS_APP_DB"] = chassis_app_db_result
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
chassis_app_db_sysparams["SYSTEM_LAG_ID_TABLE"] = voqdb.dump("SYSTEM_LAG_ID_TABLE")["SYSTEM_LAG_ID_TABLE"]['value']
chassis_app_db_sysparams["SYSTEM_LAG_ID_SET"] = voqdb.dump("SYSTEM_LAG_ID_SET")["SYSTEM_LAG_ID_SET"]['value']
system_lag_id["SYSTEM_LAG_ID_TABLE"] = voqdb.dump("SYSTEM_LAG_ID_TABLE")["SYSTEM_LAG_ID_TABLE"]['value']
SYSTEM_LAG_ID_SET = voqdb.dump("SYSTEM_LAG_ID_SET")["SYSTEM_LAG_ID_SET"]['value']
end = int(voqdb.dump("SYSTEM_LAG_ID_END")["SYSTEM_LAG_ID_END"]['value'])
start = int(voqdb.dump("SYSTEM_LAG_ID_START")["SYSTEM_LAG_ID_START"]['value'])
LAG_IDS_FREE_LIST = voqdb.dump("SYSTEM_LAG_IDS_FREE_LIST")["SYSTEM_LAG_IDS_FREE_LIST"]['value']

def verify_system_lag_sanity():
seen = set(LAG_IDS_FREE_LIST + SYSTEM_LAG_ID_SET)
if len(seen) != (end - start + 1):
logging.error(
"Missing or extra values are found in SYSTEM_LAG_IDS_FREE_LIST:{} or SYSTEM_LAG_ID_SET:{}".
format(LAG_IDS_FREE_LIST, SYSTEM_LAG_ID_SET))
return False
if any(LAG_IDS_FREE_LIST.count(x) > 1 or SYSTEM_LAG_ID_SET.count(
x) > 1 or (x in LAG_IDS_FREE_LIST and x in SYSTEM_LAG_ID_SET) for x in seen):
logging.error(
"Duplicate values found in SYSTEM_LAG_IDS_FREE_LIST:{} or SYSTEM_LAG_ID_SET:{}".
format(LAG_IDS_FREE_LIST, SYSTEM_LAG_ID_SET))
return False

return True

pytest_assert(wait_until(220, 10, 0, verify_system_lag_sanity))

return {k: sorted(v) for k, v in chassis_app_db_sysparams.items()}

0 comments on commit 4bc227b

Please sign in to comment.