Skip to content

Commit

Permalink
[tests/configlet] Update configlet test to align with swss update (#1…
Browse files Browse the repository at this point in the history
…2290)

Approach
What is the motivation for this PR?
The swss introduce flap count and last flap time. The test fail because the two new fields mismatch. But these two fields are not affect the correctness of configlet test. sonic-net/sonic-swss#3052

How did you do it?
Add two fields to skip val.

How did you verify/test it?
E2E test using the sonic-swss updated image.

02:31:34 helpers.log_msg L0060 INFO | /var/src/sonic-mgmt-int/tests/configlet/util/common.py:359:02:31:34 patch_rm: compared dump state-db mismatch_cnt=0 msg=
02:31:34 helpers.log_msg L0060 INFO | /var/src/sonic-mgmt-int/tests/configlet/util/common.py:385:02:31:34 patch_rm: generic_patch_rm_t0: Succeeded to compare
02:31:34 helpers.log_msg L0060 INFO | /var/src/sonic-mgmt-int/tests/configlet/util/base_test.py:294:02:31:34 patch_rm: Test run is good!
PASSED [100%]
-------------------------------------------------------------------------------------------- live log teardown ---------------------------------------------------------------------------------------------

co-authorized by: jianquanye@microsoft.com
  • Loading branch information
wen587 authored Apr 3, 2024
1 parent 7dd677f commit 7719a5f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/configlet/util/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def do_pause(secs, msg):
# BUFFER_PG.*3-4 is an auto created entry by buffermgr
# configlet skips it. So skip verification too.
"BUFFER_PG_TABLE:Ethernet[0-9][0-9]*:3-4"},
"keys_skip_val_comp": set()
"keys_skip_val_comp": {
"last_up_time",
"flap_count"
}
},
"state-db": {
"db_no": 6,
Expand All @@ -115,10 +118,10 @@ def do_pause(secs, msg):
"VLAN_MEMBER_TABLE",
"VLAN_TABLE"
},
"keys_to_skip_comp": set(),
"keys_skip_val_comp": {
"keys_to_skip_comp": {
"PORT_TABLE"
}
},
"keys_skip_val_comp": set()
}
}

Expand Down Expand Up @@ -235,8 +238,13 @@ def get_dump(duthost, db_name, db_info, dir_name, data_dir):
db_write = {}
for k in db_read:
# Transient keys start with "_"; Hence skipped
if ((not k.startswith("_")) and (not match_key(k, keys_skip_cmp))):
db_write[k] = {} if match_key(k, keys_skip_val) else db_read[k]
if (not k.startswith("_")) and (not match_key(k, keys_skip_cmp)):
value = db_read[k].get("value", {}) # Get the value or empty dictionary if

for skip_val in keys_skip_val:
if match_key(skip_val, value):
value.pop(skip_val)
db_write[k] = db_read[k]

dst_file = os.path.join(dir_name, "{}.json".format(db_name))
with open(dst_file, "w") as s:
Expand Down

0 comments on commit 7719a5f

Please sign in to comment.