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

[watermarkstat] Add new warning message for the 'q_shared_multi' counters #2408

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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 +220,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 @@ -264,7 +268,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
80 changes: 74 additions & 6 deletions tests/queue_counter_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import imp
import json
import os
import sys
import pytest

from click.testing import CliRunner
from unittest import TestCase
from swsscommon.swsscommon import ConfigDBConnector

from .mock_tables import dbconnector

import show.main as show
from utilities_common.cli import json_dump
from utilities_common.db import Db

test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path)
Expand Down Expand Up @@ -1153,6 +1148,60 @@
}
}"""

show_queue_watermark_multicast = """\
Egress shared pool occupancy per multicast queue:
Port MC10 MC11 MC12 MC13 MC14 MC15 MC16 MC17 MC18 MC19
--------- ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
"""

show_queue_watermark_unicast = """\
Egress shared pool occupancy per unicast queue:
Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 UC8 UC9
--------- ------- ------- ----- ----- ----- ----- ----- ----- ----- -----
Ethernet0 2057328 2056704 0 0 0 0 0 2704 416 20
Ethernet4 0 0 0 1986 2567 0 0 0 0 0
Ethernet8 0 0 1040 0 0 0 0 0 8528 7696
"""

show_queue_watermark_all = """\
Egress shared pool occupancy per all queues:
Port ALL20 ALL21 ALL22 ALL23 ALL24 ALL25 ALL26 ALL27 ALL28 ALL29
--------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------
Ethernet0 1234567 7654321 0 0 0 20 500 200 0 10
Ethernet4 0 0 0 1986 2567 0 0 0 0 0
Ethernet8 20 5 1998 0 0 0 0 0 8528 7696
"""

show_queue_persistent_watermark_multicast = """\
Egress shared pool occupancy per multicast queue:
Port MC10 MC11 MC12 MC13 MC14 MC15 MC16 MC17 MC18 MC19
--------- ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
"""

show_queue_persistent_watermark_unicast = """\
Egress shared pool occupancy per unicast queue:
Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 UC8 UC9
--------- ------- ------- ----- ----- ----- ----- ----- ----- ----- -----
Ethernet0 3057328 3056704 0 0 0 0 0 3704 516 30
Ethernet4 0 0 0 2986 3567 0 0 0 0 0
Ethernet8 0 0 2040 0 0 0 0 0 9528 8696
"""

show_queue_persistent_watermark_all = """\
Egress shared pool occupancy per all queues:
Port ALL20 ALL21 ALL22 ALL23 ALL24 ALL25 ALL26 ALL27 ALL28 ALL29
--------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------
Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
"""

class TestQueue(object):
@classmethod
def setup_class(cls):
Expand Down Expand Up @@ -1262,6 +1311,25 @@ def test_queue_voq_counters_port_json(self):
del v["time"]
assert json_dump(json_output) == show_queue_port_voq_counters_json

@pytest.mark.parametrize("counter,counter_type,output", [
('watermark', 'multicast', show_queue_watermark_multicast),
('watermark', 'unicast', show_queue_watermark_unicast),
('watermark', 'all', show_queue_watermark_all),
('persistent-watermark', 'multicast', show_queue_persistent_watermark_multicast),
('persistent-watermark', 'unicast', show_queue_persistent_watermark_unicast),
('persistent-watermark', 'all', show_queue_persistent_watermark_all)
])
def test_queue_counters_all_multi_uni(self, counter, counter_type, output):
runner = CliRunner()
result = runner.invoke(
show.cli.commands["queue"].commands[counter].commands[counter_type],
[]
)
assert result.exit_code == 0
print(result.output)

assert result.output == output

@classmethod
def teardown_class(cls):
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1])
Expand Down