Skip to content

Commit f62d1e5

Browse files
[watermarkstat] Add new warning message for the 'q_shared_multi' counters (sonic-net#2408)
- 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!
1 parent 25fda26 commit f62d1e5

File tree

4 files changed

+1284
-5
lines changed

4 files changed

+1284
-5
lines changed

scripts/watermarkstat

+17-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ try:
2121
tests_path = os.path.join(modules_path, "tests")
2222
sys.path.insert(0, modules_path)
2323
sys.path.insert(0, tests_path)
24-
import mock_tables.dbconnector
24+
from mock_tables import dbconnector
2525

26+
if os.environ["WATERMARKSTAT_UNIT_TESTING"] == "1":
27+
input_path = os.path.join(tests_path, "wm_input")
28+
mock_db_path = os.path.join(input_path, "mock_db")
29+
30+
for mock_db in os.listdir(mock_db_path):
31+
name, ext = os.path.splitext(mock_db)
32+
if ext == ".json":
33+
dbconnector.dedicated_dbs[name.upper()] = os.path.join(mock_db_path, name)
2634
except KeyError:
2735
pass
2836

@@ -201,7 +209,7 @@ class Watermarkstat(object):
201209

202210
return pg_index
203211

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

222230
if min_idx == sys.maxsize:
223-
print("Object map is empty!", file=sys.stderr)
224-
sys.exit(1)
231+
if counter_type != 'q_shared_multi':
232+
print("Object map is empty!", file=sys.stderr)
233+
sys.exit(1)
234+
else:
235+
print("Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!")
236+
sys.exit(0)
225237

226238
self.min_idx = min_idx
227239
self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in range(self.min_idx, max_idx + 1)]
@@ -264,7 +276,7 @@ class Watermarkstat(object):
264276
data = STATUS_NA
265277
table.append((buf_pool, data))
266278
else:
267-
self.build_header(type)
279+
self.build_header(type, key)
268280
# Get stat for each port
269281
for port in natsorted(self.counter_port_name_map):
270282
row_data = list()

tests/watermarkstat_test.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import pytest
34

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

1516

17+
@pytest.fixture(scope="function")
18+
def q_multicast_wm_neg():
19+
print("Setup watermarkstat sample data: no queue multicast watermark counters")
20+
os.environ['WATERMARKSTAT_UNIT_TESTING'] = "1"
21+
yield
22+
del os.environ['WATERMARKSTAT_UNIT_TESTING']
23+
print("Teardown watermarkstat sample data: no queue multicast watermark counters")
24+
25+
1626
class TestWatermarkstat(object):
1727
@classmethod
1828
def setup_class(cls):
@@ -32,6 +42,9 @@ def test_show_queue_unicast_wm(self):
3242
def test_show_queue_multicast_wm(self):
3343
self.executor(testData['show_q_wm_multicast'])
3444

45+
def test_show_queue_multicast_wm_neg(self, q_multicast_wm_neg):
46+
self.executor(testData['show_q_wm_multicast_neg'])
47+
3548
def test_show_queue_all_wm(self):
3649
self.executor(testData['show_q_wm_all'])
3750

0 commit comments

Comments
 (0)