Skip to content

Commit

Permalink
[pfcwd] fix test_pfcwd_mmu_change from pfcwd_function (#3473)
Browse files Browse the repository at this point in the history
Summary:
updated method get_mmu_params()
  * to check whether the buffer configurations are in config db or appl db via checking whether buffer_model exists in DEVICE_METADATA|localhost
  * fetch the buffer configuration from the config db/appl db accordingly.

Signed-off-by: Anton <antonh@nvidia.com>

What is the motivation for this PR?
fix tests in pfcwd/test_pfcwd_function.py

previously the test "test_pfcwd_mmu_change" failed with error:
'> )[0].encode("utf-8")
E IndexError: list index out of range'

In method "get_mmu_params", the reason for it was the "NULL" output in request
asic.run_redis_cmd(
argv = [
"redis-cli", "-n", db, "HGET",
"BUFFER_PG|{}|3-4".format(port), "profile"
]
)
  • Loading branch information
AntonHryshchuk authored May 14, 2021
1 parent 9dc1c17 commit 7bb0894
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions tests/pfcwd/test_pfcwd_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

logger = logging.getLogger(__name__)


@pytest.fixture(scope='function', autouse=True)
def stop_pfcwd(duthosts, rand_one_dut_hostname):
"""
Expand All @@ -40,7 +41,31 @@ def stop_pfcwd(duthosts, rand_one_dut_hostname):
logger.info("--- Stop Pfcwd --")
duthost.command("pfcwd stop")


class PfcCmd(object):
buffer_model_initialized = False
buffer_model = None

@staticmethod
def isBufferInApplDb(asic):
if not PfcCmd.buffer_model_initialized:
PfcCmd.buffer_model = asic.run_redis_cmd(
argv=[
"redis-cli", "-n", "4", "hget",
"DEVICE_METADATA|localhost", "buffer_model"
]
)

PfcCmd.buffer_model_initialized = True
logger.info(
"Buffer model is {}, buffer tables will be fetched from {}".
format(
PfcCmd.buffer_model or "not defined",
"APPL_DB" if PfcCmd.buffer_model else "CONFIG_DB"
)
)
return PfcCmd.buffer_model

@staticmethod
def counter_cmd(dut, queue_oid, attr):
"""
Expand Down Expand Up @@ -115,21 +140,29 @@ def get_mmu_params(dut, port):
logger.info("Retreiving pg profile and dynamic threshold for port: {}".format(port))

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", "4", "HGET",
"BUFFER_PG|{}|3-4".format(port), "profile"
"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", "4", "HGET", pg_profile, "dynamic_th"
"redis-cli", "-n", db, "HGET", pg_profile, "dynamic_th"
]
)[0].encode("utf-8")

return pg_profile, alpha


class PfcPktCntrs(object):
""" PFCwd counter retrieval and verifications """
def __init__(self, dut, action):
Expand Down

0 comments on commit 7bb0894

Please sign in to comment.