diff --git a/tests/conftest.py b/tests/conftest.py index 9df4e3ac09..37e6e23cbf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,6 +50,7 @@ SUPPORT_PLOTTING = pyvista.system_supports_plotting() IS_SMP = is_smp() +QUICK_LAUNCH_SWITCHES = "-smp -m 100 -db 100" # check if the user wants to permit pytest to start MAPDL START_INSTANCE = get_start_instance() @@ -347,7 +348,6 @@ def mapdl(request, tmpdir_factory): run_location=run_path, cleanup_on_exit=cleanup, license_server_check=False, - # additional_switches="-smp", start_timeout=50, ) mapdl._show_matplotlib_figures = False # CI: don't show matplotlib figures diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 416efe2fe5..59d8fd369c 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -22,7 +22,12 @@ version_from_path, ) from ansys.mapdl.core.licensing import LICENSES -from conftest import skip_if_not_local, skip_on_linux, skip_on_windows +from conftest import ( + QUICK_LAUNCH_SWITCHES, + skip_if_not_local, + skip_on_linux, + skip_on_windows, +) try: import ansys_corba # noqa: F401 @@ -154,7 +159,11 @@ def test_launch_corba(version): def test_license_type_keyword(): checks = [] for license_name, license_description in LICENSES.items(): - mapdl = launch_mapdl(license_type=license_name, start_timeout=start_timeout) + mapdl = launch_mapdl( + license_type=license_name, + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) # Using first line to ensure not picking up other stuff. checks.append(license_description in mapdl.__str__().split("\n")[0]) @@ -170,7 +179,11 @@ def test_license_type_keyword_names(): successful_check = False for license_name, license_description in LICENSES.items(): - mapdl = launch_mapdl(license_type=license_name, start_timeout=start_timeout) + mapdl = launch_mapdl( + license_type=license_name, + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) # Using first line to ensure not picking up other stuff. successful_check = ( @@ -188,7 +201,8 @@ def test_license_type_additional_switch(): successful_check = False for license_name, license_description in LICENSES.items(): mapdl = launch_mapdl( - additional_switches=" -p " + license_name, start_timeout=start_timeout + additional_switches=QUICK_LAUNCH_SWITCHES + " -p " + license_name, + start_timeout=start_timeout, ) # Using first line to ensure not picking up other stuff. @@ -205,14 +219,19 @@ def test_license_type_dummy(): dummy_license_type = "dummy" with pytest.raises(LicenseServerConnectionError): launch_mapdl( - additional_switches=f" -p {dummy_license_type}", start_timeout=start_timeout + additional_switches=f" -p {dummy_license_type}" + QUICK_LAUNCH_SWITCHES, + start_timeout=start_timeout, ) @skip_if_not_local def test_remove_temp_files(): """Ensure the working directory is removed when run_location is not set.""" - mapdl = launch_mapdl(remove_temp_files=True, start_timeout=start_timeout) + mapdl = launch_mapdl( + remove_temp_files=True, + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) # possible MAPDL is installed but running in "remote" mode path = mapdl.directory @@ -229,7 +248,11 @@ def test_remove_temp_files(): @skip_if_not_local def test_remove_temp_files_fail(tmpdir): """Ensure the working directory is not removed when the cwd is changed.""" - mapdl = launch_mapdl(remove_temp_files=True, start_timeout=start_timeout) + mapdl = launch_mapdl( + remove_temp_files=True, + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) old_path = mapdl.directory assert os.path.isdir(str(tmpdir)) mapdl.cwd(str(tmpdir)) @@ -382,14 +405,23 @@ def test_find_ansys(mapdl): @skip_if_not_local def test_version(mapdl): version = int(10 * mapdl.version) - mapdl_ = launch_mapdl(version=version, start_timeout=start_timeout) + mapdl_ = launch_mapdl( + version=version, + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) mapdl_.exit() @skip_if_not_local def test_raise_exec_path_and_version_launcher(): with pytest.raises(ValueError): - launch_mapdl(exec_file="asdf", version="asdf", start_timeout=start_timeout) + launch_mapdl( + exec_file="asdf", + version="asdf", + start_timeout=start_timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) @skip_on_windows @@ -405,12 +437,16 @@ def test_get_default_ansys(): def test_launch_mapdl_non_recognaised_arguments(): with pytest.raises(ValueError, match="my_fake_argument"): - launch_mapdl(my_fake_argument="my_fake_value") + launch_mapdl( + my_fake_argument="my_fake_value", additional_switches=QUICK_LAUNCH_SWITCHES + ) def test_mapdl_non_recognaised_arguments(): with pytest.raises(ValueError, match="my_fake_argument"): - pymapdl.Mapdl(my_fake_argument="my_fake_value") + pymapdl.Mapdl( + my_fake_argument="my_fake_value", additional_switches=QUICK_LAUNCH_SWITCHES + ) def test__parse_ip_route(): diff --git a/tests/test_launcher_remote.py b/tests/test_launcher_remote.py index ba11898a55..cdf4a23f87 100644 --- a/tests/test_launcher_remote.py +++ b/tests/test_launcher_remote.py @@ -6,6 +6,7 @@ from ansys.mapdl.core.launcher import launch_mapdl from ansys.mapdl.core.mapdl_grpc import MAX_MESSAGE_LENGTH +from conftest import QUICK_LAUNCH_SWITCHES def test_launch_remote_instance(monkeypatch, mapdl): @@ -42,7 +43,9 @@ def test_launch_remote_instance(monkeypatch, mapdl): # Start MAPDL with launch_mapdl # Note: This is mocking to start MAPDL, but actually reusing the common one # Thus cleanup_on_exit is set to false - mapdl = launch_mapdl(cleanup_on_exit=False) + mapdl = launch_mapdl( + cleanup_on_exit=False, additional_switches=QUICK_LAUNCH_SWITCHES + ) # Assert: pymapdl went through the pypim workflow assert mock_is_configured.called diff --git a/tests/test_licensing.py b/tests/test_licensing.py index 5016f51d12..b9950f82ed 100644 --- a/tests/test_licensing.py +++ b/tests/test_licensing.py @@ -9,7 +9,7 @@ from ansys.mapdl.core import errors, launch_mapdl, licensing from ansys.mapdl.core.misc import threaded from conftest import ON_LOCAL as IS_LOCAL -from conftest import skip_if_not_local +from conftest import QUICK_LAUNCH_SWITCHES, skip_if_not_local try: LIC_INSTALLED = os.path.isfile(licensing.get_ansys_license_utility_path()) @@ -167,7 +167,11 @@ def test_check_license_file(tmpdir): checker.start(checkout_license=False) try: - mapdl = launch_mapdl(license_server_check=False, start_timeout=timeout) + mapdl = launch_mapdl( + license_server_check=False, + start_timeout=timeout, + additional_switches=QUICK_LAUNCH_SWITCHES, + ) assert mapdl._local mapdl.exit() except IOError: # MAPDL never started diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 8cf381e019..8645ee4dbd 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -29,6 +29,7 @@ from conftest import ( IS_SMP, ON_LOCAL, + QUICK_LAUNCH_SWITCHES, skip_if_not_local, skip_if_on_cicd, skip_no_xserver, @@ -465,7 +466,9 @@ def test_lplot(cleared, mapdl, tmpdir, vtk): def test_apdl_logging_start(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join("tmp.inp")) - mapdl = launch_mapdl(start_timeout=30, log_apdl=filename) + mapdl = launch_mapdl( + start_timeout=30, log_apdl=filename, additional_switches=QUICK_LAUNCH_SWITCHES + ) mapdl.prep7() mapdl.run("!comment test") @@ -491,8 +494,7 @@ def test_apdl_logging_start(tmpdir): def test_corba_apdl_logging_start(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join("tmp.inp")) - mapdl = pymapdl.launch_mapdl(mode="CORBA") - mapdl = launch_mapdl(log_apdl=filename) + mapdl = pymapdl.launch_mapdl(mode="CORBA", log_apdl=filename) mapdl.prep7() mapdl.run("!comment test") @@ -1944,7 +1946,9 @@ def test_cuadratic_beam(mapdl, cuadratic_beam_problem): @skip_if_not_local def test_save_on_exit(mapdl, cleared): - mapdl2 = launch_mapdl(license_server_check=False) + mapdl2 = launch_mapdl( + license_server_check=False, additional_switches=QUICK_LAUNCH_SWITCHES + ) mapdl2.parameters["my_par"] = "asdf" db_name = mapdl2.jobname + ".db" db_dir = mapdl2.directory @@ -1956,7 +1960,9 @@ def test_save_on_exit(mapdl, cleared): mapdl2.parameters["my_par"] = "qwerty" mapdl2.exit() - mapdl2 = launch_mapdl(license_server_check=False) + mapdl2 = launch_mapdl( + license_server_check=False, additional_switches=QUICK_LAUNCH_SWITCHES + ) mapdl2.resume(db_path) assert mapdl2.parameters["my_par"] == "qwerty" @@ -1966,7 +1972,9 @@ def test_save_on_exit(mapdl, cleared): db_path = os.path.join(db_dir, db_name) mapdl2.exit(save=True) - mapdl2 = launch_mapdl(license_server_check=False) + mapdl2 = launch_mapdl( + license_server_check=False, additional_switches=QUICK_LAUNCH_SWITCHES + ) mapdl2.resume(db_path) assert mapdl2.parameters["my_par"] == "zxcv" mapdl2.exit() diff --git a/tests/test_pool.py b/tests/test_pool.py index 89f57e648e..ae8cd83250 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -8,7 +8,7 @@ from ansys.mapdl.core import LocalMapdlPool, examples from ansys.mapdl.core.errors import VersionError -from conftest import skip_if_not_local +from conftest import QUICK_LAUNCH_SWITCHES, skip_if_not_local # skip entire module unless HAS_GRPC pytestmark = pytest.mark.skip_grpc @@ -26,7 +26,6 @@ ) TWAIT = 90 -LAUNCH_SWITCHES = "-smp -m 100 -db 100" NPROC = 1 @@ -42,7 +41,7 @@ def pool(tmpdir_factory): port=50056, start_timeout=30, exec_file=EXEC_FILE, - additional_switches=LAUNCH_SWITCHES, + additional_switches=QUICK_LAUNCH_SWITCHES, nproc=NPROC, ) yield mapdl_pool @@ -74,7 +73,7 @@ def test_invalid_exec(): 4, nproc=NPROC, exec_file="/usr/ansys_inc/v194/ansys/bin/mapdl", - additional_switches=LAUNCH_SWITCHES, + additional_switches=QUICK_LAUNCH_SWITCHES, ) @@ -227,7 +226,7 @@ def test_directory_names_custom_string(tmpdir): nproc=NPROC, names="my_instance", port=50056, - additional_switches=LAUNCH_SWITCHES, + additional_switches=QUICK_LAUNCH_SWITCHES, ) dirs_path_pool = os.listdir(pool._root_dir) @@ -253,7 +252,7 @@ def myfun(i): nproc=NPROC, names=myfun, run_location=tmpdir, - additional_switches=LAUNCH_SWITCHES, + additional_switches=QUICK_LAUNCH_SWITCHES, ) dirs_path_pool = os.listdir(pool._root_dir)