From 7719a5fae021cbdb1eecf755208feaf965918d8a Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Wed, 3 Apr 2024 01:01:38 -0700 Subject: [PATCH] [tests/configlet] Update configlet test to align with swss update (#12290) 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 --- tests/configlet/util/common.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/configlet/util/common.py b/tests/configlet/util/common.py index 1370524351e..c3d5f38f1c3 100755 --- a/tests/configlet/util/common.py +++ b/tests/configlet/util/common.py @@ -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, @@ -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() } } @@ -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: