From e10572921b2a2ae27a0591e27b6afce5aebb088e Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:45:39 +0100 Subject: [PATCH 01/14] feat: using an envvar to activate testing debugging --- .ci/collect_mapdl_log_locals.sh | 6 +++++ .ci/display_logs_locals.sh | 10 ++++++++ .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++++++ tests/common.py | 12 ++++----- tests/conftest.py | 26 +++++++++++++++----- 5 files changed, 85 insertions(+), 12 deletions(-) create mode 100755 .ci/collect_mapdl_log_locals.sh create mode 100755 .ci/display_logs_locals.sh diff --git a/.ci/collect_mapdl_log_locals.sh b/.ci/collect_mapdl_log_locals.sh new file mode 100755 index 0000000000..44f1e82a90 --- /dev/null +++ b/.ci/collect_mapdl_log_locals.sh @@ -0,0 +1,6 @@ + +mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES" + +cp *.log ./"$LOG_NAMES"/ || echo "No log files could be found" + +ls -la ./"$LOG_NAMES" diff --git a/.ci/display_logs_locals.sh b/.ci/display_logs_locals.sh new file mode 100755 index 0000000000..ac3c8cd823 --- /dev/null +++ b/.ci/display_logs_locals.sh @@ -0,0 +1,10 @@ +# Displaying files +FILE_PAT=./"$LOG_NAMES"/pymapdl.apdl +FILE_DESCRIPTION="PyMAPDL APDL log" + +if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: $FILE_DESCRIPTION: $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to show $FILE_DESCRIPTION file" + +FILE_PAT=./"$LOG_NAMES"/pymapdl.log +FILE_DESCRIPTION="PyMAPDL log" + +if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: $FILE_DESCRIPTION: $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to show $FILE_DESCRIPTION file" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 888deef9e0..83380d46e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,7 @@ env: PYTEST_ARGUMENTS: '-vvv -rxXsa --color=yes --durations=10 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html' BUILD_CHEATSHEET: True + PYMAPDL_DEBUG_TESTING: True # Following env vars when changed will "reset" the mentioned cache, # by changing the cache file name. It is rendered as ...-v%RESET_XXX%-... @@ -713,6 +714,27 @@ jobs: --reset_only_failed --add_missing_images \ --cov-report=xml:${{ matrix.mapdl-version }}-local.xml + - name: "Collect logs on failure" + if: always() + env: + LOG_NAMES: logs-local-${{ matrix.mapdl-version }} + run: | + .ci/collect_mapdl_logs_local.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-local-${{ matrix.mapdl-version }}.tgz + path: ./logs-local-${{ matrix.mapdl-version }}.tgz + + - name: "Display files structure" + if: always() + env: + LOG_NAMES: logs-local-${{ matrix.mapdl-version }} + run: | + .ci/display_logs_locals.sh + - name: "Adding the directory as safe directory for later step" run: | git config --global --add safe.directory $GITHUB_WORKSPACE @@ -850,6 +872,27 @@ jobs: ${{ env.PYTEST_ARGUMENTS }} \ --cov-report=xml:${{ matrix.mapdl-version }}-minimal.xml + - name: "Collect logs on failure" + if: always() + env: + LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} + run: | + .ci/collect_mapdl_logs_local.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-minimal-${{ matrix.mapdl-version }}.tgz + path: ./logs-minimal-${{ matrix.mapdl-version }}.tgz + + - name: "Display files structure" + if: always() + env: + LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} + run: | + .ci/display_logs_locals.sh + - uses: codecov/codecov-action@v5 name: "Upload coverage to Codecov" with: diff --git a/tests/common.py b/tests/common.py index 0ff9a64632..561a8fa6e8 100644 --- a/tests/common.py +++ b/tests/common.py @@ -157,14 +157,14 @@ def testing_minimal(): return os.environ.get("TESTING_MINIMAL", "NO").upper().strip() in ["YES", "TRUE"] -def log_apdl() -> bool: - if os.environ.get("PYMAPDL_LOG_APDL"): - log_apdl = os.environ.get("PYMAPDL_LOG_APDL") +def debug_testing() -> bool: + if os.environ.get("PYMAPDL_DEBUG_TESTING"): + debug_testing = os.environ.get("PYMAPDL_DEBUG_TESTING") - if log_apdl.lower() in ["true", "false", "yes", "no"]: - return log_apdl.lower() in ["true", "yes"] + if debug_testing.lower() in ["true", "false", "yes", "no"]: + return debug_testing.lower() in ["true", "yes"] else: - return log_apdl + return debug_testing else: return False diff --git a/tests/conftest.py b/tests/conftest.py index 724929fa6d..456bb61799 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,6 +35,7 @@ from common import ( Element, Node, + debug_testing, get_details_of_elements, get_details_of_nodes, has_dpf, @@ -44,7 +45,6 @@ is_on_ubuntu, is_running_on_student, is_smp, - log_apdl, log_test_start, make_sure_not_instances_are_left_open, restart_mapdl, @@ -58,6 +58,7 @@ # --------------------------- # +DEBUG_TESTING = debug_testing() TESTING_MINIMAL = testing_minimal() ON_LOCAL = is_on_local() @@ -74,7 +75,6 @@ HAS_DPF = has_dpf() SUPPORT_PLOTTING = support_plotting() IS_SMP = is_smp() -LOG_APDL = log_apdl() QUICK_LAUNCH_SWITCHES = "-smp -m 100 -db 100" VALID_PORTS = [] @@ -183,6 +183,13 @@ def requires_dependency(dependency: str): return pytest.mark.skip(reason=f"Requires '{dependency}' package") +if DEBUG_TESTING: + from ansys.mapdl.core import LOG + + LOG.setLevel("DEBUG") + LOG.log_to_file("pymapdl.log") + + ################################################################ # # Importing packages @@ -265,7 +272,7 @@ def pytest_report_header(config, start_path, startdir): text = [] text += ["Testing variables".center(get_terminal_size()[0], "-")] text += [ - f"Session dependent: ON_CI ({ON_CI}), TESTING_MINIMAL ({TESTING_MINIMAL}), SUPPORT_PLOTTING ({SUPPORT_PLOTTING})" + f"Session dependent: DEBUG_TESTING ({DEBUG_TESTING}), ON_CI ({ON_CI}), TESTING_MINIMAL ({TESTING_MINIMAL}), SUPPORT_PLOTTING ({SUPPORT_PLOTTING})" ] text += [ f"OS dependent: ON_LINUX ({ON_LINUX}), ON_UBUNTU ({ON_UBUNTU}), ON_WINDOWS ({ON_WINDOWS}), ON_MACOS ({ON_MACOS})" @@ -429,7 +436,7 @@ def run_before_and_after_tests( mapdl = restart_mapdl(mapdl) # Write test info to log_apdl - if LOG_APDL: + if DEBUG_TESTING: log_test_start(mapdl) # check if the local/remote state has changed or not @@ -551,7 +558,9 @@ def mapdl_console(request): "Valid versions are up to 2020R2." ) - mapdl = launch_mapdl(console_path, log_apdl=LOG_APDL) + mapdl = launch_mapdl( + console_path, log_apdl="pymapdl.apdl" if DEBUG_TESTING else None + ) from ansys.mapdl.core.mapdl_console import MapdlConsole assert isinstance(mapdl, MapdlConsole) @@ -582,8 +591,10 @@ def mapdl(request, tmpdir_factory): cleanup_on_exit=cleanup, license_server_check=False, start_timeout=50, - log_apdl=LOG_APDL, + log_apdl="pymapdl.apdl" if DEBUG_TESTING else None, + loglevel="DEBUG" if DEBUG_TESTING else "ERROR", ) + mapdl._show_matplotlib_figures = False # CI: don't show matplotlib figures MAPDL_VERSION = mapdl.version # Caching version @@ -595,6 +606,9 @@ def mapdl(request, tmpdir_factory): if mapdl.is_local: assert Path(mapdl.directory) == Path(run_path) + if DEBUG_TESTING: + mapdl._ctrl("set_verb", 5) # Setting verbosity on the server + # using yield rather than return here to be able to test exit yield mapdl From 4d4d5dfe9ea4ce0b2a29dda2a359ebd9e07f3ea7 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:48:31 +0000 Subject: [PATCH 02/14] chore: adding changelog file 3594.maintenance.md [dependabot-skip] --- doc/changelog.d/3594.maintenance.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/3594.maintenance.md diff --git a/doc/changelog.d/3594.maintenance.md b/doc/changelog.d/3594.maintenance.md new file mode 100644 index 0000000000..5b108f1e54 --- /dev/null +++ b/doc/changelog.d/3594.maintenance.md @@ -0,0 +1 @@ +feat: debug testing \ No newline at end of file From 20729768a541e50639cd990456e9c6b597f3ab0b Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:58:20 +0000 Subject: [PATCH 03/14] fix: test logging name too long --- tests/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/common.py b/tests/common.py index 561a8fa6e8..a42b29a27e 100644 --- a/tests/common.py +++ b/tests/common.py @@ -228,7 +228,7 @@ def log_test_start(mapdl: Mapdl) -> None: ) mapdl.run("!") - mapdl.run(f"! PyMAPDL running test: {test_name}") + mapdl.run(f"! PyMAPDL running test: {test_name}"[:639]) mapdl.run("!") # To see it also in MAPDL terminal output @@ -241,6 +241,7 @@ def log_test_start(mapdl: Mapdl) -> None: types_ = ["File path", "Test function"] mapdl._run("/com,Running test in:", mute=True) + for type_, name_ in zip(types_, test_name): mapdl._run(f"/com, {type_}: {name_}", mute=True) From c69cd3e92a5ce3cc74e5131e8c77de5cd164bcff Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:21:00 +0000 Subject: [PATCH 04/14] fix: detecting comments as parameters sets when they have =. --- src/ansys/mapdl/core/mapdl_core.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index ad21da82f5..b04700bb0a 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -2216,6 +2216,8 @@ def run( command = command.strip() + is_comment = command.startswith("!") or command.upper().startswith("/COM") + # always reset the cache self._reset_cache() @@ -2261,7 +2263,7 @@ def run( # simply return the contents of the file return self.list(*command.split(",")[1:]) - if "=" in command: + if "=" in command and not is_comment: # We are storing a parameter. param_name = command.split("=")[0].strip() @@ -2873,11 +2875,6 @@ def _raise_output_errors(self, response): [each for each in error_message.splitlines() if each] ) - # Trimming empty lines - error_message = "\n".join( - [each for each in error_message.splitlines() if each] - ) - # Checking for permitted error. for each_error in _PERMITTED_ERRORS: permited_error_message = re.search(each_error, error_message) From 805b853a0788982400f277640ec748fb9148ee3b Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Tue, 10 Dec 2024 20:09:16 +0100 Subject: [PATCH 05/14] fix: apply suggestions from code review --- tests/conftest.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 456bb61799..3785a88b94 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -189,7 +189,6 @@ def requires_dependency(dependency: str): LOG.setLevel("DEBUG") LOG.log_to_file("pymapdl.log") - ################################################################ # # Importing packages @@ -606,9 +605,6 @@ def mapdl(request, tmpdir_factory): if mapdl.is_local: assert Path(mapdl.directory) == Path(run_path) - if DEBUG_TESTING: - mapdl._ctrl("set_verb", 5) # Setting verbosity on the server - # using yield rather than return here to be able to test exit yield mapdl From 15faad68cabd940c47378f9c1bb1551ee809ef85 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:33:26 +0100 Subject: [PATCH 06/14] fix: script path name --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83380d46e4..257b5a63ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -719,7 +719,7 @@ jobs: env: LOG_NAMES: logs-local-${{ matrix.mapdl-version }} run: | - .ci/collect_mapdl_logs_local.sh + .ci/collect_mapdl_log_locals.sh - name: "Upload logs to GitHub" if: always() @@ -877,7 +877,7 @@ jobs: env: LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} run: | - .ci/collect_mapdl_logs_local.sh + .ci/collect_mapdl_log_locals.sh - name: "Upload logs to GitHub" if: always() From 25127f9a4b88edfd8a35abe408aef7c2dda752eb Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:03:14 +0100 Subject: [PATCH 07/14] fix: test --- tests/test_logging.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 3c416706be..837b7155a3 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -287,8 +287,11 @@ def test_log_to_file(tmpdir): LOG.logger.setLevel("ERROR") LOG.std_out_handler.setLevel("ERROR") - if not LOG.file_handler: + if LOG.file_handler is None: LOG.log_to_file(file_path) + else: + # the logger has been already instantiated + file_path = LOG.file_handler.baseFilename LOG.error(file_msg_error) LOG.debug(file_msg_debug) From 6e61abcb18fc9a155f8a0bd16f01d697859da09a Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:17:49 +0100 Subject: [PATCH 08/14] ci: using an external file for minimal requirements --- .ci/requirements_minimal.txt | 5 +++++ .github/workflows/ci.yml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .ci/requirements_minimal.txt diff --git a/.ci/requirements_minimal.txt b/.ci/requirements_minimal.txt new file mode 100644 index 0000000000..8a0a5ab19e --- /dev/null +++ b/.ci/requirements_minimal.txt @@ -0,0 +1,5 @@ +pyfakefs==5.7.2 +pytest-cov==6.0.0 +pytest-random-order==1.1.1 +pytest-rerunfailures==15.0 +pytest==8.3.4 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85a573d49d..97ead94b41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -843,7 +843,7 @@ jobs: - name: "Unit testing requirements installation" run: | - python -m pip install pytest pytest-rerunfailures pytest-cov pytest-random-order pyfakefs + python -m pip install -r .ci/requirements_minimal.txt - name: "Unit testing" env: @@ -972,7 +972,7 @@ jobs: - name: "Unit testing requirements installation" run: | - python -m pip install pytest pytest-rerunfailures pytest-cov pytest-random-order + python -m pip install -r .ci/requirements_minimal.txt - name: "Unit testing" env: From 9f4d4c4a4febda20ed226a63abd01e970af19ead Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:20:05 +0100 Subject: [PATCH 09/14] fix: tests --- tests/test_logging.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 837b7155a3..0b97a7c5c6 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -288,10 +288,12 @@ def test_log_to_file(tmpdir): LOG.std_out_handler.setLevel("ERROR") if LOG.file_handler is None: + old_logger = None LOG.log_to_file(file_path) else: # the logger has been already instantiated - file_path = LOG.file_handler.baseFilename + old_logger = LOG.file_handler.baseFilename + LOG.log_to_file(file_path) LOG.error(file_msg_error) LOG.debug(file_msg_debug) @@ -316,6 +318,9 @@ def test_log_to_file(tmpdir): assert file_msg_debug in text + if old_logger is not None: + LOG.log_to_file(old_logger) + def test_log_instance_name(mapdl, cleared): # verify we can access via an instance name From fc4b5492437c3bd732a2a830ce227fa86c367d05 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:13:19 +0100 Subject: [PATCH 10/14] refactor: moving dependency to requirement file --- .ci/requirements_minimal.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/requirements_minimal.txt b/.ci/requirements_minimal.txt index 8a0a5ab19e..8d55e3ac3c 100644 --- a/.ci/requirements_minimal.txt +++ b/.ci/requirements_minimal.txt @@ -2,4 +2,5 @@ pyfakefs==5.7.2 pytest-cov==6.0.0 pytest-random-order==1.1.1 pytest-rerunfailures==15.0 +pytest-timeout==2.3.1 pytest==8.3.4 \ No newline at end of file From 30b5514aefad160e2c6b17ec4bde29e2972b37f8 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:03:50 +0100 Subject: [PATCH 11/14] ci: fix files names. --- .ci/collect_mapdl_log_locals.sh | 6 ------ .ci/collect_mapdl_logs_locals.sh | 12 ++++++++++++ ...t_mapdl_logs.sh => collect_mapdl_logs_remote.sh} | 0 .ci/display_logs_locals.sh | 13 +++++++++++-- .ci/{display_logs.sh => display_logs_remote.sh} | 0 .github/workflows/ci.yml | 12 ++++++------ tests/conftest.py | 9 ++++++++- 7 files changed, 37 insertions(+), 15 deletions(-) delete mode 100755 .ci/collect_mapdl_log_locals.sh create mode 100755 .ci/collect_mapdl_logs_locals.sh rename .ci/{collect_mapdl_logs.sh => collect_mapdl_logs_remote.sh} (100%) rename .ci/{display_logs.sh => display_logs_remote.sh} (100%) diff --git a/.ci/collect_mapdl_log_locals.sh b/.ci/collect_mapdl_log_locals.sh deleted file mode 100755 index 44f1e82a90..0000000000 --- a/.ci/collect_mapdl_log_locals.sh +++ /dev/null @@ -1,6 +0,0 @@ - -mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES" - -cp *.log ./"$LOG_NAMES"/ || echo "No log files could be found" - -ls -la ./"$LOG_NAMES" diff --git a/.ci/collect_mapdl_logs_locals.sh b/.ci/collect_mapdl_logs_locals.sh new file mode 100755 index 0000000000..b6f6bf7116 --- /dev/null +++ b/.ci/collect_mapdl_logs_locals.sh @@ -0,0 +1,12 @@ + +mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES" + +cp *.log ./"$LOG_NAMES"/ || echo "No log files could be found" +cp apdl.out ./"$LOG_NAMES"/ || echo "No APDL log files could be found" +cp pymapdl.apdl ./"$LOG_NAMES"/ || echo "No PYMAPDL APDL log files could be found" + + +ls -la ./"$LOG_NAMES" + +echo "Tar files..." +tar cvzf ./"$LOG_NAMES".tgz ./"$LOG_NAMES" || echo "Failed to compress" \ No newline at end of file diff --git a/.ci/collect_mapdl_logs.sh b/.ci/collect_mapdl_logs_remote.sh similarity index 100% rename from .ci/collect_mapdl_logs.sh rename to .ci/collect_mapdl_logs_remote.sh diff --git a/.ci/display_logs_locals.sh b/.ci/display_logs_locals.sh index ac3c8cd823..c4db9eb59c 100755 --- a/.ci/display_logs_locals.sh +++ b/.ci/display_logs_locals.sh @@ -1,10 +1,19 @@ + +##### # Displaying files +FILE_PAT=./"$LOG_NAMES"/pymapdl.log +FILE_DESCRIPTION="PyMAPDL log" + +if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: $FILE_DESCRIPTION: $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to show $FILE_DESCRIPTION file" + +##### FILE_PAT=./"$LOG_NAMES"/pymapdl.apdl FILE_DESCRIPTION="PyMAPDL APDL log" if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: $FILE_DESCRIPTION: $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to show $FILE_DESCRIPTION file" -FILE_PAT=./"$LOG_NAMES"/pymapdl.log -FILE_DESCRIPTION="PyMAPDL log" +##### +FILE_PAT=./"$LOG_NAMES"/apdl.out +FILE_DESCRIPTION="MAPDL Output" if compgen -G "$FILE_PAT" > /dev/null ;then for f in "$FILE_PAT"; do echo "::group:: $FILE_DESCRIPTION: $f" && cat "$f" && echo "::endgroup::" ; done; fi || echo "Failed to show $FILE_DESCRIPTION file" \ No newline at end of file diff --git a/.ci/display_logs.sh b/.ci/display_logs_remote.sh similarity index 100% rename from .ci/display_logs.sh rename to .ci/display_logs_remote.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8810dfab96..5d8771d41d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -337,7 +337,7 @@ jobs: MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-build-docs run: | - .ci/collect_mapdl_logs.sh + .ci/collect_mapdl_logs_remote.sh - name: "Upload logs to GitHub" if: always() @@ -352,7 +352,7 @@ jobs: MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-build-docs run: | - .ci/display_logs.sh + .ci/display_logs_remote.sh build-test-remote-matrix: name: "Build remote test matrix" @@ -577,7 +577,7 @@ jobs: MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-remote-${{ matrix.mapdl-version }} run: | - .ci/collect_mapdl_logs.sh + .ci/collect_mapdl_logs_remote.sh - name: "Upload logs to GitHub" if: always() @@ -592,7 +592,7 @@ jobs: MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-remote-${{ matrix.mapdl-version }} run: | - .ci/display_logs.sh + .ci/display_logs_remote.sh build-test-local-minimal-matrix: name: "Build test matrix for minimal and local" @@ -719,7 +719,7 @@ jobs: env: LOG_NAMES: logs-local-${{ matrix.mapdl-version }} run: | - .ci/collect_mapdl_log_locals.sh + .ci/collect_mapdl_logs_locals.sh - name: "Upload logs to GitHub" if: always() @@ -877,7 +877,7 @@ jobs: env: LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} run: | - .ci/collect_mapdl_log_locals.sh + .ci/collect_mapdl_logs_locals.sh - name: "Upload logs to GitHub" if: always() diff --git a/tests/conftest.py b/tests/conftest.py index e7e9aed76d..023bbddd10 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -187,8 +187,13 @@ def requires_dependency(dependency: str): from ansys.mapdl.core import LOG LOG.setLevel("DEBUG") + + # If the following file name is changed, update `ci.yml`. LOG.log_to_file("pymapdl.log") + # the following files are also generated by MAPDL gRPC: + # - "pymapdl.apdl": The APDL commands sent to MAPDL by PyMAPDL + # - "apdl.out" : MAPDL console output. Very likely only contains the output until connected. ################################################################ # # Importing packages @@ -585,8 +590,10 @@ def mapdl(request, tmpdir_factory): cleanup_on_exit=cleanup, license_server_check=False, start_timeout=50, - log_apdl="pymapdl.apdl" if DEBUG_TESTING else None, loglevel="DEBUG" if DEBUG_TESTING else "ERROR", + # If the following file names are changed, update `ci.yml`. + log_apdl="pymapdl.apdl" if DEBUG_TESTING else None, + mapdl_output="apdl.out" if (DEBUG_TESTING and ON_LOCAL) else None, ) mapdl._show_matplotlib_figures = False # CI: don't show matplotlib figures From 3d94ec4e4302131d70cabcdc7162de0df9d623c3 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:37:37 +0100 Subject: [PATCH 12/14] fix: test --- tests/test_grpc.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_grpc.py b/tests/test_grpc.py index fd2454a4d0..d5cc35e4ca 100644 --- a/tests/test_grpc.py +++ b/tests/test_grpc.py @@ -577,13 +577,19 @@ def test_input_compatibility_api_change(mapdl, cleared): @requires("grpc") @requires("local") -def test__check_stds(mapdl, cleared): +@requires("nostudent") +def test__check_stds(): """Test that the standard input is checked.""" + from ansys.mapdl.core import launch_mapdl + + mapdl = launch_mapdl(port=50058) mapdl._read_stds() assert mapdl._stdout is not None assert mapdl._stderr is not None + mapdl.exit(force=True) + def test_subscribe_to_channel(mapdl, cleared): assert mapdl.channel_state in [ From c513f14cff5171246dc27c606135ad644582af65 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:28:24 +0100 Subject: [PATCH 13/14] ci: adding logs to console --- .ci/collect_mapdl_logs_locals.sh | 4 ++-- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.ci/collect_mapdl_logs_locals.sh b/.ci/collect_mapdl_logs_locals.sh index b6f6bf7116..5b4eff1c4a 100755 --- a/.ci/collect_mapdl_logs_locals.sh +++ b/.ci/collect_mapdl_logs_locals.sh @@ -2,8 +2,8 @@ mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES" cp *.log ./"$LOG_NAMES"/ || echo "No log files could be found" -cp apdl.out ./"$LOG_NAMES"/ || echo "No APDL log files could be found" -cp pymapdl.apdl ./"$LOG_NAMES"/ || echo "No PYMAPDL APDL log files could be found" +cp *apdl.out ./"$LOG_NAMES"/ || echo "No APDL log files could be found" +cp *pymapdl.apdl ./"$LOG_NAMES"/ || echo "No PYMAPDL APDL log files could be found" ls -la ./"$LOG_NAMES" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d8771d41d..7392bd416c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1001,6 +1001,27 @@ jobs: ${{ env.PYTEST_ARGUMENTS }} \ --cov-report=xml:${{ matrix.mapdl-version }}-minimal-console.xml + - name: "Collect logs on failure" + if: always() + env: + LOG_NAMES: logs-minimal-console-${{ matrix.mapdl-version }} + run: | + .ci/collect_mapdl_logs_locals.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-minimal-console-${{ matrix.mapdl-version }}.tgz + path: ./logs-minimal-console-${{ matrix.mapdl-version }}.tgz + + - name: "Display files structure" + if: always() + env: + LOG_NAMES: logs-minimal-console-${{ matrix.mapdl-version }} + run: | + .ci/display_logs_locals.sh + - uses: codecov/codecov-action@v5 name: "Upload coverage to Codecov" with: From 104b9889600c816248f1ae2f7ff77d22e35eb3d4 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:18:39 +0000 Subject: [PATCH 14/14] chore: adding changelog file 3594.maintenance.md [dependabot-skip] --- doc/changelog.d/3594.maintenance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/3594.maintenance.md b/doc/changelog.d/3594.maintenance.md index 5b108f1e54..3784e19adf 100644 --- a/doc/changelog.d/3594.maintenance.md +++ b/doc/changelog.d/3594.maintenance.md @@ -1 +1 @@ -feat: debug testing \ No newline at end of file +feat: activate debug mode on testing using `PYMAPDL_DEBUG_TESTING` envvar \ No newline at end of file