Verified Commit 20bf758b authored by Hines, Jesse's avatar Hines, Jesse
Browse files

Refactor system_files fixture

parent 5c931588
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
import pytest
from tests.util import DATA_PATH


@pytest.fixture(params=[
@@ -180,18 +181,24 @@ def system_config(system):


@pytest.fixture
def system_file(system):
def system_files(system):
    files = {
        "40frontiers": [],
        "adastraMI250": ["AdastaJobsMI250_15days.parquet"],
        "frontier": ["slurm/joblive/date=2024-01-18/", "jobprofile/date=2024-01-18/"],
        "fugaku": ["21_04.parquet"],
        "gcloudv2": ["/v2/google_cluster_data_2011_sample"],
        "lassen": ["Lassen-Supercomputer-Job-Dataset"],
        "marconi100": ["job_table.parquet"],
        "mit_supercloud": ["202201"],
        "setonix": [""],
        "adastraMI250": ["adastraMI250/AdastaJobsMI250_15days.parquet"],
        "frontier": ["frontier/slurm/joblive/date=2024-01-18/", "frontier/jobprofile/date=2024-01-18/"],
        "fugaku": ["fugaku/21_04.parquet"],
        "gcloudv2": ["gcloud/v2/google_cluster_data_2011_sample"],
        "lassen": ["lassen/Lassen-Supercomputer-Job-Dataset"],
        "marconi100": ["marconi100/job_table.parquet"],
        "mit_supercloud": ["mit_supercloud/202201"],
        "setonix": [],
        "summit": [],
        "lumi": []
    }
    return files.get(system, files)

    file_list = [DATA_PATH / f for f in files.get(system, [])]
    for file in file_list:
        assert file.exists(), \
            f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?"

    return [str(f) for f in file_list]
+2 −10
Original line number Diff line number Diff line
@@ -13,24 +13,16 @@ pytestmark = [
]


def test_main_network_withdata_run(system, system_config, system_file, sim_output):
def test_main_network_withdata_run(system, system_config, system_files, sim_output):
    if not system_config.get("net", False):
        pytest.skip(f"{system} does not support basic net run.")

    if isinstance(system_file, list):
        file_list = [DATA_PATH / system / x for x in system_file]
    else:
        file_list = [DATA_PATH / system / system_file]
    for file in file_list:
        assert os.path.isfile(file) or os.path.isdir(file), \
            "File does not exist. does ./data exist or is RAPS_DATA_DIR set?"

    os.chdir(PROJECT_ROOT)
    result = subprocess.run([
        "python", "main.py", "run",
        "--time", "1m",
        "--system", system,
        "-f", *file_list,
        "-f", *system_files,
        "--net",
        "-o", sim_output
    ], capture_output=True, text=True, stdin=subprocess.DEVNULL)
+2 −9
Original line number Diff line number Diff line
@@ -11,24 +11,17 @@ pytestmark = [
]


def test_main_withdata_run(system, system_config, system_file, sim_output):
def test_main_withdata_run(system, system_config, system_files, sim_output):
    if not system_config.get("main", False):
        pytest.skip(f"{system} does not support basic main even without data.")
    if not system_config.get("withdata", False):
        pytest.skip(f"{system} does not support basic main with data.")
    if isinstance(system_file, list):
        file_list = [DATA_PATH / system / x for x in system_file]
    else:
        file_list = [DATA_PATH / system / system_file]
    for file in file_list:
        assert os.path.isfile(file) or os.path.isdir(file), \
            f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?"
    os.chdir(PROJECT_ROOT)
    result = subprocess.run([
        "python", "main.py", "run",
        "--time", "1m",
        "--system", system,
        "-f", ','.join(str(p) for p in file_list),
        "-f", ','.join(system_files),
        "-o", sim_output
    ], capture_output=True, text=True, stdin=subprocess.DEVNULL)
    assert result.returncode == 0, f"Failed on {system}: {result.stderr}"
+2 −11
Original line number Diff line number Diff line
@@ -12,26 +12,17 @@ pytestmark = [
]


def test_multi_part_sim_withdata_run(system, system_config, system_file):
def test_multi_part_sim_withdata_run(system, system_config, system_files):
    if not system_config.get("multi-part-sim", False):
        pytest.skip(f"{system} does not support basic multi-part-sim run even without data.")
    if not system_config.get("withdata", False):
        pytest.skip(f"{system} does not support multi-part-sim run with data.")
    if isinstance(system_file, list):
        file_list = [DATA_PATH / system / x for x in system_file]
    else:
        file_list = [DATA_PATH / system / system_file]
    for file in file_list:
        assert os.path.isfile(file) or os.path.isdir(file), \
            f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?"

    os.chdir(PROJECT_ROOT)
    result = subprocess.run([
        "python", "main.py", "run-multi-part",
        "--time", "1h",
        "-x", f"{system}/*",
        "-f", *file_list,
        "-f", *system_files,
    ], capture_output=True, text=True, stdin=subprocess.DEVNULL)
    assert result.returncode == 0, f"Failed on {system}: {result.stderr}"
    del result
    gc.collect()
+2 −9
Original line number Diff line number Diff line
@@ -10,24 +10,17 @@ pytestmark = [
]


def test_telemetry_main_withdata_run(system, system_config, system_file, sim_output):
def test_telemetry_main_withdata_run(system, system_config, system_files, sim_output):
    if not system_config.get("telemetry", False):
        pytest.skip(f"{system} does not support telemetry run.")
    if not system_config.get("withdata", False):
        pytest.skip(f"{system} does not support telemetry run with data.")

    if isinstance(system_file, list):
        file_list = [DATA_PATH / system / x for x in system_file]
    else:
        file_list = [DATA_PATH / system / system_file]
    for file in file_list:
        assert os.path.isfile(file) or os.path.isdir(file), \
            f"File `{file}' does not exist. does ./data exist or is RAPS_DATA_DIR set?"
    os.chdir(PROJECT_ROOT)
    result = subprocess.run([
        "python", "main.py", "telemetry",
        "--system", system,
        "-f", *file_list,
        "-f", *system_files,
        "-o", sim_output,
    ], capture_output=True, text=True, stdin=subprocess.DEVNULL)
    assert result.returncode == 0, f"Failed on {system}: {result.stderr}"