Skip to content

Commit e377b39

Browse files
author
jaspals
committed
network plugin functional tests
1 parent 4f38b5f commit e377b39

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"global_args": {},
3+
"plugins": {
4+
"NetworkPlugin": {
5+
"analysis_args": {}
6+
}
7+
},
8+
"result_collators": {},
9+
"name": "NetworkPlugin config",
10+
"desc": "Config for testing NetworkPlugin"
11+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
###############################################################################
2+
#
3+
# MIT License
4+
#
5+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
#
25+
###############################################################################
26+
"""Functional tests for NetworkPlugin with --plugin-configs."""
27+
28+
from pathlib import Path
29+
30+
import pytest
31+
32+
33+
@pytest.fixture
34+
def fixtures_dir():
35+
"""Return path to fixtures directory."""
36+
return Path(__file__).parent / "fixtures"
37+
38+
39+
@pytest.fixture
40+
def network_config_file(fixtures_dir):
41+
"""Return path to NetworkPlugin config file."""
42+
return fixtures_dir / "network_plugin_config.json"
43+
44+
45+
def test_network_plugin_with_basic_config(run_cli_command, network_config_file, tmp_path):
46+
"""Test NetworkPlugin using basic config file."""
47+
assert network_config_file.exists(), f"Config file not found: {network_config_file}"
48+
49+
log_path = str(tmp_path / "logs_network_basic")
50+
result = run_cli_command(
51+
["--log-path", log_path, "--plugin-configs", str(network_config_file)], check=False
52+
)
53+
54+
assert result.returncode in [0, 1, 2]
55+
output = result.stdout + result.stderr
56+
assert len(output) > 0
57+
assert "networkplugin" in output.lower() or "network" in output.lower()
58+
59+
60+
def test_network_plugin_with_run_plugins_subcommand(run_cli_command, tmp_path):
61+
"""Test NetworkPlugin using run-plugins subcommand."""
62+
log_path = str(tmp_path / "logs_network_subcommand")
63+
result = run_cli_command(["--log-path", log_path, "run-plugins", "NetworkPlugin"], check=False)
64+
65+
assert result.returncode in [0, 1, 2]
66+
output = result.stdout + result.stderr
67+
assert len(output) > 0
68+
69+
70+
def test_network_plugin_with_passive_interaction(run_cli_command, network_config_file, tmp_path):
71+
"""Test NetworkPlugin with PASSIVE system interaction level."""
72+
log_path = str(tmp_path / "logs_network_passive")
73+
result = run_cli_command(
74+
[
75+
"--log-path",
76+
log_path,
77+
"--sys-interaction-level",
78+
"PASSIVE",
79+
"--plugin-configs",
80+
str(network_config_file),
81+
],
82+
check=False,
83+
)
84+
85+
assert result.returncode in [0, 1, 2]
86+
output = result.stdout + result.stderr
87+
assert len(output) > 0
88+
89+
90+
def test_network_plugin_skip_sudo(run_cli_command, network_config_file, tmp_path):
91+
"""Test NetworkPlugin with --skip-sudo flag."""
92+
log_path = str(tmp_path / "logs_network_no_sudo")
93+
result = run_cli_command(
94+
[
95+
"--log-path",
96+
log_path,
97+
"--skip-sudo",
98+
"--plugin-configs",
99+
str(network_config_file),
100+
],
101+
check=False,
102+
)
103+
104+
assert result.returncode in [0, 1, 2]
105+
output = result.stdout + result.stderr
106+
assert len(output) > 0

0 commit comments

Comments
 (0)