Skip to content

Commit

Permalink
[pfcwd] Fix test_pfcwd_mmu_change IndexError (sonic-net#4465)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii-Yosafat Lozovyi <andrii-yosafatx.lozovyi@intel.com>

Summary: test_pfcwd_mmu_change fails with IndexError

        asic = dut.get_port_asic_instance(port)
        if PfcCmd.isBufferInApplDb(asic):
            db = "0"
            pg_pattern = "BUFFER_PG_TABLE:{}:3-4"
        else:
            db = "4"
            pg_pattern = "BUFFER_PG|{}|3-4"

        pg_profile = asic.run_redis_cmd(
            argv = [
                "redis-cli", "-n", db, "HGET",
                pg_pattern.format(port), "profile"
            ]
        )[0].encode("utf-8")[1:-1]

        alpha = asic.run_redis_cmd(
            argv = [
                "redis-cli", "-n", db, "HGET", pg_profile, "dynamic_th"
            ]
>       )[0].encode("utf-8")
E       IndexError: list index out of range

Looks like after PR - 1626 values in DB for QOS has changed.
Example of change on different Sonic images below:

redis-cli -n 4 hget 'BUFFER_PG|Ethernet24|3-4' 'profile'
"[BUFFER_PROFILE|pg_lossless_100000_300m_profile]" - on SONiC.master.31701-dirty-20210827.084520
"pg_lossless_100000_300m_profile" - on  SONiC.master.42584-dirty-20211011.014318
This PR should solve this issue.

How did you verify/test it?
Run TC on SONiC.master.42584-dirty-20211011.014318 and SONiC.master.31701-dirty-20210827.084520

pfcwd/test_pfcwd_function.py::TestPfcwdFunc::test_pfcwd_actions[None] PASSED
pfcwd/test_pfcwd_function.py::TestPfcwdFunc::test_pfcwd_mmu_change[None] PASSED
pfcwd/test_pfcwd_function.py::TestPfcwdFunc::test_pfcwd_port_toggle[None] PASSED
  • Loading branch information
li-pingmao authored and svc-lnos-user committed Jun 9, 2022
1 parent ed96a31 commit 8c91ecb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/pfcwd/test_pfcwd_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"forward": "Verify proper function of forward action"
}
MMU_ACTIONS = ['change', 'noop', 'restore', 'noop']
DB_SEPARATORS = {'0': ':', '4': '|'}
BF_PROFILE = "BUFFER_PROFILE|{}"
BF_PROFILE_TABLE = "BUFFER_PROFILE_TABLE:{}"

pytestmark = [
pytest.mark.disable_loganalyzer,
Expand Down Expand Up @@ -128,10 +131,11 @@ def update_alpha(dut, port, profile, value):
db = "0"
else:
db = "4"
table_template = BF_PROFILE if db == "4" else BF_PROFILE_TABLE

asic.run_redis_cmd(
argv = [
"redis-cli", "-n", db, "HSET", profile, "dynamic_th", value
"redis-cli", "-n", db, "HSET", table_template.format(profile), "dynamic_th", value
]
)

Expand Down Expand Up @@ -162,11 +166,15 @@ def get_mmu_params(dut, port):
"redis-cli", "-n", db, "HGET",
pg_pattern.format(port), "profile"
]
)[0].encode("utf-8")[1:-1]
)[0].encode("utf-8")

if BF_PROFILE[:-2] in pg_profile or BF_PROFILE_TABLE[:-2] in pg_profile:
pg_profile = pg_profile.split(DB_SEPARATORS[db])[-1][:-1]
table_template = BF_PROFILE if db == "4" else BF_PROFILE_TABLE

alpha = asic.run_redis_cmd(
argv = [
"redis-cli", "-n", db, "HGET", pg_profile, "dynamic_th"
"redis-cli", "-n", db, "HGET", table_template.format(pg_profile), "dynamic_th"
]
)[0].encode("utf-8")

Expand Down

0 comments on commit 8c91ecb

Please sign in to comment.