Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare the repo to adopt the new tooling #44

Merged
merged 2 commits into from
Oct 29, 2024
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 graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Optional
import matplotlib
from matplotlib.pylab import Axes
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter, AutoMinorLocator, MultipleLocator
Expand Down Expand Up @@ -32,7 +34,7 @@ def __init__(
square=False,
show_source_file=None,
) -> None:
self.ax2 = None
self.ax2: Optional[Axes] = None
self.args = args
self.fig, self.ax = plt.subplots()
self.dpi = 100
Expand Down
15 changes: 8 additions & 7 deletions hwbench/bench/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ def __init__(self, *args, **kwargs):
with patch(
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
print(pathlib.Path("."))
p.return_value = (
pathlib.Path("./tests/parsing/stressngmethods/v17/stdout")
pathlib.Path("hwbench/tests/parsing/stressngmethods/v17/stdout")
.read_bytes()
.split(b":", 1)
)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="hwbench/tests/parsing/cpu_info/v2321",
numa="hwbench/tests/parsing/numa/8domainsllc",
)
self.load_benches("./config/sample.ini")
self.load_benches("./hwbench/config/sample.ini")
self.parse_jobs_config()

def test_parsing(self):
Expand Down Expand Up @@ -100,11 +101,11 @@ def test_stream_short(self):
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
p.return_value = (
pathlib.Path("./tests/parsing/stressngmethods/v17/stdout")
pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout")
.read_bytes()
.split(b":", 1)
)
self.load_benches("./config/stream.ini")
self.load_benches("./hwbench/config/stream.ini")
assert self.get_jobs_config().get_config().getint("global", "runtime") == 5
self.get_jobs_config().get_config().set("global", "runtime", "2")
with self.assertRaises(SystemExit):
Expand Down
2 changes: 1 addition & 1 deletion hwbench/bench/test_benchmarks_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def parse_jobs_config(self, validate_parameters=True):
with patch("hwbench.environment.turbostat.Turbostat.check_version") as cv:
cv.return_value = True
with patch("hwbench.environment.turbostat.Turbostat.run") as ts:
with open("tests/parsing/turbostat/run", "r") as f:
with open("hwbench/tests/parsing/turbostat/run", "r") as f:
ts.return_value = ast.literal_eval(f.read())
return self.benches.parse_jobs_config(validate_parameters)

Expand Down
10 changes: 5 additions & 5 deletions hwbench/bench/test_cores.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class TestCores(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="./hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="./hwbench/tests/parsing/cpu_info/v2321",
numa="./hwbench/tests/parsing/numa/8domainsllc",
)
self.load_benches("./config/cores.conf")
self.load_benches("./hwbench/config/cores.conf")
self.parse_jobs_config()

def test_cores(self):
Expand All @@ -30,7 +30,7 @@ def test_cores(self):
assert self.get_bench_parameters(3).get_pinned_cpu() == CPU0_1

# Testing broken syntax that must fail
self.load_benches("./config/sample_weirds.conf")
self.load_benches("./hwbench/config/sample_weirds.conf")
for test_name in [
"invalid_cpu_core",
"alpha_cpu_core",
Expand Down
24 changes: 12 additions & 12 deletions hwbench/bench/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class TestHelpers(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="./hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="./hwbench/tests/parsing/cpu_info/v2321",
numa="./hwbench/tests/parsing/numa/8domainsllc",
)
self.load_benches("./config/helpers.conf")
self.load_benches("./hwbench/config/helpers.conf")
self.parse_jobs_config()

def test_helpers(self):
Expand All @@ -32,11 +32,11 @@ class TestHelpers_CPUSTORAGE(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/cpustorage",
cpuinfo="./tests/parsing/cpu_info/cpustorage",
numa="./tests/parsing/numa/2domains",
cpucores="./hwbench/tests/parsing/cpu_cores/cpustorage",
cpuinfo="./hwbench/tests/parsing/cpu_info/cpustorage",
numa="./hwbench/tests/parsing/numa/2domains",
)
self.load_benches("./config/helpers.conf")
self.load_benches("./hwbench/config/helpers.conf")
self.parse_jobs_config()

def test_helpers(self):
Expand All @@ -59,11 +59,11 @@ class TestHelpersImpossible(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="./hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="./hwbench/tests/parsing/cpu_info/v2321",
numa="./hwbench/tests/parsing/numa/8domainsllc",
)
self.load_benches("./config/helpers_fail.conf")
self.load_benches("./hwbench/config/helpers_fail.conf")

def test_helpers_impossible(self):
"""Testing impossible helper usecase."""
Expand Down
12 changes: 6 additions & 6 deletions hwbench/bench/test_numa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ class TestNuma(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="./hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="./hwbench/tests/parsing/cpu_info/v2321",
numa="./hwbench/tests/parsing/numa/8domainsllc",
)
self.NUMA0 = list(range(0, 8)) + list(range(64, 72))
self.NUMA1 = list(range(8, 16)) + list(range(72, 80))
self.NUMA0_1 = sorted(self.NUMA0 + self.NUMA1)
self.NUMA7 = list(range(56, 64)) + list(range(120, 128))
self.NUMA07 = list(range(0, self.hw.get_cpu().get_logical_cores_count()))
self.load_benches("./config/numa.conf")
self.load_benches("./hwbench/config/numa.conf")
self.parse_jobs_config()

def test_quadrant(self):
Expand All @@ -28,7 +28,7 @@ def test_quadrant(self):

# Testing broken syntax that must fail
# Testing quadrants
self.load_benches("./config/sample_weirds.conf")
self.load_benches("./hwbench/config/sample_weirds.conf")
for test_name in [
"invalid_quadrant",
"alpha_quadrant",
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_numa(self):

# Testing broken syntax that must fail
# Testing quadrants
self.load_benches("./config/sample_weirds.conf")
self.load_benches("./hwbench/config/sample_weirds.conf")
for test_name in [
"invalid_numa_nodes",
"alpha_numa_nodes",
Expand Down
10 changes: 5 additions & 5 deletions hwbench/bench/test_spike.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class TestSpike(tbc.TestCommon):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.load_mocked_hardware(
cpucores="./tests/parsing/cpu_cores/v2321",
cpuinfo="./tests/parsing/cpu_info/v2321",
numa="./tests/parsing/numa/8domainsllc",
cpucores="./hwbench/tests/parsing/cpu_cores/v2321",
cpuinfo="./hwbench/tests/parsing/cpu_info/v2321",
numa="./hwbench/tests/parsing/numa/8domainsllc",
)
self.load_benches("./config/spike.conf")
self.load_benches("./hwbench/config/spike.conf")
self.parse_jobs_config()
self.QUADRANT0 = list(range(0, 16)) + list(range(64, 80))
self.QUADRANT1 = list(range(16, 32)) + list(range(80, 96))
Expand All @@ -33,7 +33,7 @@ def test_spike(self):
def test_spike_wrong_syntax(self):
# Testing broken syntax that must fail
# Testing quadrants
self.load_benches("./config/spike_weirds.conf")
self.load_benches("./hwbench/config/spike_weirds.conf")
self.parse_jobs_config(validate_parameters=False)

self.should_be_fatal(self.benches.benchs[0].validate_parameters)
Expand Down
10 changes: 5 additions & 5 deletions hwbench/config/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def __init__(self, *args, **kwargs):
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
p.return_value = (
pathlib.Path("./tests/parsing/stressngmethods/v17/stdout")
pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout")
.read_bytes()
.split(b":", 1)
)
self.hw = MockHardware()
self.load_benches("./config/sample.ini")
self.load_benches("./hwbench/config/sample.ini")

def test_sections_name(self):
"""Check if sections names are properly detected."""
Expand All @@ -43,7 +43,7 @@ def test_keywords(self):
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
p.return_value = (
pathlib.Path("./tests/parsing/stressngmethods/v17/stdout")
pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout")
.read_bytes()
.split(b":", 1)
)
Expand All @@ -59,11 +59,11 @@ def test_defaults(self):
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
p.return_value = (
pathlib.Path("./tests/parsing/stressngmethods/v17/stdout")
pathlib.Path("./hwbench/tests/parsing/stressngmethods/v17/stdout")
.read_bytes()
.split(b":", 1)
)
self.load_benches("./config/sample_weirds.conf")
self.load_benches("./hwbench/config/sample_weirds.conf")
assert (
self.get_jobs_config().get_config().getint("noglobalruntime", "runtime")
== 60
Expand Down
10 changes: 6 additions & 4 deletions hwbench/engines/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def mock_engine(version: str) -> StressNG:
"hwbench.engines.stressng.EngineModuleCpu.list_module_parameters"
) as p:
p.return_value = (
pathlib.Path(f"./tests/parsing/stressngmethods/{version}/stdout")
pathlib.Path(
f"./hwbench/tests/parsing/stressngmethods/{version}/stdout"
)
.read_bytes()
.split(b":", 1)
)
Expand All @@ -37,7 +39,7 @@ def mock_engine(version: str) -> StressNG:

class TestParse(unittest.TestCase):
def test_engine_parsing_version(self):
test_dir = pathlib.Path("./tests/parsing/stressng")
test_dir = pathlib.Path("./hwbench/tests/parsing/stressng")
for d in test_dir.iterdir():
test_target = mock_engine("v17")
if not d.is_dir():
Expand All @@ -54,7 +56,7 @@ def test_module_parsing_output(self):
(StressNGStream, EngineModuleStream, "stressng-stream", 0, engine_v17),
(StressNGMemrate, EngineModuleMemrate, "stressng-memrate", 128, engine_v17),
]:
test_dir = pathlib.Path(f"./tests/parsing/{prefix}")
test_dir = pathlib.Path(f"./hwbench/tests/parsing/{prefix}")
for d in test_dir.iterdir():
if not d.is_dir():
continue
Expand Down Expand Up @@ -95,7 +97,7 @@ def test_module_parsing_output(self):
assert output == json.loads((d / "output").read_bytes())

def test_stressng_methods(self):
test_dir = pathlib.Path("./tests/parsing/stressngmethods")
test_dir = pathlib.Path("./hwbench/tests/parsing/stressngmethods")
for d in test_dir.iterdir():
if not d.is_dir():
continue
Expand Down
4 changes: 3 additions & 1 deletion hwbench/environment/test_hpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

class TestGenericHpe(TestVendors):
def __init__(self, path: str, *args, **kwargs):
super().__init__(Hpe("", None, "tests/mocked_monitoring.cfg"), *args, **kwargs)
super().__init__(
Hpe("", None, "hwbench/tests/mocked_monitoring.cfg"), *args, **kwargs
)
self.path = path

def setUp(self):
Expand Down
18 changes: 9 additions & 9 deletions hwbench/environment/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TestParseCPU(object):
def test_ami_aptio(self):
d = pathlib.Path("./tests/parsing/ami_aptio/v5")
d = pathlib.Path("./hwbench/tests/parsing/ami_aptio/v5")
print(f"parsing test {d.name}")
test_target = amd.Ami_Aptio(path)
ver_stdout = (d / "version-stdout").read_bytes()
Expand All @@ -22,8 +22,8 @@ def test_ami_aptio(self):

def test_parsing_cpuinfo(self):
for d in [
pathlib.Path("./tests/parsing/cpu_info/v2321"),
pathlib.Path("./tests/parsing/cpu_info/cpustorage"),
pathlib.Path("./hwbench/tests/parsing/cpu_info/v2321"),
pathlib.Path("./hwbench/tests/parsing/cpu_info/cpustorage"),
]:
print(f"parsing test {d.name}")
test_target = cpu_info.CPU_INFO(path)
Expand All @@ -49,7 +49,7 @@ def test_parsing_cpuinfo(self):
assert test_target.get_vendor() == output["Vendor ID"]

def test_parsing_cpu_cores(self):
d = pathlib.Path("./tests/parsing/cpu_cores/v2321")
d = pathlib.Path("./hwbench/tests/parsing/cpu_cores/v2321")
print(f"parsing test {d.name}")
test_target = cpu_cores.CPU_CORES(path)

Expand Down Expand Up @@ -202,7 +202,7 @@ def test_parsing_cpu_cores(self):
assert test_target.get_peer_sibling(64) == 0

def test_parsing_numa_1_domain(self):
d = pathlib.Path("./tests/parsing/numa/1domain")
d = pathlib.Path("./hwbench/tests/parsing/numa/1domain")
print(f"parsing test {d.name}")
test_target = numa.NUMA(path)

Expand All @@ -214,7 +214,7 @@ def test_parsing_numa_1_domain(self):
assert len(test_target.get_cores(0)) == 128

def test_parsing_numa_2_domains(self):
d = pathlib.Path("./tests/parsing/numa/2domains")
d = pathlib.Path("./hwbench/tests/parsing/numa/2domains")
print(f"parsing test {d.name}")
test_target = numa.NUMA(path)

Expand All @@ -227,7 +227,7 @@ def test_parsing_numa_2_domains(self):
assert len(test_target.get_cores(1)) == 36

def test_parsing_numa_4_domains(self):
d = pathlib.Path("./tests/parsing/numa/4domains")
d = pathlib.Path("./hwbench/tests/parsing/numa/4domains")
print(f"parsing test {d.name}")
test_target = numa.NUMA(path)

Expand All @@ -240,7 +240,7 @@ def test_parsing_numa_4_domains(self):
assert len(test_target.get_cores(domain)) == 16

def test_parsing_numa_8_domains_with_llc(self):
d = pathlib.Path("./tests/parsing/numa/8domainsllc")
d = pathlib.Path("./hwbench/tests/parsing/numa/8domainsllc")
print(f"parsing test {d.name}")
test_target = numa.NUMA(path)

Expand All @@ -253,7 +253,7 @@ def test_parsing_numa_8_domains_with_llc(self):
assert len(test_target.get_cores(domain)) == 16

def test_ipmitool_parsing(self):
d = pathlib.Path("./tests/parsing/ipmitool/1818")
d = pathlib.Path("./hwbench/tests/parsing/ipmitool/1818")
print(f"parsing test {d.name}")
test_target = BMC(path, None)
stdout = (d / "stdout").read_bytes()
Expand Down
5 changes: 4 additions & 1 deletion hwbench/environment/vendors/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ def connect_redfish(self):

class MockVendor(Vendor):
def __init__(
self, out_dir, dmi, monitoring_config_filename="tests/mocked_monitoring.cfg"
self,
out_dir,
dmi,
monitoring_config_filename="hwbench/tests/mocked_monitoring.cfg",
):
super().__init__(out_dir, dmi, monitoring_config_filename)
self.bmc = MockedBMC(self.out_dir, self)
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cachetools
numpy
matplotlib
matplotlib>=3.9.2
redfish
pycairo
packaging
Loading
Loading