Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion nodescraper/plugins/inband/process/collector_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
class ProcessCollectorArgs(CollectorArgs):
top_n_process: int = Field(
default=10,
description="Number of top processes by CPU usage to collect (e.g. for top -b -n 1 -o %CPU).",
description=(
"Number of top processes by CPU usage to collect " "(e.g. for top -b -n 1 -o %%CPU)."
),
)
32 changes: 32 additions & 0 deletions test/functional/test_cli_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
import subprocess
import sys

import pytest

from nodescraper.pluginregistry import PluginRegistry

_REGISTERED_PLUGIN_NAMES = tuple(sorted(PluginRegistry().plugins.keys()))


def test_help_command():
"""Test that node-scraper -h displays help information."""
Expand Down Expand Up @@ -67,3 +73,29 @@ def test_help_shows_subcommands():
assert result.returncode == 0
output = result.stdout.lower()
assert "run-plugins" in output or "commands:" in output or "positional arguments:" in output


@pytest.mark.parametrize("plugin_name", _REGISTERED_PLUGIN_NAMES)
def test_run_plugins_help_for_each_registered_plugin(plugin_name, tmp_path):
"""``run-plugins <Plugin> -h`` must succeed for every plugin in the registry."""
log_path = str(tmp_path / "logs")
result = subprocess.run(
[
sys.executable,
"-m",
"nodescraper.cli.cli",
"--log-path",
log_path,
"run-plugins",
plugin_name,
"-h",
],
capture_output=True,
text=True,
)
assert result.returncode == 0, (
f"run-plugins {plugin_name} -h failed:\n"
f"stdout={result.stdout!r}\nstderr={result.stderr!r}"
)
combined = (result.stdout or "") + (result.stderr or "")
assert "usage:" in combined.lower()
Loading