ansys-fluent-core 0.28.1__py3-none-any.whl → 0.29.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-fluent-core might be problematic. Click here for more details.
- ansys/fluent/core/__init__.py +26 -1
- ansys/fluent/core/_stand_alone_datamodel_client/_datamodel_client.py +22 -0
- ansys/fluent/core/_version.py +24 -2
- ansys/fluent/core/codegen/__init__.py +22 -0
- ansys/fluent/core/codegen/allapigen.py +38 -5
- ansys/fluent/core/codegen/builtin_settingsgen.py +22 -0
- ansys/fluent/core/codegen/data/__init__.py +21 -0
- ansys/fluent/core/codegen/data/fluent_gui_help_patch.py +22 -0
- ansys/fluent/core/codegen/data/meshing_utilities_examples.py +22 -0
- ansys/fluent/core/codegen/datamodelgen.py +40 -4
- ansys/fluent/core/codegen/print_fluent_version.py +22 -0
- ansys/fluent/core/codegen/settingsgen.py +67 -4
- ansys/fluent/core/codegen/tuigen.py +44 -6
- ansys/fluent/core/codegen/walk_api.py +67 -18
- ansys/fluent/core/codegen/write_settings_yaml.py +22 -0
- ansys/fluent/core/data_model_cache.py +22 -0
- ansys/fluent/core/examples/__init__.py +22 -0
- ansys/fluent/core/examples/downloads.py +22 -0
- ansys/fluent/core/exceptions.py +22 -0
- ansys/fluent/core/file_session.py +22 -0
- ansys/fluent/core/filereader/__init__.py +21 -0
- ansys/fluent/core/filereader/case_file.py +22 -0
- ansys/fluent/core/filereader/casereader.py +22 -0
- ansys/fluent/core/filereader/data_file.py +22 -0
- ansys/fluent/core/filereader/lispy.py +22 -0
- ansys/fluent/core/fluent_connection.py +23 -1
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_252/meshing.py +32 -0
- ansys/fluent/core/generated/datamodel_252/preferences.py +7 -0
- ansys/fluent/core/generated/fluent_version_252.py +3 -3
- ansys/fluent/core/generated/meshing/tui_252.py +395 -390
- ansys/fluent/core/generated/solver/settings_222.py +0 -72
- ansys/fluent/core/generated/solver/settings_222.pyi +0 -307
- ansys/fluent/core/generated/solver/settings_231.py +0 -574
- ansys/fluent/core/generated/solver/settings_231.pyi +0 -561
- ansys/fluent/core/generated/solver/settings_232.py +0 -527
- ansys/fluent/core/generated/solver/settings_232.pyi +0 -2803
- ansys/fluent/core/generated/solver/settings_241.py +0 -478
- ansys/fluent/core/generated/solver/settings_241.pyi +0 -522
- ansys/fluent/core/generated/solver/settings_242.py +0 -361
- ansys/fluent/core/generated/solver/settings_242.pyi +0 -591
- ansys/fluent/core/generated/solver/settings_251.py +0 -399
- ansys/fluent/core/generated/solver/settings_251.pyi +0 -629
- ansys/fluent/core/generated/solver/settings_252.py +8118 -4206
- ansys/fluent/core/generated/solver/settings_252.pyi +7229 -3259
- ansys/fluent/core/generated/solver/tui_252.py +4508 -3877
- ansys/fluent/core/get_build_details.py +22 -0
- ansys/fluent/core/journaling.py +38 -0
- ansys/fluent/core/launcher/__init__.py +22 -0
- ansys/fluent/core/launcher/container_launcher.py +65 -56
- ansys/fluent/core/launcher/error_handler.py +30 -0
- ansys/fluent/core/launcher/fluent_container.py +45 -20
- ansys/fluent/core/launcher/launcher.py +53 -5
- ansys/fluent/core/launcher/launcher_utils.py +22 -0
- ansys/fluent/core/launcher/pim_launcher.py +120 -86
- ansys/fluent/core/launcher/process_launch_string.py +22 -0
- ansys/fluent/core/launcher/pyfluent_enums.py +22 -0
- ansys/fluent/core/launcher/server_info.py +45 -3
- ansys/fluent/core/launcher/slurm_launcher.py +25 -3
- ansys/fluent/core/launcher/standalone_launcher.py +68 -63
- ansys/fluent/core/launcher/watchdog.py +22 -0
- ansys/fluent/core/logging.py +24 -0
- ansys/fluent/core/logging_config.yaml +3 -0
- ansys/fluent/core/meshing/meshing_workflow.py +22 -0
- ansys/fluent/core/parametric.py +22 -0
- ansys/fluent/core/post_objects/__init__.py +21 -0
- ansys/fluent/core/post_objects/check_in_notebook.py +22 -0
- ansys/fluent/core/post_objects/meta.py +22 -0
- ansys/fluent/core/post_objects/post_helper.py +22 -0
- ansys/fluent/core/post_objects/post_object_definitions.py +22 -0
- ansys/fluent/core/post_objects/post_objects_container.py +22 -0
- ansys/fluent/core/post_objects/singleton_meta.py +22 -0
- ansys/fluent/core/post_objects/timing_decorator.py +22 -0
- ansys/fluent/core/report.py +77 -0
- ansys/fluent/core/rpvars.py +22 -0
- ansys/fluent/core/scheduler/__init__.py +22 -0
- ansys/fluent/core/scheduler/load_machines.py +22 -0
- ansys/fluent/core/scheduler/machine_list.py +22 -0
- ansys/fluent/core/search.py +22 -0
- ansys/fluent/core/services/__init__.py +22 -0
- ansys/fluent/core/services/api_upgrade.py +22 -0
- ansys/fluent/core/services/app_utilities.py +38 -0
- ansys/fluent/core/services/batch_ops.py +22 -0
- ansys/fluent/core/services/datamodel_se.py +163 -61
- ansys/fluent/core/services/datamodel_tui.py +22 -0
- ansys/fluent/core/services/deprecated_field_data.py +23 -1
- ansys/fluent/core/services/events.py +22 -0
- ansys/fluent/core/services/field_data.py +285 -2
- ansys/fluent/core/services/health_check.py +22 -0
- ansys/fluent/core/services/interceptors.py +50 -2
- ansys/fluent/core/services/monitor.py +22 -0
- ansys/fluent/core/services/reduction.py +22 -0
- ansys/fluent/core/services/scheme_eval.py +22 -0
- ansys/fluent/core/services/settings.py +22 -0
- ansys/fluent/core/services/solution_variables.py +22 -0
- ansys/fluent/core/services/streaming.py +22 -0
- ansys/fluent/core/services/transcript.py +22 -0
- ansys/fluent/core/session.py +39 -2
- ansys/fluent/core/session_base_meshing.py +22 -0
- ansys/fluent/core/session_meshing.py +22 -0
- ansys/fluent/core/session_meshing.pyi +22 -0
- ansys/fluent/core/session_pure_meshing.py +22 -0
- ansys/fluent/core/session_pure_meshing.pyi +22 -0
- ansys/fluent/core/session_shared.py +22 -0
- ansys/fluent/core/session_solver.py +43 -0
- ansys/fluent/core/session_solver.pyi +22 -0
- ansys/fluent/core/session_solver_aero.py +22 -0
- ansys/fluent/core/session_solver_icing.py +22 -0
- ansys/fluent/core/session_solver_lite.py +22 -0
- ansys/fluent/core/solver/__init__.py +22 -0
- ansys/fluent/core/solver/error_message.py +22 -0
- ansys/fluent/core/solver/flobject.py +22 -0
- ansys/fluent/core/solver/flunits.py +22 -0
- ansys/fluent/core/solver/function/__init__.py +22 -0
- ansys/fluent/core/solver/function/reduction.py +22 -0
- ansys/fluent/core/solver/settings_builtin_bases.py +22 -0
- ansys/fluent/core/solver/settings_builtin_data.py +22 -0
- ansys/fluent/core/solver/settings_external.py +22 -0
- ansys/fluent/core/streaming_services/__init__.py +21 -0
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +34 -12
- ansys/fluent/core/streaming_services/datamodel_streaming.py +22 -0
- ansys/fluent/core/streaming_services/events_streaming.py +22 -0
- ansys/fluent/core/streaming_services/field_data_streaming.py +22 -0
- ansys/fluent/core/streaming_services/monitor_streaming.py +23 -1
- ansys/fluent/core/streaming_services/streaming.py +22 -0
- ansys/fluent/core/streaming_services/transcript_streaming.py +22 -0
- ansys/fluent/core/systemcoupling.py +22 -0
- ansys/fluent/core/utils/__init__.py +22 -0
- ansys/fluent/core/utils/data_transfer.py +22 -0
- ansys/fluent/core/utils/deprecate.py +24 -1
- ansys/fluent/core/utils/dictionary_operations.py +22 -0
- ansys/fluent/core/utils/dump_session_data.py +22 -0
- ansys/fluent/core/utils/event_loop.py +22 -0
- ansys/fluent/core/utils/execution.py +22 -0
- ansys/fluent/core/utils/file_transfer_service.py +22 -0
- ansys/fluent/core/utils/fix_doc.py +22 -0
- ansys/fluent/core/utils/fldoc.py +22 -0
- ansys/fluent/core/utils/fluent_version.py +22 -0
- ansys/fluent/core/utils/networking.py +22 -0
- ansys/fluent/core/utils/setup_for_fluent.py +22 -0
- ansys/fluent/core/warnings.py +22 -0
- ansys/fluent/core/workflow.py +22 -0
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/LICENSE +8 -8
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/METADATA +56 -33
- ansys_fluent_core-0.29.0.dist-info/RECORD +219 -0
- {ansys_fluent_core-0.28.1.dist-info → ansys_fluent_core-0.29.0.dist-info}/WHEEL +1 -1
- ansys/fluent/core/docs/README.rst +0 -155
- ansys/fluent/tests/conftest.py +0 -415
- ansys/fluent/tests/fluent_fixtures.py +0 -195
- ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
- ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
- ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
- ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
- ansys/fluent/tests/test_aero_session.py +0 -88
- ansys/fluent/tests/test_batch_ops.py +0 -39
- ansys/fluent/tests/test_builtin_settings.py +0 -761
- ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
- ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
- ansys/fluent/tests/test_casereader.py +0 -324
- ansys/fluent/tests/test_codegen.py +0 -783
- ansys/fluent/tests/test_creatable.py +0 -31
- ansys/fluent/tests/test_data_model_cache.py +0 -434
- ansys/fluent/tests/test_datamodel_api.py +0 -449
- ansys/fluent/tests/test_datamodel_service.py +0 -814
- ansys/fluent/tests/test_datareader.py +0 -103
- ansys/fluent/tests/test_error_handling.py +0 -24
- ansys/fluent/tests/test_events_manager.py +0 -214
- ansys/fluent/tests/test_field_data.py +0 -466
- ansys/fluent/tests/test_file_session.py +0 -355
- ansys/fluent/tests/test_file_transfer_service.py +0 -165
- ansys/fluent/tests/test_fix_doc.py +0 -29
- ansys/fluent/tests/test_flobject.py +0 -1235
- ansys/fluent/tests/test_fluent_fixes.py +0 -106
- ansys/fluent/tests/test_fluent_session.py +0 -270
- ansys/fluent/tests/test_fluent_version.py +0 -66
- ansys/fluent/tests/test_fluent_version_marker.py +0 -65
- ansys/fluent/tests/test_icing_session.py +0 -9
- ansys/fluent/tests/test_launcher.py +0 -529
- ansys/fluent/tests/test_launcher_remote.py +0 -272
- ansys/fluent/tests/test_lispy.py +0 -40
- ansys/fluent/tests/test_logging.py +0 -16
- ansys/fluent/tests/test_mapped_api.py +0 -774
- ansys/fluent/tests/test_meshing_utilities.py +0 -2436
- ansys/fluent/tests/test_meshing_workflow.py +0 -421
- ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
- ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
- ansys/fluent/tests/test_preferences.py +0 -89
- ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
- ansys/fluent/tests/test_reduction.py +0 -484
- ansys/fluent/tests/test_rp_vars.py +0 -77
- ansys/fluent/tests/test_scheduler.py +0 -471
- ansys/fluent/tests/test_scheme_eval_222.py +0 -338
- ansys/fluent/tests/test_scheme_eval_231.py +0 -243
- ansys/fluent/tests/test_search.py +0 -344
- ansys/fluent/tests/test_session.py +0 -594
- ansys/fluent/tests/test_settings_api.py +0 -606
- ansys/fluent/tests/test_settings_reader.py +0 -85
- ansys/fluent/tests/test_slurm_future.py +0 -67
- ansys/fluent/tests/test_solution_variables.py +0 -241
- ansys/fluent/tests/test_solver_monitors.py +0 -83
- ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
- ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
- ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
- ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
- ansys/fluent/tests/test_solvermode/test_general.py +0 -109
- ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
- ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
- ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
- ansys/fluent/tests/test_solvermode/test_models.py +0 -99
- ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
- ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
- ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
- ansys/fluent/tests/test_streaming_services.py +0 -52
- ansys/fluent/tests/test_systemcoupling.py +0 -44
- ansys/fluent/tests/test_topy.py +0 -179
- ansys/fluent/tests/test_tui_api.py +0 -70
- ansys/fluent/tests/test_type_stub.py +0 -37
- ansys/fluent/tests/test_utils.py +0 -82
- ansys/fluent/tests/util/__init__.py +0 -36
- ansys/fluent/tests/util/meshing_workflow.py +0 -33
- ansys/fluent/tests/util/solver.py +0 -72
- ansys_fluent_core-0.28.1.dist-info/AUTHORS +0 -12
- ansys_fluent_core-0.28.1.dist-info/RECORD +0 -294
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from ansys.fluent.core.examples import download_file, path
|
|
4
|
-
from ansys.fluent.core.filereader.casereader import CaseReader
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_get_and_set_rp_vars(new_solver_session) -> None:
|
|
8
|
-
case_path = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
|
|
9
|
-
solver = new_solver_session
|
|
10
|
-
solver.tui.file.read_case(case_path)
|
|
11
|
-
rp_vars = solver.rp_vars
|
|
12
|
-
|
|
13
|
-
# simple integer
|
|
14
|
-
iter_count = 54321
|
|
15
|
-
rp_vars("number-of-iterations", iter_count)
|
|
16
|
-
assert iter_count == rp_vars("number-of-iterations")
|
|
17
|
-
|
|
18
|
-
# complex list structure
|
|
19
|
-
before_init_mod = rp_vars("strategy/solution-strategy/before-init-modification")
|
|
20
|
-
assert before_init_mod[1][1][1] == ("value", False)
|
|
21
|
-
before_init_mod[1][1][1] = ("value", True)
|
|
22
|
-
rp_vars("strategy/solution-strategy/before-init-modification", before_init_mod)
|
|
23
|
-
before_init_mod_2 = rp_vars("strategy/solution-strategy/before-init-modification")
|
|
24
|
-
assert before_init_mod_2[1][1][1] == ("value", True)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@pytest.mark.fluent_version(">=23.1, !=24.1")
|
|
28
|
-
def test_get_all_rp_vars(new_solver_session) -> None:
|
|
29
|
-
case_path = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
|
|
30
|
-
solver = new_solver_session
|
|
31
|
-
solver.tui.file.read_case(case_path)
|
|
32
|
-
rp_vars = solver.rp_vars
|
|
33
|
-
# all vars
|
|
34
|
-
all_vars = rp_vars()
|
|
35
|
-
assert len(all_vars) == pytest.approx(9000, 10)
|
|
36
|
-
|
|
37
|
-
# refresh
|
|
38
|
-
solver.file.write(file_type="case", file_name=case_path)
|
|
39
|
-
solver.tui.file.read_case(case_path)
|
|
40
|
-
|
|
41
|
-
# all vars again
|
|
42
|
-
all_vars = rp_vars()
|
|
43
|
-
assert len(all_vars) == pytest.approx(9000, 20)
|
|
44
|
-
|
|
45
|
-
# CaseFile comparison, note that the PyFluent work dir is not necessarily the same as the Fluent work dir
|
|
46
|
-
case = CaseReader(case_file_name=path(case_path))
|
|
47
|
-
case_vars = case.rp_vars()
|
|
48
|
-
assert len(case_vars) == pytest.approx(9000, 450)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@pytest.mark.fluent_version(">=23.2")
|
|
52
|
-
def test_rp_vars_allowed_values(new_solver_session) -> None:
|
|
53
|
-
solver = new_solver_session
|
|
54
|
-
rp_vars = solver.rp_vars
|
|
55
|
-
|
|
56
|
-
assert rp_vars("number-of-iterations") == 0
|
|
57
|
-
|
|
58
|
-
with pytest.raises(RuntimeError):
|
|
59
|
-
rp_vars("number-of-iterat")
|
|
60
|
-
|
|
61
|
-
assert "number-of-iterations" in rp_vars.allowed_values()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@pytest.mark.fluent_version(">=23.2")
|
|
65
|
-
def test_rp_vars_boolean(new_solver_session) -> None:
|
|
66
|
-
solver = new_solver_session
|
|
67
|
-
|
|
68
|
-
var_name = "rp-lam?"
|
|
69
|
-
rp_vars = solver.rp_vars
|
|
70
|
-
|
|
71
|
-
var_val = rp_vars(var_name)
|
|
72
|
-
assert isinstance(var_val, bool)
|
|
73
|
-
|
|
74
|
-
for i in range(10):
|
|
75
|
-
var_val = not var_val
|
|
76
|
-
rp_vars(var_name, var_val)
|
|
77
|
-
assert rp_vars(var_name) == var_val
|
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
"""Provide a module to test the algorithms which parse job scheduler environments for
|
|
2
|
-
machines to run on."""
|
|
3
|
-
|
|
4
|
-
from builtins import range
|
|
5
|
-
import os
|
|
6
|
-
import socket
|
|
7
|
-
import tempfile
|
|
8
|
-
import unittest
|
|
9
|
-
|
|
10
|
-
from ansys.fluent.core.scheduler import build_parallel_options
|
|
11
|
-
from ansys.fluent.core.scheduler.load_machines import (
|
|
12
|
-
_construct_machine_list_slurm,
|
|
13
|
-
_parse_host_info,
|
|
14
|
-
_parse_machine_data,
|
|
15
|
-
_restrict_machines_to_core_count,
|
|
16
|
-
load_machines,
|
|
17
|
-
)
|
|
18
|
-
from ansys.fluent.core.scheduler.machine_list import Machine, MachineList
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class TestMachine(unittest.TestCase):
|
|
22
|
-
"""A basic test that checks Machine object behavior."""
|
|
23
|
-
|
|
24
|
-
def setUp(self):
|
|
25
|
-
pass
|
|
26
|
-
|
|
27
|
-
def tearDown(self):
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
|
-
def test_initialize_host(self):
|
|
31
|
-
"""Test that a Machine initializes as expected."""
|
|
32
|
-
machine = Machine("machine", 20)
|
|
33
|
-
self.assertEqual(machine.host_name, "machine")
|
|
34
|
-
self.assertEqual(machine.number_of_cores, 20)
|
|
35
|
-
self.assertEqual(machine.queue_name, None)
|
|
36
|
-
self.assertEqual(machine.core_list, None)
|
|
37
|
-
|
|
38
|
-
def test_modify_host(self):
|
|
39
|
-
"""Test that a Machine can be modified."""
|
|
40
|
-
machine = Machine("machine", 20, "allq", "0:0")
|
|
41
|
-
machine.number_of_cores = 12
|
|
42
|
-
self.assertEqual(machine.number_of_cores, 12)
|
|
43
|
-
machine.number_of_cores = machine.number_of_cores + 2
|
|
44
|
-
machine.number_of_cores += 1
|
|
45
|
-
self.assertEqual(machine.number_of_cores, 15)
|
|
46
|
-
machine.number_of_cores -= 3
|
|
47
|
-
self.assertEqual(machine.number_of_cores, 12)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class TestMachineList(unittest.TestCase):
|
|
51
|
-
"""Provide a test suite that checks that the MachineList object behaves properly."""
|
|
52
|
-
|
|
53
|
-
def setUp(self):
|
|
54
|
-
self._machineList = MachineList()
|
|
55
|
-
|
|
56
|
-
def tearDown(self):
|
|
57
|
-
self._machineList.reset()
|
|
58
|
-
|
|
59
|
-
def test_initialize_machinelist(self):
|
|
60
|
-
"""Tests that a host file object initializes properly."""
|
|
61
|
-
newMachineFile = MachineList()
|
|
62
|
-
self.assertIsInstance(newMachineFile, MachineList)
|
|
63
|
-
self.assertEqual(newMachineFile.machines, [])
|
|
64
|
-
self.assertEqual(newMachineFile.num_machines, 0)
|
|
65
|
-
|
|
66
|
-
def test_copy_machinelist(self):
|
|
67
|
-
"""Tests that the internal copy function works properly."""
|
|
68
|
-
import copy
|
|
69
|
-
|
|
70
|
-
newMachineList = copy.deepcopy(self._machineList)
|
|
71
|
-
for m1, m2 in zip(self._machineList.machines, newMachineList.machines):
|
|
72
|
-
self.assertEqual(m1.host_name, m2.host_name)
|
|
73
|
-
self.assertEqual(m1.number_of_cores, m2.number_of_cores)
|
|
74
|
-
|
|
75
|
-
def test_add_to_machinelist(self):
|
|
76
|
-
"""Tests that a machines can be added to a machine list."""
|
|
77
|
-
self._machineList.add(Machine("machine1", 20, "allq", "0:0"))
|
|
78
|
-
self._machineList.add(Machine("machine2", 20, "allq", "0:0"))
|
|
79
|
-
self.assertEqual(self._machineList.num_machines, 2)
|
|
80
|
-
|
|
81
|
-
def test_number_of_cores_and_machines(self):
|
|
82
|
-
"""Test that the total and max number of cores and machines is working."""
|
|
83
|
-
self._machineList.add(Machine("machine1", 20, "allq", "0:0"))
|
|
84
|
-
self._machineList.add(Machine("machine2", 25, "allq", "0:0"))
|
|
85
|
-
self._machineList.add(Machine("machine3", 15, "allq", "0:0"))
|
|
86
|
-
self.assertEqual(self._machineList.num_machines, 3)
|
|
87
|
-
self.assertEqual(self._machineList.number_of_cores, 60)
|
|
88
|
-
self.assertEqual(self._machineList.max_cores, 25)
|
|
89
|
-
self.assertEqual(self._machineList.min_cores, 15)
|
|
90
|
-
|
|
91
|
-
def test_sort_machine_list(self):
|
|
92
|
-
"""Test that the machines are sorted in order of decreasing core count."""
|
|
93
|
-
self._machineList.add(Machine("machine1", 15, "allq", "0:0"))
|
|
94
|
-
self._machineList.add(Machine("machine2", 10, "allq", "0:0"))
|
|
95
|
-
self._machineList.add(Machine("machine3", 5, "allq", "0:0"))
|
|
96
|
-
|
|
97
|
-
# Sort in ascending order
|
|
98
|
-
self._machineList.sort_by_core_count_ascending()
|
|
99
|
-
numCores = self._machineList.machines[0].number_of_cores
|
|
100
|
-
for h in range(1, len(self._machineList.machines)):
|
|
101
|
-
self.assertLessEqual(
|
|
102
|
-
numCores, self._machineList.machines[h].number_of_cores
|
|
103
|
-
)
|
|
104
|
-
numCores = self._machineList.machines[h].number_of_cores
|
|
105
|
-
|
|
106
|
-
# Sort in descending order
|
|
107
|
-
self._machineList.sort_by_core_count()
|
|
108
|
-
numCores = self._machineList.machines[0].number_of_cores
|
|
109
|
-
for h in range(1, len(self._machineList.machines)):
|
|
110
|
-
self.assertLessEqual(
|
|
111
|
-
self._machineList.machines[h].number_of_cores, numCores
|
|
112
|
-
)
|
|
113
|
-
numCores = self._machineList.machines[h].number_of_cores
|
|
114
|
-
|
|
115
|
-
def test_remote_empty_machines(self):
|
|
116
|
-
self._machineList.add(Machine("machine1", 5))
|
|
117
|
-
self._machineList.add(Machine("machine2", 0))
|
|
118
|
-
self._machineList.remove_empty_machines()
|
|
119
|
-
self.assertEqual(self._machineList.num_machines, 1)
|
|
120
|
-
self.assertEqual(self._machineList.machines[0].host_name, "machine1")
|
|
121
|
-
|
|
122
|
-
def test_move_local_host_to_front(self):
|
|
123
|
-
import socket
|
|
124
|
-
|
|
125
|
-
localHostName = socket.gethostname()
|
|
126
|
-
|
|
127
|
-
self._machineList.add(Machine("M0", 2))
|
|
128
|
-
self._machineList.add(Machine(localHostName, 1))
|
|
129
|
-
self._machineList.add(Machine("M1", 3))
|
|
130
|
-
self._machineList.move_local_host_to_front()
|
|
131
|
-
self.assertEqual(self._machineList.machines[0].host_name, localHostName)
|
|
132
|
-
self.assertEqual(self._machineList.machines[0].number_of_cores, 1)
|
|
133
|
-
self.assertEqual(self._machineList.machines[1].host_name, "M0")
|
|
134
|
-
self.assertEqual(self._machineList.machines[1].number_of_cores, 2)
|
|
135
|
-
self.assertEqual(self._machineList.machines[2].host_name, "M1")
|
|
136
|
-
self.assertEqual(self._machineList.machines[2].number_of_cores, 3)
|
|
137
|
-
|
|
138
|
-
def test_deep_copy_machinelist(self):
|
|
139
|
-
self._machineList.add(Machine("wathpc-2-0.local", 23))
|
|
140
|
-
self._machineList.add(Machine("wathpc-2-1.local", 23))
|
|
141
|
-
self._machineList.add(Machine("wathpc-2-2.local", 23))
|
|
142
|
-
self._machineList.add(Machine("wathpc-2-3.local", 23))
|
|
143
|
-
import copy
|
|
144
|
-
|
|
145
|
-
machineListCopy = copy.deepcopy(self._machineList)
|
|
146
|
-
for m1, m2 in zip(self._machineList.machines, machineListCopy.machines):
|
|
147
|
-
self.assertEqual(m1.host_name, m2.host_name)
|
|
148
|
-
self.assertEqual(m1.number_of_cores, m2.number_of_cores)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
class TestLoadMachines(unittest.TestCase):
|
|
152
|
-
"""Provide a test suite that checks that loadMachines behaves properly."""
|
|
153
|
-
|
|
154
|
-
def setUp(self):
|
|
155
|
-
self._machineList = MachineList()
|
|
156
|
-
|
|
157
|
-
def tearDown(self):
|
|
158
|
-
self._machineList.reset()
|
|
159
|
-
|
|
160
|
-
def test_machine_info(self):
|
|
161
|
-
info = [
|
|
162
|
-
{"machine-name": "M0", "core-count": 1},
|
|
163
|
-
{"machine-name": "M1", "core-count": 6},
|
|
164
|
-
]
|
|
165
|
-
machineList = load_machines(machine_info=info)
|
|
166
|
-
self.assertEqual(machineList.number_of_cores, 7)
|
|
167
|
-
|
|
168
|
-
def test_restrict_machines(self):
|
|
169
|
-
info = [
|
|
170
|
-
{"machine-name": "M0", "core-count": 1},
|
|
171
|
-
{"machine-name": "M1", "core-count": 1},
|
|
172
|
-
]
|
|
173
|
-
machineList = load_machines(machine_info=info)
|
|
174
|
-
old_machine_list = _restrict_machines_to_core_count(
|
|
175
|
-
machineList, ncores=machineList.number_of_cores
|
|
176
|
-
)
|
|
177
|
-
self.assertEqual(machineList, old_machine_list)
|
|
178
|
-
|
|
179
|
-
def test_pe_hostfile(self):
|
|
180
|
-
with tempfile.NamedTemporaryFile(delete=False) as fp:
|
|
181
|
-
fp.write(b"m1\r\n\r\nm2 3 None None\r\nm3 4\r\nm4 2 queueName1")
|
|
182
|
-
os.environ["PE_HOSTFILE"] = fp.name
|
|
183
|
-
machineList = load_machines()
|
|
184
|
-
os.unlink(fp.name)
|
|
185
|
-
self.assertEqual(machineList.number_of_cores, 10)
|
|
186
|
-
self.assertEqual(machineList.machines[1].host_name, "m2")
|
|
187
|
-
self.assertEqual(machineList.machines[2].number_of_cores, 4)
|
|
188
|
-
self.assertEqual(machineList.machines[3].queue_name, "queueName1")
|
|
189
|
-
del os.environ["PE_HOSTFILE"]
|
|
190
|
-
|
|
191
|
-
def test_lsb_mcpu(self):
|
|
192
|
-
os.environ["LSB_MCPU_HOSTS"] = "m1 3 m2 3"
|
|
193
|
-
machineList = load_machines()
|
|
194
|
-
self.assertEqual(machineList.number_of_cores, 6)
|
|
195
|
-
del os.environ["LSB_MCPU_HOSTS"]
|
|
196
|
-
|
|
197
|
-
def test_pbs_nodefile(self):
|
|
198
|
-
with tempfile.NamedTemporaryFile(delete=False) as fp:
|
|
199
|
-
fp.write(b"m1\r\n\r\nm2\r\nm2\r\nm2")
|
|
200
|
-
os.environ["PBS_NODEFILE"] = fp.name
|
|
201
|
-
machineList = load_machines()
|
|
202
|
-
os.unlink(fp.name)
|
|
203
|
-
self.assertEqual(machineList[1].number_of_cores, 3)
|
|
204
|
-
del os.environ["PBS_NODEFILE"]
|
|
205
|
-
|
|
206
|
-
def test_no_environment(self):
|
|
207
|
-
machineList = load_machines()
|
|
208
|
-
self.assertEqual(machineList[0].host_name, socket.gethostname())
|
|
209
|
-
self.assertEqual(machineList.number_of_cores, 1)
|
|
210
|
-
|
|
211
|
-
def test_no_environment_cores(self):
|
|
212
|
-
machineList = load_machines(ncores=4)
|
|
213
|
-
self.assertEqual(machineList[0].host_name, socket.gethostname())
|
|
214
|
-
self.assertEqual(machineList.number_of_cores, 4)
|
|
215
|
-
|
|
216
|
-
def test_constrain_machines1(self):
|
|
217
|
-
machineList = load_machines(host_info="M0:2,M1:3,M2:2", ncores=4)
|
|
218
|
-
expectedValue = {"M0": 1, "M1": 2, "M2": 1}
|
|
219
|
-
self.assertEqual(len(machineList.machines), 3)
|
|
220
|
-
for machine in machineList.machines:
|
|
221
|
-
self.assertEqual(machine.number_of_cores, expectedValue[machine.host_name])
|
|
222
|
-
# Ensure that the order is preserved
|
|
223
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
224
|
-
fluentOpts = build_parallel_options(machineList)
|
|
225
|
-
self.assertEqual(fluentOpts, "-t4 -cnf=M0:1,M1:2,M2:1")
|
|
226
|
-
|
|
227
|
-
def test_constrain_machines2(self):
|
|
228
|
-
with tempfile.NamedTemporaryFile(delete=False) as fp:
|
|
229
|
-
fp.write(b"M0:2,M1:3,M2:2")
|
|
230
|
-
machineList = load_machines(host_info=fp.name, ncores=3)
|
|
231
|
-
expectedValue = {"M0": 1, "M1": 1, "M2": 1}
|
|
232
|
-
os.unlink(fp.name)
|
|
233
|
-
self.assertEqual(len(machineList.machines), 3)
|
|
234
|
-
for machine in machineList.machines:
|
|
235
|
-
self.assertEqual(machine.number_of_cores, expectedValue[machine.host_name])
|
|
236
|
-
# Ensure that the order is preserved
|
|
237
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
238
|
-
fluentOpts = build_parallel_options(machineList)
|
|
239
|
-
self.assertEqual(fluentOpts, "-t3 -cnf=M0:1,M1:1,M2:1")
|
|
240
|
-
|
|
241
|
-
def test_overload_machines1(self):
|
|
242
|
-
machineList = load_machines(host_info="M0:2,M1:1", ncores=10)
|
|
243
|
-
expectedValue = {"M0": 2, "M1": 1}
|
|
244
|
-
self.assertEqual(len(machineList.machines), 2)
|
|
245
|
-
for machine in machineList.machines:
|
|
246
|
-
self.assertEqual(machine.number_of_cores, expectedValue[machine.host_name])
|
|
247
|
-
# Ensure that the order is preserved
|
|
248
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
249
|
-
fluentOpts = build_parallel_options(machineList)
|
|
250
|
-
self.assertEqual(fluentOpts, "-t3 -cnf=M0:2,M1:1")
|
|
251
|
-
|
|
252
|
-
def test_overload_machines2(self):
|
|
253
|
-
machineList = load_machines(host_info="M0,M0,M1", ncores=10)
|
|
254
|
-
expectedValue = {"M0": 2, "M1": 1}
|
|
255
|
-
self.assertEqual(len(machineList.machines), 2)
|
|
256
|
-
for machine in machineList.machines:
|
|
257
|
-
self.assertEqual(machine.number_of_cores, expectedValue[machine.host_name])
|
|
258
|
-
# Ensure that the order is preserved
|
|
259
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
260
|
-
fluentOpts = build_parallel_options(machineList)
|
|
261
|
-
self.assertEqual(fluentOpts, "-t3 -cnf=M0:2,M1:1")
|
|
262
|
-
|
|
263
|
-
def test_winhpc(self):
|
|
264
|
-
os.environ["CCP_NODES"] = "3 M0 8 M1 8 M2 16"
|
|
265
|
-
machineList = load_machines()
|
|
266
|
-
self.assertEqual(machineList.num_machines, 3)
|
|
267
|
-
self.assertEqual(machineList.number_of_cores, 32)
|
|
268
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
269
|
-
self.assertEqual(machineList.machines[1].host_name, "M1")
|
|
270
|
-
self.assertEqual(machineList.machines[2].host_name, "M2")
|
|
271
|
-
fluentOpts = build_parallel_options(machineList)
|
|
272
|
-
self.assertEqual(fluentOpts, "-t32 -cnf=M0:8,M1:8,M2:16")
|
|
273
|
-
del os.environ["CCP_NODES"]
|
|
274
|
-
|
|
275
|
-
def test_slurm_single_num(self):
|
|
276
|
-
os.environ["SLURM_JOB_NODELIST"] = "M[1-2],M[3]"
|
|
277
|
-
os.environ["SLURM_TASKS_PER_NODE"] = "8,10(x2)"
|
|
278
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
279
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
280
|
-
self.assertEqual(machineList[1].number_of_cores, 10)
|
|
281
|
-
self.assertEqual(machineList[2].number_of_cores, 10)
|
|
282
|
-
self.assertEqual(machineList[2].host_name, "M3")
|
|
283
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
284
|
-
del os.environ["SLURM_TASKS_PER_NODE"]
|
|
285
|
-
|
|
286
|
-
def test_slurm_no_brackets(self):
|
|
287
|
-
os.environ["SLURM_JOB_NODELIST"] = "M0,M1,M2"
|
|
288
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "8"
|
|
289
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
290
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
291
|
-
self.assertEqual(machineList.num_machines, 3)
|
|
292
|
-
self.assertEqual(machineList.number_of_cores, 24)
|
|
293
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
294
|
-
self.assertEqual(machineList.machines[1].host_name, "M1")
|
|
295
|
-
self.assertEqual(machineList.machines[2].host_name, "M2")
|
|
296
|
-
fluentOpts = build_parallel_options(machineList)
|
|
297
|
-
self.assertEqual(fluentOpts, "-t24 -cnf=M0:8,M1:8,M2:8")
|
|
298
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
299
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
300
|
-
|
|
301
|
-
def test_slurm_no_padding(self):
|
|
302
|
-
os.environ["SLURM_JOB_NODELIST"] = "M[0-2]"
|
|
303
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "12"
|
|
304
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
305
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
306
|
-
self.assertEqual(machineList.num_machines, 3)
|
|
307
|
-
self.assertEqual(machineList.number_of_cores, 36)
|
|
308
|
-
self.assertEqual(machineList.machines[0].host_name, "M0")
|
|
309
|
-
self.assertEqual(machineList.machines[1].host_name, "M1")
|
|
310
|
-
self.assertEqual(machineList.machines[2].host_name, "M2")
|
|
311
|
-
fluentOpts = build_parallel_options(machineList)
|
|
312
|
-
self.assertEqual(fluentOpts, "-t36 -cnf=M0:12,M1:12,M2:12")
|
|
313
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
314
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
315
|
-
|
|
316
|
-
def test_slurm_hosts_with_dash(self):
|
|
317
|
-
os.environ["SLURM_JOB_NODELIST"] = "M-n50-[0-1],M-p50-[9-11]"
|
|
318
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "12"
|
|
319
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
320
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
321
|
-
self.assertEqual(machineList.num_machines, 5)
|
|
322
|
-
self.assertEqual(machineList.number_of_cores, 60)
|
|
323
|
-
self.assertEqual(machineList.machines[0].host_name, "M-n50-0")
|
|
324
|
-
self.assertEqual(machineList.machines[1].host_name, "M-n50-1")
|
|
325
|
-
self.assertEqual(machineList.machines[2].host_name, "M-p50-9")
|
|
326
|
-
self.assertEqual(machineList.machines[3].host_name, "M-p50-10")
|
|
327
|
-
self.assertEqual(machineList.machines[4].host_name, "M-p50-11")
|
|
328
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
329
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
330
|
-
|
|
331
|
-
def test_slurm_with_padding(self):
|
|
332
|
-
os.environ["SLURM_JOB_NODELIST"] = "MC[008-009,010,011,012-014]"
|
|
333
|
-
os.environ["SLURM_TASKS_PER_NODE"] = "8,10(x2),12(x3),10"
|
|
334
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
335
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
336
|
-
self.assertEqual(machineList.num_machines, 7)
|
|
337
|
-
self.assertEqual(machineList.number_of_cores, 74)
|
|
338
|
-
self.assertEqual(machineList.machines[0].host_name, "MC008")
|
|
339
|
-
self.assertEqual(machineList.machines[0].number_of_cores, 8)
|
|
340
|
-
self.assertEqual(machineList.machines[1].host_name, "MC009")
|
|
341
|
-
self.assertEqual(machineList.machines[1].number_of_cores, 10)
|
|
342
|
-
self.assertEqual(machineList.machines[2].host_name, "MC010")
|
|
343
|
-
self.assertEqual(machineList.machines[2].number_of_cores, 10)
|
|
344
|
-
self.assertEqual(machineList.machines[3].host_name, "MC011")
|
|
345
|
-
self.assertEqual(machineList.machines[3].number_of_cores, 12)
|
|
346
|
-
self.assertEqual(machineList.machines[4].host_name, "MC012")
|
|
347
|
-
self.assertEqual(machineList.machines[4].number_of_cores, 12)
|
|
348
|
-
self.assertEqual(machineList.machines[5].host_name, "MC013")
|
|
349
|
-
self.assertEqual(machineList.machines[5].number_of_cores, 12)
|
|
350
|
-
self.assertEqual(machineList.machines[6].host_name, "MC014")
|
|
351
|
-
self.assertEqual(machineList.machines[6].number_of_cores, 10)
|
|
352
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
353
|
-
del os.environ["SLURM_TASKS_PER_NODE"]
|
|
354
|
-
|
|
355
|
-
def test_slurm_with_padding_one_hostlist(self):
|
|
356
|
-
os.environ["SLURM_JOB_NODELIST"] = "MD[099-101]"
|
|
357
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "12"
|
|
358
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
359
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
360
|
-
self.assertEqual(machineList.num_machines, 3)
|
|
361
|
-
self.assertEqual(machineList.number_of_cores, 36)
|
|
362
|
-
self.assertEqual(machineList.machines[0].host_name, "MD099")
|
|
363
|
-
self.assertEqual(machineList.machines[1].host_name, "MD100")
|
|
364
|
-
self.assertEqual(machineList.machines[2].host_name, "MD101")
|
|
365
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
366
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
367
|
-
|
|
368
|
-
def test_slurm_no_padding_commas(self):
|
|
369
|
-
os.environ["SLURM_JOB_NODELIST"] = "M[2-3,4,5-7,8-11,12-14,15-16]"
|
|
370
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "12"
|
|
371
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
372
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
373
|
-
self.assertEqual(machineList.num_machines, 15)
|
|
374
|
-
self.assertEqual(machineList.number_of_cores, 180)
|
|
375
|
-
self.assertEqual(machineList.machines[0].host_name, "M2")
|
|
376
|
-
self.assertEqual(machineList.machines[1].host_name, "M3")
|
|
377
|
-
self.assertEqual(machineList.machines[2].host_name, "M4")
|
|
378
|
-
self.assertEqual(machineList.machines[3].host_name, "M5")
|
|
379
|
-
self.assertEqual(machineList.machines[4].host_name, "M6")
|
|
380
|
-
self.assertEqual(machineList.machines[5].host_name, "M7")
|
|
381
|
-
self.assertEqual(machineList.machines[6].host_name, "M8")
|
|
382
|
-
self.assertEqual(machineList.machines[7].host_name, "M9")
|
|
383
|
-
self.assertEqual(machineList.machines[8].host_name, "M10")
|
|
384
|
-
self.assertEqual(machineList.machines[9].host_name, "M11")
|
|
385
|
-
self.assertEqual(machineList.machines[10].host_name, "M12")
|
|
386
|
-
self.assertEqual(machineList.machines[11].host_name, "M13")
|
|
387
|
-
self.assertEqual(machineList.machines[12].host_name, "M14")
|
|
388
|
-
self.assertEqual(machineList.machines[13].host_name, "M15")
|
|
389
|
-
self.assertEqual(machineList.machines[14].host_name, "M16")
|
|
390
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
391
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
392
|
-
|
|
393
|
-
def test_slurm_very_complex(self):
|
|
394
|
-
os.environ["SLURM_JOB_NODELIST"] = (
|
|
395
|
-
"M[2-3,4,5-7,8-11,12-14,15-16],MB,MC[008-009,010-011,012-014],MD[099-101]"
|
|
396
|
-
)
|
|
397
|
-
os.environ["SLURM_NTASKS_PER_NODE"] = "24"
|
|
398
|
-
hostList = os.environ.get("SLURM_JOB_NODELIST")
|
|
399
|
-
machineList = _construct_machine_list_slurm(hostList)
|
|
400
|
-
self.assertEqual(machineList.num_machines, 26)
|
|
401
|
-
self.assertEqual(machineList.number_of_cores, 624)
|
|
402
|
-
self.assertEqual(machineList.machines[0].host_name, "M2")
|
|
403
|
-
self.assertEqual(machineList.machines[0].number_of_cores, 24)
|
|
404
|
-
self.assertEqual(machineList.machines[7].host_name, "M9")
|
|
405
|
-
self.assertEqual(machineList.machines[14].host_name, "M16")
|
|
406
|
-
self.assertEqual(machineList.machines[15].host_name, "MB")
|
|
407
|
-
self.assertEqual(machineList.machines[16].host_name, "MC008")
|
|
408
|
-
self.assertEqual(machineList.machines[19].host_name, "MC011")
|
|
409
|
-
self.assertEqual(machineList.machines[22].host_name, "MC014")
|
|
410
|
-
self.assertEqual(machineList.machines[24].host_name, "MD100")
|
|
411
|
-
del os.environ["SLURM_JOB_NODELIST"]
|
|
412
|
-
del os.environ["SLURM_NTASKS_PER_NODE"]
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
class TestMachineListCmdLine(unittest.TestCase):
|
|
416
|
-
"""Provide a test suite that checks the machine list parser."""
|
|
417
|
-
|
|
418
|
-
def setUp(self):
|
|
419
|
-
self._expectedValues = {"M0": 2, "M1": 4}
|
|
420
|
-
|
|
421
|
-
def tearDown(self):
|
|
422
|
-
pass
|
|
423
|
-
|
|
424
|
-
def test_parse_machine_data(self):
|
|
425
|
-
machineDataList = [["M0:2", "M1:2", "M1:2"], ["M0", "M0", "M1", "M1:3"]]
|
|
426
|
-
|
|
427
|
-
for machineData in machineDataList:
|
|
428
|
-
machineList = _parse_machine_data(machineData)
|
|
429
|
-
for machine in machineList.machines:
|
|
430
|
-
self.assertEqual(
|
|
431
|
-
machine.number_of_cores, self._expectedValues[machine.host_name]
|
|
432
|
-
)
|
|
433
|
-
|
|
434
|
-
def test_cmd_string(self):
|
|
435
|
-
hostLists = ["M0:2,M1:2,M1:2", "M0,M0,M1,M1:3"]
|
|
436
|
-
|
|
437
|
-
for hostList in hostLists:
|
|
438
|
-
machineList = _parse_host_info(hostList)
|
|
439
|
-
for machine in machineList.machines:
|
|
440
|
-
self.assertEqual(
|
|
441
|
-
machine.number_of_cores, self._expectedValues[machine.host_name]
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
def test_no_machine_name(self):
|
|
445
|
-
hostList = "M0:2,M1:2,"
|
|
446
|
-
with self.assertRaises(RuntimeError) as cm:
|
|
447
|
-
_parse_host_info(hostList)
|
|
448
|
-
self.assertEqual(str(cm.exception), "Problem with machine list format.")
|
|
449
|
-
|
|
450
|
-
def test_host_file(self):
|
|
451
|
-
import os.path
|
|
452
|
-
|
|
453
|
-
hostfile = "hosts.txt"
|
|
454
|
-
# This unit test only runs if the file exists
|
|
455
|
-
if os.path.isfile(hostfile):
|
|
456
|
-
machineList = _parse_host_info(hostfile)
|
|
457
|
-
for machine in machineList.machines:
|
|
458
|
-
self.assertEqual(
|
|
459
|
-
machine.number_of_cores, self._expectedValues[machine.host_name]
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
suite1 = unittest.TestLoader().loadTestsFromTestCase(TestMachine)
|
|
464
|
-
suite2 = unittest.TestLoader().loadTestsFromTestCase(TestMachineList)
|
|
465
|
-
suite3 = unittest.TestLoader().loadTestsFromTestCase(TestLoadMachines)
|
|
466
|
-
suite4 = unittest.TestLoader().loadTestsFromTestCase(TestMachineListCmdLine)
|
|
467
|
-
alltests = unittest.TestSuite([suite1, suite2, suite3, suite4])
|
|
468
|
-
unittest.TextTestRunner(verbosity=2).run(alltests)
|
|
469
|
-
|
|
470
|
-
if __name__ == "__main__":
|
|
471
|
-
unittest.main()
|