Skip to content

Commit

Permalink
[watermarkstat][202205] Add new warning message for the 'q_shared_mul…
Browse files Browse the repository at this point in the history
…ti' counters (#2406)

Signed-off-by: Vadym Hlushko [email protected]

What I did
Add a new warning message for the 'q_shared_multi' counter and not perform the exit with error code (1) because of the new implementation sonic-swss/pull/2432 from now on there is a valid case if there are no multicast counters inside the COUNTERS_DB.

In order for multicast counters to be presented in COUNTERS_DB the appropriate queues should be configured inside the CONFIG_DB (e.g "BUFFER_QUEUE|Ethernet14|7-8")

How I did it
Change the watermarkstat script

How to verify it
Run the sonic-mgmt/tests/iface_namingmode/test_iface_namingmode.py

Previous command output (if the output of a command-line utility has changed)
root@sonic:/home/admin# show queue watermark multicast
Object map is empty!

New command output (if the output of a command-line utility has changed)
root@sonic:/home/admin# show queue watermark multicast
Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!
  • Loading branch information
vadymhlushko-mlnx authored Oct 10, 2022
1 parent a255838 commit 6925947
Show file tree
Hide file tree
Showing 4 changed files with 1,284 additions and 5 deletions.
22 changes: 17 additions & 5 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ try:
tests_path = os.path.join(modules_path, "tests")
sys.path.insert(0, modules_path)
sys.path.insert(0, tests_path)
import mock_tables.dbconnector
from mock_tables import dbconnector

if os.environ["WATERMARKSTAT_UNIT_TESTING"] == "1":
input_path = os.path.join(tests_path, "wm_input")
mock_db_path = os.path.join(input_path, "mock_db")

for mock_db in os.listdir(mock_db_path):
name, ext = os.path.splitext(mock_db)
if ext == ".json":
dbconnector.dedicated_dbs[name.upper()] = os.path.join(mock_db_path, name)
except KeyError:
pass

Expand Down Expand Up @@ -201,7 +209,7 @@ class Watermarkstat(object):

return pg_index

def build_header(self, wm_type):
def build_header(self, wm_type, counter_type):
if wm_type is None:
print("Header info is not available!", file=sys.stderr)
sys.exit(1)
Expand All @@ -220,8 +228,12 @@ class Watermarkstat(object):
min_idx = element_idx

if min_idx == sys.maxsize:
print("Object map is empty!", file=sys.stderr)
sys.exit(1)
if counter_type != 'q_shared_multi':
print("Object map is empty!", file=sys.stderr)
sys.exit(1)
else:
print("Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!")
sys.exit(0)

self.min_idx = min_idx
self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in range(self.min_idx, max_idx + 1)]
Expand Down Expand Up @@ -261,7 +273,7 @@ class Watermarkstat(object):
data = STATUS_NA
table.append((buf_pool, data))
else:
self.build_header(type)
self.build_header(type, key)
# Get stat for each port
for port in natsorted(self.counter_port_name_map):
row_data = list()
Expand Down
13 changes: 13 additions & 0 deletions tests/watermarkstat_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import pytest

import show.main as show
from click.testing import CliRunner
Expand All @@ -13,6 +14,15 @@
sys.path.insert(0, modules_path)


@pytest.fixture(scope="function")
def q_multicast_wm_neg():
print("Setup watermarkstat sample data: no queue multicast watermark counters")
os.environ['WATERMARKSTAT_UNIT_TESTING'] = "1"
yield
del os.environ['WATERMARKSTAT_UNIT_TESTING']
print("Teardown watermarkstat sample data: no queue multicast watermark counters")


class TestWatermarkstat(object):
@classmethod
def setup_class(cls):
Expand All @@ -32,6 +42,9 @@ def test_show_queue_unicast_wm(self):
def test_show_queue_multicast_wm(self):
self.executor(testData['show_q_wm_multicast'])

def test_show_queue_multicast_wm_neg(self, q_multicast_wm_neg):
self.executor(testData['show_q_wm_multicast_neg'])

def test_show_queue_all_wm(self):
self.executor(testData['show_q_wm_all'])

Expand Down
Loading

0 comments on commit 6925947

Please sign in to comment.