Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic buffer calc] Test cases for dynamic buffer calculation #1971

Merged
merged 9 commits into from
Jan 7, 2021
29 changes: 29 additions & 0 deletions tests/qos/files/dynamic_buffer_param.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"mellanox": {
"default_cable_length": ["5m", "40m", "300m"],
"testparam_cable_length": ["15m", "40m"],
"headroom-override": {
"add": {
"xon": "18432",
"xoff": "18432",
"size": "36864",
"dynamic_th": "1"
},
"set": {
"xon": "18432",
"xoff": "36864",
"size": "55296"
}
},
"lossless_pg": {
"headroom-override": {
"xon": "18432",
"xoff": "32768",
"size": "51200"
},
"non-default-dynamic_th": {
"dynamic_th": "2"
}
}
}
}
44 changes: 35 additions & 9 deletions tests/qos/qos_sai_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ class QosSaiBase:
TARGET_QUEUE_WRED = 3
TARGET_LOSSY_QUEUE_SCHED = 0
TARGET_LOSSLESS_QUEUE_SCHED = 3
buffer_model_initialized = False
buffer_model = None

@pytest.fixture(scope='class', autouse=True)
def isBufferInApplDb(self, duthost):
if not self.buffer_model_initialized:
self.buffer_model = duthost.shell('redis-cli -n 4 hget "DEVICE_METADATA|localhost" buffer_model')["stdout"]
self.buffer_model_initialized = True
logger.info("Buffer model is {}, buffer tables will be fetched from {}".
format(self.buffer_model or "not defined", "APPL_DB" if self.buffer_model else "CONFIG_DB"))
return self.buffer_model

def __runRedisCommandOrAssert(self, duthost, argv=[]):
"""
Expand Down Expand Up @@ -52,10 +63,11 @@ def __computeBufferThreshold(self, duthost, bufferProfile):
Returns:
Updates bufferProfile with computed buffer threshold
"""
db = "0" if self.isBufferInApplDb(duthost) else "4"
pool = bufferProfile["pool"].encode("utf-8").translate(None, "[]")
bufferSize = int(self.__runRedisCommandOrAssert(
duthost,
argv = ["redis-cli", "-n", "4", "HGET", pool, "size"]
argv = ["redis-cli", "-n", db, "HGET", pool, "size"]
)[0])
bufferScale = 2**float(bufferProfile["dynamic_th"])
bufferScale /= (bufferScale + 1)
Expand All @@ -72,7 +84,10 @@ def __updateVoidRoidParams(self, duthost, bufferProfile):
Returns:
Updates bufferProfile with VOID/ROID obtained from Redis db
"""
bufferPoolName = bufferProfile["pool"].encode("utf-8").translate(None, "[]").replace("BUFFER_POOL|",'')
if self.isBufferInApplDb(duthost):
bufferPoolName = bufferProfile["pool"].encode("utf-8").translate(None, "[]").replace("BUFFER_POOL_TABLE:",'')
else:
bufferPoolName = bufferProfile["pool"].encode("utf-8").translate(None, "[]").replace("BUFFER_POOL|",'')

bufferPoolVoid = self.__runRedisCommandOrAssert(
duthost,
Expand Down Expand Up @@ -100,14 +115,21 @@ def __getBufferProfile(self, request, duthost, table, port, priorityGroup):
Returns:
bufferProfile (dict): Map of buffer profile attributes
"""

if self.isBufferInApplDb(duthost):
db = "0"
keystr = "{0}:{1}:{2}".format(table, port, priorityGroup)
else:
db = "4"
keystr = "{0}|{1}|{2}".format(table, port, priorityGroup)
bufferProfileName = self.__runRedisCommandOrAssert(
duthost,
argv = ["redis-cli", "-n", "4", "HGET", "{0}|{1}|{2}".format(table, port, priorityGroup), "profile"]
argv = ["redis-cli", "-n", db, "HGET", keystr, "profile"]
)[0].encode("utf-8").translate(None, "[]")

result = self.__runRedisCommandOrAssert(
duthost,
argv = ["redis-cli", "-n", "4", "HGETALL", bufferProfileName]
argv = ["redis-cli", "-n", db, "HGETALL", bufferProfileName]
)
it = iter(result)
bufferProfile = dict(zip(it, it))
Expand Down Expand Up @@ -539,7 +561,11 @@ def dutQosConfig(self, duthosts, rand_one_dut_hostname, ingressLosslessProfile,
pytest_assert("minigraph_hwsku" in mgFacts, "Could not find DUT SKU")

profileName = ingressLosslessProfile["profileName"]
m = re.search("^BUFFER_PROFILE\|pg_lossless_(.*)_profile$", profileName)
if self.isBufferInApplDb(duthost):
profile_pattern = "^BUFFER_PROFILE_TABLE\:pg_lossless_(.*)_profile$"
else:
profile_pattern = "^BUFFER_PROFILE\|pg_lossless_(.*)_profile"
m = re.search(profile_pattern, profileName)
pytest_assert(m.group(1), "Cannot find port speed/cable length")

portSpeedCableLength = m.group(1)
Expand Down Expand Up @@ -680,7 +706,7 @@ def ingressLosslessProfile(self, request, duthosts, rand_one_dut_hostname, dutCo
yield self.__getBufferProfile(
request,
duthost,
"BUFFER_PG",
"BUFFER_PG_TABLE" if self.isBufferInApplDb(duthost) else "BUFFER_PG",
dutConfig["dutInterfaces"][dutConfig["testPorts"]["src_port_id"]],
"3-4"
)
Expand All @@ -703,7 +729,7 @@ def ingressLossyProfile(self, request, duthosts, rand_one_dut_hostname, dutConfi
yield self.__getBufferProfile(
request,
duthost,
"BUFFER_PG",
"BUFFER_PG_TABLE" if self.isBufferInApplDb(duthost) else "BUFFER_PG",
dutConfig["dutInterfaces"][dutConfig["testPorts"]["src_port_id"]],
"0"
)
Expand All @@ -726,7 +752,7 @@ def egressLosslessProfile(self, request, duthosts, rand_one_dut_hostname, dutCon
yield self.__getBufferProfile(
request,
duthost,
"BUFFER_QUEUE",
"BUFFER_QUEUE_TABLE" if self.isBufferInApplDb(duthost) else "BUFFER_QUEUE",
dutConfig["dutInterfaces"][dutConfig["testPorts"]["src_port_id"]],
"3-4"
)
Expand All @@ -749,7 +775,7 @@ def egressLossyProfile(self, request, duthosts, rand_one_dut_hostname, dutConfig
yield self.__getBufferProfile(
request,
duthost,
"BUFFER_QUEUE",
"BUFFER_QUEUE_TABLE" if self.isBufferInApplDb(duthost) else "BUFFER_QUEUE",
dutConfig["dutInterfaces"][dutConfig["testPorts"]["src_port_id"]],
"0-2"
)
Expand Down
Loading