Skip to content

Commit b9cab6b

Browse files
committed
adding collector arg to disable writing full dmesg log to disk
1 parent 9757101 commit b9cab6b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

nodescraper/plugins/inband/dmesg/collector_args.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ class DmesgCollectorArgs(CollectorArgs):
3636

3737
collect_rotated_logs: bool = False
3838
skip_sudo: bool = False
39+
collect_dmesg_log: bool = True

test/unit/plugin/test_dmesg_collector.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from nodescraper.enums.systeminteraction import SystemInteractionLevel
3333
from nodescraper.interfaces.task import SystemCompatibilityError
3434
from nodescraper.models.systeminfo import OSFamily
35+
from nodescraper.plugins.inband.dmesg.collector_args import DmesgCollectorArgs
3536
from nodescraper.plugins.inband.dmesg.dmesg_collector import DmesgCollector
3637
from nodescraper.plugins.inband.dmesg.dmesgdata import DmesgData
3738

@@ -276,3 +277,27 @@ def run_map(cmd, **kwargs):
276277

277278
assert isinstance(data, DmesgData)
278279
assert data.dmesg_content == "DMESG OUTPUT\n"
280+
281+
282+
def test_collect_data_with_args(conn_mock, system_info):
283+
"""Test collect_data accepts DmesgCollectorArgs"""
284+
dmesg = "2023-06-01T01:00:00,685236-05:00 test message1\n"
285+
conn_mock.run_command.return_value = CommandArtifact(
286+
exit_code=0,
287+
stdout=dmesg,
288+
stderr="",
289+
command="dmesg --time-format iso",
290+
)
291+
292+
collector = DmesgCollector(
293+
system_info=system_info,
294+
system_interaction_level=SystemInteractionLevel.INTERACTIVE,
295+
connection=conn_mock,
296+
)
297+
298+
args = DmesgCollectorArgs(collect_dmesg_log=False)
299+
res, data = collector.collect_data(args=args)
300+
301+
assert res.status == ExecutionStatus.OK
302+
assert data is not None
303+
assert data.dmesg_content == dmesg

0 commit comments

Comments
 (0)