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
2 changes: 1 addition & 1 deletion .github/workflows/code_quality_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
pre-commit:
runs-on: [ self-hosted ]
container: python:3.10
container: python:3.9

steps:
- uses: actions/checkout@v3
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Python Functional Tests

on:
workflow_dispatch:
pull_request:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
run_tests:
runs-on: [ self-hosted ]
container: python:3.9

steps:
- uses: actions/checkout@v3

- name: Install xmllint
run: |
apt-get update
apt-get install -y libxml2-utils bc

- name: Install package and run functional tests
id: run_functional_tests
shell: bash
run: |
source ./dev-setup.sh
pytest test/functional -s --disable-warnings -v
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
run_tests:
runs-on: [ self-hosted ]
container: python:3.10
container: python:3.9

steps:
- uses: actions/checkout@v3
Expand Down
26 changes: 26 additions & 0 deletions test/functional/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
"""Functional tests for node-scraper."""
57 changes: 57 additions & 0 deletions test/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
"""Shared fixtures for functional tests."""

import subprocess
import sys
from typing import List

import pytest


@pytest.fixture
def run_cli_command():
"""Fixture that returns a function to run CLI commands."""

def _run_command(args: List[str], check: bool = False):
"""Run a node-scraper CLI command.

Args:
args: List of command-line arguments
check: If True, raise CalledProcessError on non-zero exit

Returns:
subprocess.CompletedProcess instance
"""
cmd = [sys.executable, "-m", "nodescraper.cli.cli"] + args
return subprocess.run(
cmd,
capture_output=True,
text=True,
check=check,
)

return _run_command
55 changes: 55 additions & 0 deletions test/functional/test_cli_describe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
"""Functional tests for CLI describe command."""


def test_describe_command_list_plugins(run_cli_command):
"""Test that describe command can list all plugins."""
result = run_cli_command(["describe", "plugin"])

assert result.returncode == 0
assert len(result.stdout) > 0
output = result.stdout.lower()
assert "available plugins" in output or "biosplugin" in output or "kernelplugin" in output


def test_describe_command_single_plugin(run_cli_command):
"""Test that describe command can describe a single plugin."""
result = run_cli_command(["describe", "plugin", "BiosPlugin"])

assert result.returncode == 0
assert len(result.stdout) > 0
output = result.stdout.lower()
assert "bios" in output


def test_describe_invalid_plugin(run_cli_command):
"""Test that describe command handles invalid plugin gracefully."""
result = run_cli_command(["describe", "plugin", "NonExistentPlugin"])

assert result.returncode != 0
output = (result.stdout + result.stderr).lower()
assert "error" in output or "not found" in output or "invalid" in output
83 changes: 83 additions & 0 deletions test/functional/test_cli_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
"""Functional tests for node-scraper CLI help commands."""

import subprocess
import sys


def test_help_command():
"""Test that node-scraper -h displays help information."""
result = subprocess.run(
[sys.executable, "-m", "nodescraper.cli.cli", "-h"],
capture_output=True,
text=True,
)

assert result.returncode == 0
assert "usage:" in result.stdout.lower()
assert "node scraper" in result.stdout.lower()
assert "-h" in result.stdout or "--help" in result.stdout


def test_help_command_long_form():
"""Test that node-scraper --help displays help information."""
result = subprocess.run(
[sys.executable, "-m", "nodescraper.cli.cli", "--help"],
capture_output=True,
text=True,
)

assert result.returncode == 0
assert "usage:" in result.stdout.lower()
assert "node scraper" in result.stdout.lower()


def test_no_arguments():
"""Test that node-scraper with no arguments runs the default config."""
result = subprocess.run(
[sys.executable, "-m", "nodescraper.cli.cli"],
capture_output=True,
text=True,
timeout=30,
)

assert len(result.stdout) > 0 or len(result.stderr) > 0
output = (result.stdout + result.stderr).lower()
assert "plugin" in output or "nodescraper" in output


def test_help_shows_subcommands():
"""Test that help output includes available subcommands."""
result = subprocess.run(
[sys.executable, "-m", "nodescraper.cli.cli", "-h"],
capture_output=True,
text=True,
)

assert result.returncode == 0
output = result.stdout.lower()
assert "run-plugins" in output or "commands:" in output or "positional arguments:" in output
75 changes: 75 additions & 0 deletions test/functional/test_plugin_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
"""Functional tests for plugin registry and plugin loading."""

import inspect

from nodescraper.pluginregistry import PluginRegistry


def test_plugin_registry_loads_plugins():
"""Test that PluginRegistry successfully loads built-in plugins."""
registry = PluginRegistry()

assert len(registry.plugins) > 0
plugin_names = [name.lower() for name in registry.plugins.keys()]
expected_plugins = ["biosplugin", "kernelplugin", "osplugin"]

for expected in expected_plugins:
assert expected in plugin_names


def test_plugin_registry_has_connection_managers():
"""Test that PluginRegistry loads connection managers."""
registry = PluginRegistry()

assert len(registry.connection_managers) > 0
conn_names = [name.lower() for name in registry.connection_managers.keys()]
assert "inbandconnectionmanager" in conn_names


def test_plugin_registry_list_plugins():
"""Test that PluginRegistry stores plugins in a dictionary."""
registry = PluginRegistry()
plugin_dict = registry.plugins

assert isinstance(plugin_dict, dict)
assert len(plugin_dict) > 0
assert all(isinstance(name, str) for name in plugin_dict.keys())
assert all(inspect.isclass(cls) for cls in plugin_dict.values())


def test_plugin_registry_get_plugin():
"""Test that PluginRegistry can retrieve a specific plugin."""
registry = PluginRegistry()
plugin_names = list(registry.plugins.keys())
assert len(plugin_names) > 0

first_plugin_name = plugin_names[0]
plugin = registry.plugins[first_plugin_name]

assert plugin is not None
assert hasattr(plugin, "run")
Loading