Skip to content

refactor: make cli testing not depending on MAPDL.#3678

Merged
germa89 merged 5 commits into
mainfrom
refactor/patch-cli-tests
Jan 24, 2025
Merged

refactor: make cli testing not depending on MAPDL.#3678
germa89 merged 5 commits into
mainfrom
refactor/patch-cli-tests

Conversation

@germa89
Copy link
Copy Markdown
Collaborator

@germa89 germa89 commented Jan 20, 2025

Description

As the title.

Issue linked

[Side-quest] To speed up testing.

From 44s to:

=================================================== 30 passed in 4.41s ===================================================

On docker MacOS:

from:

============================================================= PyMAPDL Pytest short summary ==============================================================
======================================================= 6 passed, 1 xfailed in 117.03s (0:01:57) 

to:

============================================================= PyMAPDL Pytest short summary ==============================================================
================================================================== 30 passed in 47.03s ==================================================================

Checklist

@germa89 germa89 requested a review from a team as a code owner January 20, 2025 12:43
@ansys-reviewer-bot
Copy link
Copy Markdown
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@github-actions github-actions Bot added the enhancement Improve any current implemented feature label Jan 20, 2025
@germa89
Copy link
Copy Markdown
Collaborator Author

germa89 commented Jan 20, 2025

For some reason, testing in the docker container on MacOS takes a lot to setup and a lot to tear it down:

================================================================= slowest 10 durations ==================================================================
30.46s teardown tests/test_cli.py::test_launch_mapdl_cli_config[license_server_check]
13.31s setup    tests/test_cli.py::test_pymapdl_stop_instances[mapping2]
1.81s call     tests/test_cli.py::test_convert_pipe
0.04s call     tests/test_cli.py::test_convert
0.03s call     tests/test_cli.py::test_pymapdl_stop_instances[mapping2]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--instances-check5]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[-l-check3]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--location-check8]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--cmd-check6]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--long-check7]

Extended:

Details

(.venv) root@989c9d68bf57:~/pymapdl# pytest tests/test_cli.py 
================================================================== test session starts ==================================================================
platform linux -- Python 3.10.12, pytest-8.3.3, pluggy-1.5.0 -- /home/mapdl/.venv/bin/python3.10
--------------------------------------------------------------------Testing variables--------------------------------------------------------------------
Session dependent: DEBUG_TESTING (False), ON_CI (True), TESTING_MINIMAL (False), SUPPORT_PLOTTING (True)
OS dependent: ON_LINUX (True), ON_UBUNTU (True), ON_WINDOWS (False), ON_MACOS (False)
MAPDL dependent: ON_LOCAL (True), ON_STUDENT (False), HAS_GRPC (True), HAS_DPF (False), IS_SMP (True)
------------------------------------------------------------------Environment variables------------------------------------------------------------------

-------------------------------------------------------------------Pytest configuration------------------------------------------------------------------
cachedir: .pytest_cache
Using --random-order-bucket=class
Using --random-order-seed=303455

rootdir: /home/mapdl/pymapdl
configfile: .pytest.ini
plugins: pyfakefs-5.7.1, memprof-0.2.0, rerunfailures-15.0, cov-6.0.0, random-order-1.1.1, anyio-4.8.0, pytest_pyvista-0.1.9, sphinx-0.6.3, profiling-1.8.1
collected 30 items                                                                                                                                      

tests/test_cli.py::test_pymapdl_stop_instances[mapping2] PASSED                                                                                   [  3%]
tests/test_cli.py::test_launch_mapdl_cli_config[mode] PASSED                                                                                      [  6%]
tests/test_cli.py::test_launch_mapdl_cli_config[print_com] PASSED                                                                                 [ 10%]
tests/test_cli.py::test_launch_mapdl_cli[True] PASSED                                                                                             [ 13%]
tests/test_cli.py::test_launch_mapdl_cli_list[--instances-check5] PASSED                                                                          [ 16%]
tests/test_cli.py::test_launch_mapdl_cli_list[-i-check1] PASSED                                                                                   [ 20%]
tests/test_cli.py::test_launch_mapdl_cli_config[ip] PASSED                                                                                        [ 23%]
tests/test_cli.py::test_launch_mapdl_cli_list[-cwd-check4] PASSED                                                                                 [ 26%]
tests/test_cli.py::test_launch_mapdl_cli_list[-c-check2] PASSED                                                                                   [ 30%]
tests/test_cli.py::test_pymapdl_stop_instances[mapping1] PASSED                                                                                   [ 33%]
tests/test_cli.py::test_launch_mapdl_cli_list[--long-check7] PASSED                                                                               [ 36%]
tests/test_cli.py::test_launch_mapdl_cli_config[cleanup_on_exit] PASSED                                                                           [ 40%]
tests/test_cli.py::test_launch_mapdl_cli[None] PASSED                                                                                             [ 43%]
tests/test_cli.py::test_launch_mapdl_cli[False] PASSED                                                                                            [ 46%]
tests/test_cli.py::test_pymapdl_stop_instances[mapping3] PASSED                                                                                   [ 50%]
tests/test_cli.py::test_launch_mapdl_cli_config[log_apdl] PASSED                                                                                  [ 53%]
tests/test_cli.py::test_launch_mapdl_cli_list[--location-check8] PASSED                                                                           [ 56%]
tests/test_cli.py::test_launch_mapdl_cli_list[--cmd-check6] PASSED                                                                                [ 60%]
tests/test_cli.py::test_launch_mapdl_cli_list[-check0] PASSED                                                                                     [ 63%]
tests/test_cli.py::test_launch_mapdl_cli_config[replace_env_vars] PASSED                                                                          [ 66%]
tests/test_cli.py::test_launch_mapdl_cli_config[add_env_vars] PASSED                                                                              [ 70%]
tests/test_cli.py::test_launch_mapdl_cli_config[loglevel] PASSED                                                                                  [ 73%]
tests/test_cli.py::test_convert_pipe PASSED                                                                                                       [ 76%]
tests/test_cli.py::test_pymapdl_stop_instances[mapping0] PASSED                                                                                   [ 80%]
tests/test_cli.py::test_launch_mapdl_cli_config[clear_on_connect] PASSED                                                                          [ 83%]
tests/test_cli.py::test_launch_mapdl_cli_list[-l-check3] PASSED                                                                                   [ 86%]
tests/test_cli.py::test_launch_mapdl_cli_config[remove_temp_dir_on_exit] PASSED                                                                   [ 90%]
tests/test_cli.py::test_convert PASSED                                                                                                            [ 93%]
tests/test_cli.py::test_launch_mapdl_cli_config[start_instance] PASSED                                                                            [ 96%]
tests/test_cli.py::test_launch_mapdl_cli_config[license_server_check] PASSED                                                                      [100%]
============================================================= memory consumption estimates ==============================================================
pymapdl::tests::test_cli.py::test_convert_pipe                                      - 157.1 MB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_list[--location-check8]          - 4.3 MB
pymapdl::tests::test_cli.py::test_pymapdl_stop_instances[mapping2]                  - 1.4 MB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_list[-check0]                    - 808.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_list[-l-check3]                  - 512.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_list[--cmd-check6]               - 356.0 KB
pymapdl::tests::test_cli.py::test_convert                                           - 252.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_config[log_apdl]                 - 240.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_config[mode]                     - 180.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_config[start_instance]           - 148.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_config[remove_temp_dir_on_exit]  - 108.0 KB
pymapdl::tests::test_cli.py::test_launch_mapdl_cli_list[-i-check1]                  - 80.0 KB
pymapdl::tests::test_cli.py::test_pymapdl_stop_instances[mapping1]                  - 32.0 KB
Profiling (from /home/mapdl/pymapdl/prof/combined.prof):
Mon Jan 20 12:56:33 2025    /home/mapdl/pymapdl/prof/combined.prof

         27454516 function calls (27440965 primitive calls) in 46.102 seconds

   Ordered by: cumulative time
   List reduced from 1990 to 20 due to restriction <20>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       30    0.000    0.000   46.100    1.537 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:110(pytest_runtest_protocol)
       30    0.000    0.000   46.092    1.536 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:118(runtestprotocol)
       90    0.001    0.000   46.092    0.512 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:226(call_and_report)
  691/330    0.002    0.000   46.092    0.140 /home/mapdl/.venv/lib/python3.10/site-packages/pluggy/_hooks.py:498(__call__)
  691/330    0.001    0.000   46.090    0.140 /home/mapdl/.venv/lib/python3.10/site-packages/pluggy/_manager.py:111(_hookexec)
  691/330    0.008    0.000   46.090    0.140 /home/mapdl/.venv/lib/python3.10/site-packages/pluggy/_callers.py:53(_multicall)
       90    0.001    0.000   46.073    0.512 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:319(from_call)
       90    0.000    0.000   46.072    0.512 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:242(<lambda>)
5146/4560    0.002    0.000   43.972    0.010 {built-in method builtins.next}
        2    0.000    0.000   43.767   21.884 /home/mapdl/pymapdl/tests/conftest.py:582(mapdl)
     1105   30.963    0.028   30.963    0.028 {built-in method time.sleep}
  115/114    0.009    0.000   30.612    0.269 /home/mapdl/pymapdl/src/ansys/mapdl/core/errors.py:299(wrapper)
       30    0.000    0.000   30.606    1.020 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:187(pytest_runtest_teardown)
       30    0.001    0.000   30.604    1.020 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/runner.py:529(teardown_exact)
  137/104    0.001    0.000   30.603    0.294 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/fixtures.py:1016(finish)
       35    0.000    0.000   30.599    0.874 /home/mapdl/.venv/lib/python3.10/site-packages/_pytest/fixtures.py:902(_teardown_yield_fixture)
        4    0.000    0.000   15.006    3.752 /home/mapdl/pymapdl/src/ansys/mapdl/core/mapdl_extended.py:2733(get_value)
        1    0.000    0.000   15.004   15.004 /home/mapdl/pymapdl/src/ansys/mapdl/core/mapdl_grpc.py:1072(_send_command_stream)
        1    0.000    0.000   15.004   15.004 /home/mapdl/pymapdl/src/ansys/mapdl/core/mapdl_grpc.py:2019(_get_time_step_stream)
        1    0.000    0.000   15.004   15.004 /home/mapdl/pymapdl/src/ansys/mapdl/core/mapdl_core.py:856(platform)


SVG profile created in /home/mapdl/pymapdl/prof/combined.svg.

================================================================= slowest 10 durations ==================================================================
30.46s teardown tests/test_cli.py::test_launch_mapdl_cli_config[license_server_check]
13.31s setup    tests/test_cli.py::test_pymapdl_stop_instances[mapping2]
1.81s call     tests/test_cli.py::test_convert_pipe
0.04s call     tests/test_cli.py::test_convert
0.03s call     tests/test_cli.py::test_pymapdl_stop_instances[mapping2]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--instances-check5]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[-l-check3]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--location-check8]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--cmd-check6]
0.02s call     tests/test_cli.py::test_launch_mapdl_cli_list[--long-check7]
============================================================= PyMAPDL Pytest short summary ==============================================================
================================================================== 30 passed in 47.03s ==================================================================

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.86%. Comparing base (e6221a6) to head (12bbb7b).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3678      +/-   ##
==========================================
+ Coverage   87.14%   87.86%   +0.72%     
==========================================
  Files         187      187              
  Lines       14697    14699       +2     
==========================================
+ Hits        12808    12916     +108     
+ Misses       1889     1783     -106     

@germa89 germa89 self-assigned this Jan 20, 2025
@germa89
Copy link
Copy Markdown
Collaborator Author

germa89 commented Jan 21, 2025

@pyansys-ci-bot LGTM.

Copy link
Copy Markdown
Contributor

@pyansys-ci-bot pyansys-ci-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approving this PR because germa89 said so in here 😬

LGTM

@germa89 germa89 merged commit a2f91e6 into main Jan 24, 2025
@germa89 germa89 deleted the refactor/patch-cli-tests branch January 24, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improve any current implemented feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants