Skip to content

Commit

Permalink
New parser Ql2xmqSupport (#3374)
Browse files Browse the repository at this point in the history
Signed-off-by: Xinting Li <[email protected]>

Co-authored-by: Xinting Li <[email protected]>
(cherry picked from commit c979366)
  • Loading branch information
TZ3070 authored and xiangce committed Apr 7, 2022
1 parent d1c4e50 commit bc97d6a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
20 changes: 20 additions & 0 deletions insights/parsers/sys_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
---------------------------------------------------------------------
VHostNetZeroCopyTx - file ``/sys/module/vhost_net/parameters/experimental_zcopytx``
-----------------------------------------------------------------------------------
Ql2xMaxLUN - file ``/sys/module/qla2xxx/parameters/ql2xmqsupport``
------------------------------------------------------------------
"""
from insights import parser, Parser
from insights.parsers import SkipException
Expand Down Expand Up @@ -173,3 +175,21 @@ class SCSIModMaxReportLUNs(MaxLUNs):
512
"""
pass


@parser(Specs.ql2xmqsupport)
class Ql2xmqSupport(XModUseBlkMq):
"""
This file `/sys/module/qla2xxx/parameters/ql2xmqsupport` shows if ql2xmqsupport
parameter is on.
Examples::
>>> type(qla2xxx_ql2xmqsupport)
<class 'insights.parsers.sys_module.Ql2xmqSupport'>
>>> qla2xxx_ql2xmqsupport.val
'1'
>>> qla2xxx_ql2xmqsupport.is_on
True
"""
pass
24 changes: 23 additions & 1 deletion insights/parsers/tests/test_sys_module.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import doctest
import pytest
from insights.parsers import sys_module, SkipException
from insights.parsers.sys_module import DMModUseBlkMq, SCSIModUseBlkMq, VHostNetZeroCopyTx, MaxLUNs, LpfcMaxLUNs, Ql2xMaxLUN, SCSIModMaxReportLUNs
from insights.parsers.sys_module import DMModUseBlkMq, SCSIModUseBlkMq, VHostNetZeroCopyTx, MaxLUNs, LpfcMaxLUNs, Ql2xMaxLUN, SCSIModMaxReportLUNs, Ql2xmqSupport
from insights.tests import context_wrap


Expand All @@ -11,6 +11,10 @@
SCSI_DM_MOD_USE_BLK_MQ_N = """
N
""".strip()
QLA2XXX_QL2XMQSUPPORT = """
1
""".strip()

SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE = """
unknow_case
""".strip()
Expand All @@ -37,6 +41,7 @@ def test_doc_examples():
'lpfc_max_luns': LpfcMaxLUNs(context_wrap(MAX_LUNS)),
'ql2xmaxlun': Ql2xMaxLUN(context_wrap(MAX_LUNS)),
'scsi_mod_max_report_luns': SCSIModMaxReportLUNs(context_wrap(MAX_LUNS)),
'qla2xxx_ql2xmqsupport': Ql2xmqSupport(context_wrap(QLA2XXX_QL2XMQSUPPORT))
}
failed, total = doctest.testmod(sys_module, globs=env)
assert failed == 0
Expand All @@ -62,6 +67,14 @@ def test_XModUseBlkMq():
assert zero_copy_1.is_on is True
assert zero_copy_1.val == '1'

ql2xmqsuppor_copy_0 = Ql2xmqSupport(context_wrap(ZERO_COPY))
assert ql2xmqsuppor_copy_0.is_on is False
assert ql2xmqsuppor_copy_0.val == '0'

ql2xmqsuppor_copy_1 = Ql2xmqSupport(context_wrap(QLA2XXX_QL2XMQSUPPORT))
assert ql2xmqsuppor_copy_1.is_on is True
assert ql2xmqsuppor_copy_1.val == '1'


def test_MaxLUNs():
max_luns = MaxLUNs(context_wrap(MAX_LUNS))
Expand Down Expand Up @@ -95,3 +108,12 @@ def test_class_exceptions():
max_luns_not_digit = MaxLUNs(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE))
max_luns_not_digit.val
assert "Unexpected content: unknow_case" in str(e)

with pytest.raises(SkipException):
ql2xmqsuppor_empty = Ql2xmqSupport(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_EMPTY))
assert ql2xmqsuppor_empty is None

with pytest.raises(ValueError) as e:
ql2xmqsuppor_unknow = Ql2xmqSupport(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_UNKNOW_CASE))
ql2xmqsuppor_unknow.is_on
assert "Unexpected value unknow_case, please get raw data from attribute 'val' and tell is_on by yourself." in str(e)
1 change: 1 addition & 0 deletions insights/specs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ class Specs(SpecSet):
qemu_conf = RegistryPoint()
qemu_xml = RegistryPoint(multi_output=True)
ql2xmaxlun = RegistryPoint()
ql2xmqsupport = RegistryPoint()
qpid_stat_g = RegistryPoint()
qpid_stat_q = RegistryPoint()
qpid_stat_u = RegistryPoint()
Expand Down
1 change: 1 addition & 0 deletions insights/specs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ def md5chk_file_list(broker):
qemu_conf = simple_file("/etc/libvirt/qemu.conf")
qemu_xml = glob_file(r"/etc/libvirt/qemu/*.xml")
ql2xmaxlun = simple_file("/sys/module/qla2xxx/parameters/ql2xmaxlun")
ql2xmqsupport = simple_file("/sys/module/qla2xxx/parameters/ql2xmqsupport")
qpidd_conf = simple_file("/etc/qpid/qpidd.conf")
rabbitmq_env = simple_file("/etc/rabbitmq/rabbitmq-env.conf")
rabbitmq_report = simple_command("/usr/sbin/rabbitmqctl report")
Expand Down

0 comments on commit bc97d6a

Please sign in to comment.