From 0af3a19dbd1458491a199bf31c6c182859d957a8 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 8 Aug 2025 19:11:10 +0200 Subject: [PATCH 01/19] refactor: Update MAPDL Docker setup and documentation. Moved MAPDL docker files to `MAPDL` directory. --- doc/source/getting_started/make_container.rst | 2 +- docker/{ => MAPDL}/.dockerignore | 0 docker/{ => MAPDL}/Dockerfile | 0 docker/{ => MAPDL}/docker-compose.yml | 0 docker/{ => MAPDL}/make_container.rst | 8 ++++---- 5 files changed, 5 insertions(+), 5 deletions(-) rename docker/{ => MAPDL}/.dockerignore (100%) rename docker/{ => MAPDL}/Dockerfile (100%) rename docker/{ => MAPDL}/docker-compose.yml (100%) rename docker/{ => MAPDL}/make_container.rst (95%) diff --git a/doc/source/getting_started/make_container.rst b/doc/source/getting_started/make_container.rst index aec6e40f537..8f8b671d648 100644 --- a/doc/source/getting_started/make_container.rst +++ b/doc/source/getting_started/make_container.rst @@ -1,3 +1,3 @@ .. _ref_make_container: -.. include:: ../../../docker/make_container.rst +.. include:: ../../../docker/MAPDL/make_container.rst diff --git a/docker/.dockerignore b/docker/MAPDL/.dockerignore similarity index 100% rename from docker/.dockerignore rename to docker/MAPDL/.dockerignore diff --git a/docker/Dockerfile b/docker/MAPDL/Dockerfile similarity index 100% rename from docker/Dockerfile rename to docker/MAPDL/Dockerfile diff --git a/docker/docker-compose.yml b/docker/MAPDL/docker-compose.yml similarity index 100% rename from docker/docker-compose.yml rename to docker/MAPDL/docker-compose.yml diff --git a/docker/make_container.rst b/docker/MAPDL/make_container.rst similarity index 95% rename from docker/make_container.rst rename to docker/MAPDL/make_container.rst index a146f3f25b6..3751f4475a8 100644 --- a/docker/make_container.rst +++ b/docker/MAPDL/make_container.rst @@ -24,8 +24,8 @@ Requirements * The following provided files: - * `Dockerfile `_ - * `.dockerignore `_ + * `Dockerfile `_ + * `.dockerignore `_ Procedure @@ -100,10 +100,10 @@ Please notice that: * ``path_to_mapdl_installation`` is the path to where you have locally installed ANSYS MAPDL. Not all the installation files are copied, in fact, the files ignored during the copying -are detailed in the file `.dockerignore `_. +are detailed in the file `.dockerignore `_. The Docker container configuration needed to build the container is detailed in the -`Dockerfile `_. +`Dockerfile `_. Summary From 505625c079c0e5e5e58bbc0d4762708d351c3d18 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 11 Aug 2025 13:45:16 +0200 Subject: [PATCH 02/19] feat: Add Docker setup for PyMAPDL testing environment with Dockerfile, docker-compose, and start script --- docker/PyMAPDL-Testing/Dockerfile | 68 +++++++++++++++++++++++ docker/PyMAPDL-Testing/docker-compose.yml | 18 ++++++ docker/PyMAPDL-Testing/start.sh | 1 + 3 files changed, 87 insertions(+) create mode 100644 docker/PyMAPDL-Testing/Dockerfile create mode 100644 docker/PyMAPDL-Testing/docker-compose.yml create mode 100644 docker/PyMAPDL-Testing/start.sh diff --git a/docker/PyMAPDL-Testing/Dockerfile b/docker/PyMAPDL-Testing/Dockerfile new file mode 100644 index 00000000000..4ab2d5ea9fd --- /dev/null +++ b/docker/PyMAPDL-Testing/Dockerfile @@ -0,0 +1,68 @@ +# PyMAPDL docker image that runs the tests. + +ARG PYTHON_VERSION=3.11 +ARG PLATFORM=linux/amd64 + +FROM ubuntu:22.04 + +ARG PYTHON_VERSION=3.11 + +# Install system dependencies +RUN apt-get update && \ + apt-get install -y \ + libgl1-mesa-glx \ + xvfb \ + libgomp1 \ + graphviz \ + git + +RUN apt-get update && apt install -y \ + python${PYTHON_VERSION}-venv \ + python3-pip \ + openssh-client \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Set workdir +WORKDIR /workspace + +# Clone PyMAPDL repository +RUN git clone https://github.com/ansys/pymapdl.git . + +RUN \ + python${PYTHON_VERSION} -m pip install --upgrade pip && \ + python${PYTHON_VERSION} -m pip install build && \ + python${PYTHON_VERSION} -m build && \ + python${PYTHON_VERSION} -m pip install dist/*.whl && \ + xvfb-run python${PYTHON_VERSION} -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + +# Upgrade pip and install test dependencies + +RUN \ + pip install .[tests] + +# Configuration +ENV ON_CI=True +ENV ON_LOCAL=False +ENV ON_UBUNTU=False +ENV ON_STUDENT=False + +ENV PYANSYS_OFF_SCREEN=True +ENV PYMAPDL_DEBUG_TESTING=True +ENV PYMAPDL_START_INSTANCE=FALSE + +# Pytest settings +ENV PYTEST_ARGUMENTS='-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers' + +# DPF testing +ENV DPF_START_SERVER=False +ENV HAS_DPF=True +ENV TEST_DPF_BACKEND=false +ENV ON_SAME_CONTAINER=False + +EXPOSE 50052 + +COPY start.sh / +RUN chmod +x /start.sh + +CMD [ "./start.sh" ] diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml new file mode 100644 index 00000000000..c9ff923aaa6 --- /dev/null +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -0,0 +1,18 @@ +services: + mapdl: + shm_size: '8gb' + container_name: mapdl + mem_reservation: 8g + environment: + - ANSYSLMD_LICENSE_FILE=1055@${ANSYSLMD_LICENSE_FILE} + - ANSYS_LOCK=OFF + image: ${DOCKER_IMAGE} + platform: linux/amd64 + entrypoint: "/bin/bash ansys -grpc" + + test: + container_name: pymapdl-test + platform: linux/amd64 + build: + context: . + dockerfile: Dockerfile \ No newline at end of file diff --git a/docker/PyMAPDL-Testing/start.sh b/docker/PyMAPDL-Testing/start.sh new file mode 100644 index 00000000000..ee600ae6a0c --- /dev/null +++ b/docker/PyMAPDL-Testing/start.sh @@ -0,0 +1 @@ +#! /bin/sh \ No newline at end of file From a028637c7f7cb2785c1121eed450ca85dc94c8ec Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:56:43 +0200 Subject: [PATCH 03/19] feat: Enhance Docker setup and testing scripts for PyMAPDL with improved configurations and profiles --- docker/PyMAPDL-Testing/Dockerfile | 192 ++++++++++++++--- docker/PyMAPDL-Testing/docker-compose.yml | 244 +++++++++++++++++++++- docker/PyMAPDL-Testing/start.sh | 26 ++- 3 files changed, 430 insertions(+), 32 deletions(-) diff --git a/docker/PyMAPDL-Testing/Dockerfile b/docker/PyMAPDL-Testing/Dockerfile index 4ab2d5ea9fd..5005c693c01 100644 --- a/docker/PyMAPDL-Testing/Dockerfile +++ b/docker/PyMAPDL-Testing/Dockerfile @@ -1,12 +1,19 @@ # PyMAPDL docker image that runs the tests. -ARG PYTHON_VERSION=3.11 -ARG PLATFORM=linux/amd64 +ARG DOCKER_IMAGE -FROM ubuntu:22.04 +####################################################### +FROM ubuntu:22.04 AS python-main +####################################################### +ARG USE_LOCAL_REPO=yes ARG PYTHON_VERSION=3.11 +ENV USE_LOCAL_REPO=${USE_LOCAL_REPO} + +# Set workdir +WORKDIR /workspace + # Install system dependencies RUN apt-get update && \ apt-get install -y \ @@ -14,55 +21,192 @@ RUN apt-get update && \ xvfb \ libgomp1 \ graphviz \ - git + git \ + openssh-client + +# Clone to install the libraries needed +RUN git clone https://github.com/ansys/pymapdl.git . RUN apt-get update && apt install -y \ python${PYTHON_VERSION}-venv \ python3-pip \ - openssh-client \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# Set workdir -WORKDIR /workspace - -# Clone PyMAPDL repository -RUN git clone https://github.com/ansys/pymapdl.git . - -RUN \ - python${PYTHON_VERSION} -m pip install --upgrade pip && \ - python${PYTHON_VERSION} -m pip install build && \ - python${PYTHON_VERSION} -m build && \ - python${PYTHON_VERSION} -m pip install dist/*.whl && \ - xvfb-run python${PYTHON_VERSION} -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - # Upgrade pip and install test dependencies - RUN \ + python${PYTHON_VERSION} -m pip install --upgrade pip && \ pip install .[tests] # Configuration +# ------------- +# Variable for running as if it were on CICD while testing ENV ON_CI=True +# Tu simulate running on local machine ENV ON_LOCAL=False +# For tests that check if running on ubuntu. ENV ON_UBUNTU=False +# Some tests check if running on student machines ENV ON_STUDENT=False +# PyMAPDL testing env vars +# ------------------------ +# To work without a screen. ENV PYANSYS_OFF_SCREEN=True +# Enable debugging for PyMAPDL ENV PYMAPDL_DEBUG_TESTING=True -ENV PYMAPDL_START_INSTANCE=FALSE +# To connect to an already alive or remote MAPDL instance +ENV PYMAPDL_START_INSTANCE=False +# Set MAPDL port to connect to +ENV PYMAPDL_PORT=50052 + +# DPF testing +# ----------- +# Not testing against DPF +# +# To connect to a remote DPF server +ENV DPF_START_SERVER=False +# Simulate not having DPF +ENV HAS_DPF=False +# Not testing DPF-Results backend +ENV TEST_DPF_BACKEND=False +# MAPDL and DPF are running on the same container +ENV ON_SAME_CONTAINER=False # Pytest settings +# --------------- ENV PYTEST_ARGUMENTS='-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers' +# Setting entrypoint +# ------------------ +COPY start.sh / +RUN chmod +x /start.sh + +EXPOSE 50052 + +CMD [ "/bin/bash", "/start.sh" ] + +####################################################### +FROM python-main AS test-clone-pymapdl +####################################################### + +ENV USE_LOCAL_REPO=True + +####################################################### +FROM python-main AS test-local-pymapdl +####################################################### + +ENV USE_LOCAL_REPO=False + +# Remove cloned repo so the local repo can be mounted. +RUN rm -rf * + +####################################################### +FROM ubuntu:22.04 AS mapdl-local +####################################################### + +ARG USERNAME=mapdl +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +ENV DEBIAN_FRONTEND=noninteractive +ENV USERNAME=$USERNAME + +# OS configuration +# ---------------- +# Installing dependencies +RUN apt-get update && \ + apt-get install -y \ + libgomp1 \ + libgl1 \ + libglu1 \ + libxm4 \ + libxi6 \ + openssh-client \ + && apt install -y software-properties-common \ + && add-apt-repository -y ppa:zeehio/libxp \ + && apt-get update \ + && apt-get install -y libxp6 \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +####################################################### +FROM ${DOCKER_IMAGE} AS mapdl-local-container-pymapdl +####################################################### +# +# WARNING: This container is designed to work using an Ubuntu base image. +# +ARG PYTHON_VERSION=3.11 + +# OS configuration +# ---------------- +# Installing dependencies +RUN apt-get update && \ + apt-get install -y \ + libgl1-mesa-glx \ + xvfb \ + libgomp1 \ + graphviz \ + git \ + openssh-client + +# Clone to install the libraries needed +RUN git clone https://github.com/ansys/pymapdl.git . + +RUN python3 --version || (apt-get update && apt install -y \ + python${PYTHON_VERSION}-venv \ + python3-pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*) + +# Upgrade pip and install test dependencies +RUN \ + python3 -m pip install --upgrade pip && \ + pip install .[tests] + +# Configuration +# ------------- +# Variable for running as if it were on CICD while testing +ENV ON_CI=True +# Tu simulate running on local machine +ENV ON_LOCAL=True +# For tests that check if running on ubuntu. +ENV ON_UBUNTU=False +# Some tests check if running on student machines +ENV ON_STUDENT=False + +# PyMAPDL testing env vars +# ------------------------ +# To work without a screen. +ENV PYANSYS_OFF_SCREEN=True +# Enable debugging for PyMAPDL +ENV PYMAPDL_DEBUG_TESTING=True +# To connect to an already alive or remote MAPDL instance +ENV PYMAPDL_START_INSTANCE=False +# Set MAPDL port to connect to +ENV PYMAPDL_PORT=50052 + # DPF testing +# ----------- +# Not testing against DPF +# +# To connect to a remote DPF server ENV DPF_START_SERVER=False -ENV HAS_DPF=True -ENV TEST_DPF_BACKEND=false +# Simulate not having DPF +ENV HAS_DPF=False +# Not testing DPF-Results backend +ENV TEST_DPF_BACKEND=False +# MAPDL and DPF are running on the same container ENV ON_SAME_CONTAINER=False -EXPOSE 50052 +# Pytest settings +# --------------- +ENV PYTEST_ARGUMENTS='-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers' +# Setting entrypoint +# ------------------ COPY start.sh / RUN chmod +x /start.sh -CMD [ "./start.sh" ] +EXPOSE 50052 + +CMD [ "/bin/bash", "/start.sh" ] diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml index c9ff923aaa6..cb1fa23a4ce 100644 --- a/docker/PyMAPDL-Testing/docker-compose.yml +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -1,18 +1,248 @@ +# PyMAPDL docker compose testing +# +# This docker compose file is used to test PyMAPDL against different MAPDL installations. +# It allows you to run tests against a local MAPDL installation, a cloned PyMAPDL +# repository, or a remote MAPDL installation. +# +# Required environment variables +# ------------------------------ +# +# - `ANSYSLMD_LICENSE_FILE` for the license server required in all MAPDL configurations +# - See each service definition for additional environment variables +# +# Available profiles +# ------------------ +# +# This docker compose works using profiles. The are many profiles, depending on the following +# configurations possible: +# +# - MAPDL acting as remote (`mapdl-remote`) or local (`mapdl-local`) +# - MAPDL from a container (`mapdl-xxx-container`) or from the host (`mapdl-xxx-host`) +# - PyMAPDL cloned from Github (`pymapdl-clone`) or from the host (`pymapdl-host`) +# +# Because of this configuration there are two main groups of profiles, based on MAPDL or PyMAPDL. +# +# - MAPDL profiles: +# - mapdl-remote-container +# - mapdl-remote-container +# - mapdl-remote-host +# - mapdl-remote-host +# - mapdl-local-container +# - mapdl-local-host +# - mapdl-local-container +# - mapdl-local-host +# +# - PyMAPDL profiles +# - pymapdl-clone +# - pymapdl-host +# +# You can specify each one with `--profile `. For instance: +# +# ``` +# docker compose --profile mapdl-remote-container --profile pymapdl-clone +# ``` +# +# which is equivalent to: +# +# ``` +# docker compose --profile mapdl-remote-container-pymapdl-clone +# ``` +# +# The full list of profiles already available for testing is: +# +# - [x] mapdl-remote-container-pymapdl-clone +# - [x] mapdl-remote-container-pymapdl-host +# - [x] mapdl-remote-host-pymapdl-clone +# - [x] mapdl-remote-host-pymapdl-host +# +# - [ ] mapdl-local-container-pymapdl-host +# - [ ] mapdl-local-host-pymapdl-host +# - [w] mapdl-local-container-pymapdl-clone +# - [w] mapdl-local-host-pymapdl-clone +# +# The list of profiles not implemented yet are: +# +# +# +# Example usage +# ------------- +# +# docker compose --profile local-repository --profile mapdl-container up +# + +name: PyMAPDL Testing + services: - mapdl: - shm_size: '8gb' + mapdl-remote-container: + # This service is used to run MAPDL in a remote container. + # + # Environment variables + # --------------------- + # - `ANSYSLMD_LICENSE_FILE` (mandatory) for the license server + # - `DOCKER_IMAGE` (mandatory) environment variable to specify the image to use. + # - `MAPDL_ENTRYPOINT` to specify the entrypoint for the container. + # - `MAPDL_EXEC_PATH` to specify the path to the MAPDL executable. + # - `MAPDL_EXTRA_ARGS` to specify any additional arguments for the MAPDL command. + # container_name: mapdl - mem_reservation: 8g + profiles: + - mapdl-remote-container + - mapdl-remote-container-pymapdl-clone + - mapdl-remote-container-pymapdl-host + - '' # Default profile + shm_size: '2gb' + restart: unless-stopped + hostname: mapdl + networks: + - pymapdl-net environment: - - ANSYSLMD_LICENSE_FILE=1055@${ANSYSLMD_LICENSE_FILE} + - ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE} - ANSYS_LOCK=OFF image: ${DOCKER_IMAGE} platform: linux/amd64 - entrypoint: "/bin/bash ansys -grpc" + # You might want to customize it + entrypoint: ${MAPDL_ENTRYPOINT:-"/bin/bash"} + command: ["${MAPDL_EXEC_PATH:-ansys}", "-grpc", "${MAPDL_EXTRA_ARGS:-}"] + + mapdl-remote-host: + # This service is used to run the local MAPDL instalation by mounting the volume + # inside the container. + # This is using an ubuntu container with the required dependencies to mount the directory + # where MAPDL is installed, and then run MAPDL. + # + # Environment variables + # --------------------- + # + # - `ANSYSLMD_LICENSE_FILE` (mandatory) for the license server. + # - `ANSYS_INC` (mandatory) the installation directory `ansys_inc` of MAPDL. + # - `MAPDL_EXEC_PATH` (mandatory) the path to the MAPDL executable. The default is `ansys`. + # - `MAPDL_ENTRYPOINT` (optional) the entrypoint to the MAPDL container. The default is `"/bin/bash"`. + # - `MAPDL_EXTRA_ARGS` (optional) any additional arguments for the MAPDL command. + # + container_name: mapdl + profiles: + - mapdl-remote-host + - mapdl-remote-host-pymapdl-clone + - mapdl-remote-host-pymapdl-host + shm_size: '2gb' + restart: unless-stopped + hostname: mapdl + networks: + - pymapdl-net + environment: + - ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE} + - ANSYS_LOCK=OFF + platform: linux/amd64 + build: + context: . + dockerfile: Dockerfile + target: mapdl-local + entrypoint: ${MAPDL_ENTRYPOINT:-"/bin/bash"} + command: ["${MAPDL_EXEC_PATH:-ansys}", "-grpc", "${MAPDL_EXTRA_ARGS:-}"] + volumes: + - ${ANSYS_INC-/ansys_inc}:/ansys_inc:ro + + pymapdl-host: + # This service mount the local PyMAPDL repository and test it. + profiles: + - pymapdl-host + - mapdl-remote-container-pymapdl-host + - mapdl-remote-host-pymapdl-host + - mapdl-local-container-pymapdl-host + - mapdl-local-host-pymapdl-host + - '' # Default profile + container_name: pymapdl-test + platform: linux/amd64 + depends_on: + - mapdl + networks: + - pymapdl-net + build: + context: . + dockerfile: Dockerfile + target: test-local-pymapdl + environment: + - PYMAPDL_IP=mapdl-remote # Use the MAPDL service name + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + volumes: + - ../../../:/workspace + + pymapdl-clone: + # This service clones the PyMAPDL repository and test against it. + profiles: + - cloned-repository + container_name: pymapdl-test + platform: linux/amd64 + depends_on: + - mapdl + networks: + - pymapdl-net + build: + context: . + dockerfile: Dockerfile + target: test-local-pymapdl + environment: + - PYMAPDL_IP=mapdl-remote # Use the MAPDL service name + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + + mapdl-local-container-pymapdl-clone: + # This service clones PyMAPDL inside the MAPDL container and run the tests. + # + # WARNING: It is very likely you will have to update your dockerfile according the specific + # ${DOCKER_IMAGE} you are using. + # + # Environment variables + # --------------------- + # + # - `ANSYSLMD_LICENSE_FILE` (mandatory) for the license server. + # + profiles: + - mapdl-local-container-pymapdl-clone + container_name: pymapdl-test + platform: linux/amd64 + networks: + - pymapdl-net + build: + context: . + dockerfile: Dockerfile + target: mapdl-local-container-pymapdl + args: + - DOCKER_IMAGE=${DOCKER_IMAGE} + environment: + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch - test: + mapdl-local-container-pymapdl-host: + # This service clones PyMAPDL inside the MAPDL container and run the tests. + # + # WARNING: It is very likely you will have to update your dockerfile according the specific + # ${DOCKER_IMAGE} you are using. + # + # Environment variables + # --------------------- + # + # - `ANSYSLMD_LICENSE_FILE` (mandatory) for the license server. + # + profiles: + - mapdl-local-container-pymapdl-host container_name: pymapdl-test platform: linux/amd64 + networks: + - pymapdl-net build: context: . - dockerfile: Dockerfile \ No newline at end of file + dockerfile: Dockerfile + target: mapdl-local-container-pymapdl + args: + - DOCKER_IMAGE=${DOCKER_IMAGE} + environment: + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + volumes: + - ../../../:/workspace + +networks: + pymapdl-net: + driver: bridge \ No newline at end of file diff --git a/docker/PyMAPDL-Testing/start.sh b/docker/PyMAPDL-Testing/start.sh index ee600ae6a0c..cf76c0bffa3 100644 --- a/docker/PyMAPDL-Testing/start.sh +++ b/docker/PyMAPDL-Testing/start.sh @@ -1 +1,25 @@ -#! /bin/sh \ No newline at end of file +#! /bin/bash + +echo "===============================================" +echo "Running tests in PyMAPDL Testing environment..." +echo "===============================================" +echo "" + +# Checkout to the specified branch if PYMAPDL_BRANCH is set +if [ -n "${PYMAPDL_BRANCH}" ]; then + echo "PYMAPDL_BRANCH is set to '${PYMAPDL_BRANCH}'. Checking out this branch..." + git fetch origin "${PYMAPDL_BRANCH}" + git checkout "${PYMAPDL_BRANCH}" +fi + +if [[ "${USE_LOCAL_REPO}" == "yes" ]]; then + echo "Using local PyMAPDL repository for testing." + python3 -m pip install '.[tests]' + +else + echo "Using cloned PyMAPDL repository for testing." +fi + +echo "Using pytest arguments: ${PYTEST_ARGUMENTS}" + +xvfb-run pytest "${PYTEST_ARGUMENTS}" \ No newline at end of file From e31b2eda92f3f636d2a4dd736882b86213df219f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:03:39 +0200 Subject: [PATCH 04/19] refactor: Update docker-compose.yml to correct service name and remove commented profiles --- docker/PyMAPDL-Testing/docker-compose.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml index cb1fa23a4ce..f410725d3a6 100644 --- a/docker/PyMAPDL-Testing/docker-compose.yml +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -24,13 +24,9 @@ # # - MAPDL profiles: # - mapdl-remote-container -# - mapdl-remote-container -# - mapdl-remote-host # - mapdl-remote-host # - mapdl-local-container # - mapdl-local-host -# - mapdl-local-container -# - mapdl-local-host # # - PyMAPDL profiles # - pymapdl-clone @@ -70,7 +66,7 @@ # docker compose --profile local-repository --profile mapdl-container up # -name: PyMAPDL Testing +name: PyMAPDL-Testing services: mapdl-remote-container: From dcac7650f85072f52844c04106efed14fa73ad2a Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:06:00 +0200 Subject: [PATCH 05/19] refactor: Update docker-compose.yml to standardize service name casing --- docker/PyMAPDL-Testing/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml index f410725d3a6..711acd87122 100644 --- a/docker/PyMAPDL-Testing/docker-compose.yml +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -66,7 +66,7 @@ # docker compose --profile local-repository --profile mapdl-container up # -name: PyMAPDL-Testing +name: pymapdl-testing services: mapdl-remote-container: From 882034550543a615e7165410a05036a56f732fb0 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:17:05 +0200 Subject: [PATCH 06/19] refactor: Update Dockerfile and docker-compose.yml to improve configuration and remove unnecessary dependencies --- docker/PyMAPDL-Testing/Dockerfile | 5 ++++- docker/PyMAPDL-Testing/docker-compose.yml | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docker/PyMAPDL-Testing/Dockerfile b/docker/PyMAPDL-Testing/Dockerfile index 5005c693c01..e7f0890dc4b 100644 --- a/docker/PyMAPDL-Testing/Dockerfile +++ b/docker/PyMAPDL-Testing/Dockerfile @@ -1,6 +1,9 @@ # PyMAPDL docker image that runs the tests. -ARG DOCKER_IMAGE +# Dummy default so there is no error if not set. +# It needs to be set here because we are using it +# later on the FROM. +ARG DOCKER_IMAGE=mapdl:latest ####################################################### FROM ubuntu:22.04 AS python-main diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml index 711acd87122..52581b95b98 100644 --- a/docker/PyMAPDL-Testing/docker-compose.yml +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -149,8 +149,6 @@ services: - '' # Default profile container_name: pymapdl-test platform: linux/amd64 - depends_on: - - mapdl networks: - pymapdl-net build: @@ -167,11 +165,13 @@ services: pymapdl-clone: # This service clones the PyMAPDL repository and test against it. profiles: - - cloned-repository + - pymapdl-clone + - mapdl-remote-container-pymapdl-clone + - mapdl-remote-host-pymapdl-clone + - mapdl-local-container-pymapdl-clone + - mapdl-local-host-pymapdl-clone container_name: pymapdl-test platform: linux/amd64 - depends_on: - - mapdl networks: - pymapdl-net build: From 4db251a03a55104393c56e5a2756e2892a0c8109 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:17:14 +0200 Subject: [PATCH 07/19] refactor: Update Dockerfile and docker-compose.yml for improved configurations and added mylocal.ip --- docker/PyMAPDL-Testing/Dockerfile | 12 +++++---- docker/PyMAPDL-Testing/docker-compose.yml | 31 +++++++++++++++-------- docker/PyMAPDL-Testing/mylocal.ip | 1 + docker/PyMAPDL-Testing/start.sh | 10 +++++--- 4 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 docker/PyMAPDL-Testing/mylocal.ip diff --git a/docker/PyMAPDL-Testing/Dockerfile b/docker/PyMAPDL-Testing/Dockerfile index e7f0890dc4b..6097e2d9bb1 100644 --- a/docker/PyMAPDL-Testing/Dockerfile +++ b/docker/PyMAPDL-Testing/Dockerfile @@ -78,7 +78,7 @@ ENV ON_SAME_CONTAINER=False # Pytest settings # --------------- -ENV PYTEST_ARGUMENTS='-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers' +ENV PYTEST_ARGUMENTS="-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers" # Setting entrypoint # ------------------ @@ -87,22 +87,24 @@ RUN chmod +x /start.sh EXPOSE 50052 +RUN git config --global --add safe.directory /workspace/pymapdl + CMD [ "/bin/bash", "/start.sh" ] ####################################################### FROM python-main AS test-clone-pymapdl ####################################################### -ENV USE_LOCAL_REPO=True +ENV USE_LOCAL_REPO=false ####################################################### FROM python-main AS test-local-pymapdl ####################################################### -ENV USE_LOCAL_REPO=False +ENV USE_LOCAL_REPO=true # Remove cloned repo so the local repo can be mounted. -RUN rm -rf * +RUN $(rm -rf *) >/dev/null 2>&1 ####################################################### FROM ubuntu:22.04 AS mapdl-local @@ -130,7 +132,7 @@ RUN apt-get update && \ && add-apt-repository -y ppa:zeehio/libxp \ && apt-get update \ && apt-get install -y libxp6 \ - apt-get clean && rm -rf /var/lib/apt/lists/* + && apt-get clean && rm -rf /var/lib/apt/lists/* ####################################################### FROM ${DOCKER_IMAGE} AS mapdl-local-container-pymapdl diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/PyMAPDL-Testing/docker-compose.yml index 52581b95b98..e0acab02932 100644 --- a/docker/PyMAPDL-Testing/docker-compose.yml +++ b/docker/PyMAPDL-Testing/docker-compose.yml @@ -98,7 +98,15 @@ services: platform: linux/amd64 # You might want to customize it entrypoint: ${MAPDL_ENTRYPOINT:-"/bin/bash"} - command: ["${MAPDL_EXEC_PATH:-ansys}", "-grpc", "${MAPDL_EXTRA_ARGS:-}"] + command: [ + "${MAPDL_EXEC_PATH:-ansys}", + "-grpc", + "${MAPDL_EXTRA_ARGS:-}" + ] + # Required for v261 onwards. + working_dir: /workspace + volumes: + - ./mylocal.ip:/workspace/mylocal.ip:ro mapdl-remote-host: # This service is used to run the local MAPDL instalation by mounting the volume @@ -146,7 +154,6 @@ services: - mapdl-remote-host-pymapdl-host - mapdl-local-container-pymapdl-host - mapdl-local-host-pymapdl-host - - '' # Default profile container_name: pymapdl-test platform: linux/amd64 networks: @@ -156,9 +163,10 @@ services: dockerfile: Dockerfile target: test-local-pymapdl environment: - - PYMAPDL_IP=mapdl-remote # Use the MAPDL service name + - PYMAPDL_IP=mapdl # Use the MAPDL service name # If empty, it will use the default 'main' branch - - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} + working_dir: /workspace/pymapdl volumes: - ../../../:/workspace @@ -170,19 +178,20 @@ services: - mapdl-remote-host-pymapdl-clone - mapdl-local-container-pymapdl-clone - mapdl-local-host-pymapdl-clone - container_name: pymapdl-test + - '' # Default profile + # container_name: pymapdl-test platform: linux/amd64 networks: - pymapdl-net build: context: . dockerfile: Dockerfile - target: test-local-pymapdl + target: test-clone-pymapdl environment: - - PYMAPDL_IP=mapdl-remote # Use the MAPDL service name + - PYMAPDL_IP=mapdl # Use the MAPDL service name # If empty, it will use the default 'main' branch - - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch - + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} + mapdl-local-container-pymapdl-clone: # This service clones PyMAPDL inside the MAPDL container and run the tests. # @@ -208,7 +217,7 @@ services: - DOCKER_IMAGE=${DOCKER_IMAGE} environment: # If empty, it will use the default 'main' branch - - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} mapdl-local-container-pymapdl-host: # This service clones PyMAPDL inside the MAPDL container and run the tests. @@ -235,7 +244,7 @@ services: - DOCKER_IMAGE=${DOCKER_IMAGE} environment: # If empty, it will use the default 'main' branch - - PYMAPDL_BRANCH=${PYMAPDL_BRANCH}# if empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} volumes: - ../../../:/workspace diff --git a/docker/PyMAPDL-Testing/mylocal.ip b/docker/PyMAPDL-Testing/mylocal.ip new file mode 100644 index 00000000000..d690dc0d591 --- /dev/null +++ b/docker/PyMAPDL-Testing/mylocal.ip @@ -0,0 +1 @@ +0.0.0.0 diff --git a/docker/PyMAPDL-Testing/start.sh b/docker/PyMAPDL-Testing/start.sh index cf76c0bffa3..e5369a929b5 100644 --- a/docker/PyMAPDL-Testing/start.sh +++ b/docker/PyMAPDL-Testing/start.sh @@ -8,13 +8,14 @@ echo "" # Checkout to the specified branch if PYMAPDL_BRANCH is set if [ -n "${PYMAPDL_BRANCH}" ]; then echo "PYMAPDL_BRANCH is set to '${PYMAPDL_BRANCH}'. Checking out this branch..." - git fetch origin "${PYMAPDL_BRANCH}" + git fetch origin "${PYMAPDL_BRANCH}" > /dev/null 2>&1 git checkout "${PYMAPDL_BRANCH}" fi -if [[ "${USE_LOCAL_REPO}" == "yes" ]]; then +if [[ "${USE_LOCAL_REPO}" == "true" ]]; then echo "Using local PyMAPDL repository for testing." - python3 -m pip install '.[tests]' + # Uncomment if you expect changes in the dependencies. + # python3 -m pip install '.[tests]' else echo "Using cloned PyMAPDL repository for testing." @@ -22,4 +23,5 @@ fi echo "Using pytest arguments: ${PYTEST_ARGUMENTS}" -xvfb-run pytest "${PYTEST_ARGUMENTS}" \ No newline at end of file +# shellcheck disable=SC2086 +xvfb-run pytest ${PYTEST_ARGUMENTS} \ No newline at end of file From f11d019fb89c4ca993d97bf387aa4b33a80b07a8 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:38:56 +0200 Subject: [PATCH 08/19] feat: Add Dockerfile, docker-compose.yml, mylocal.ip, and start.sh for PyMAPDL testing setup --- docker/{PyMAPDL-Testing => testing}/Dockerfile | 0 docker/{PyMAPDL-Testing => testing}/docker-compose.yml | 0 docker/{PyMAPDL-Testing => testing}/mylocal.ip | 0 docker/{PyMAPDL-Testing => testing}/start.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename docker/{PyMAPDL-Testing => testing}/Dockerfile (100%) rename docker/{PyMAPDL-Testing => testing}/docker-compose.yml (100%) rename docker/{PyMAPDL-Testing => testing}/mylocal.ip (100%) rename docker/{PyMAPDL-Testing => testing}/start.sh (100%) diff --git a/docker/PyMAPDL-Testing/Dockerfile b/docker/testing/Dockerfile similarity index 100% rename from docker/PyMAPDL-Testing/Dockerfile rename to docker/testing/Dockerfile diff --git a/docker/PyMAPDL-Testing/docker-compose.yml b/docker/testing/docker-compose.yml similarity index 100% rename from docker/PyMAPDL-Testing/docker-compose.yml rename to docker/testing/docker-compose.yml diff --git a/docker/PyMAPDL-Testing/mylocal.ip b/docker/testing/mylocal.ip similarity index 100% rename from docker/PyMAPDL-Testing/mylocal.ip rename to docker/testing/mylocal.ip diff --git a/docker/PyMAPDL-Testing/start.sh b/docker/testing/start.sh similarity index 100% rename from docker/PyMAPDL-Testing/start.sh rename to docker/testing/start.sh From 1f1829b61325d763cf14eb13868d7174e78a8332 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 19 Aug 2025 17:41:47 +0000 Subject: [PATCH 09/19] chore: adding changelog file 4186.miscellaneous.md [dependabot-skip] --- doc/changelog.d/4186.miscellaneous.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/4186.miscellaneous.md diff --git a/doc/changelog.d/4186.miscellaneous.md b/doc/changelog.d/4186.miscellaneous.md new file mode 100644 index 00000000000..de3914ac627 --- /dev/null +++ b/doc/changelog.d/4186.miscellaneous.md @@ -0,0 +1 @@ +Ci: adding docker compose files for testing From 77afe052a6f986c71bd6df42e9a5d1b103be72cd Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 09:54:19 +0200 Subject: [PATCH 10/19] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docker/testing/Dockerfile | 4 ++-- docker/testing/docker-compose.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/testing/Dockerfile b/docker/testing/Dockerfile index 6097e2d9bb1..44467219d36 100644 --- a/docker/testing/Dockerfile +++ b/docker/testing/Dockerfile @@ -104,7 +104,7 @@ FROM python-main AS test-local-pymapdl ENV USE_LOCAL_REPO=true # Remove cloned repo so the local repo can be mounted. -RUN $(rm -rf *) >/dev/null 2>&1 +RUN rm -rf /workspace/* >/dev/null 2>&1 ####################################################### FROM ubuntu:22.04 AS mapdl-local @@ -172,7 +172,7 @@ RUN \ # ------------- # Variable for running as if it were on CICD while testing ENV ON_CI=True -# Tu simulate running on local machine +# To simulate running on local machine ENV ON_LOCAL=True # For tests that check if running on ubuntu. ENV ON_UBUNTU=False diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index e0acab02932..5dbce18959b 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -85,7 +85,7 @@ services: - mapdl-remote-container - mapdl-remote-container-pymapdl-clone - mapdl-remote-container-pymapdl-host - - '' # Default profile +- default shm_size: '2gb' restart: unless-stopped hostname: mapdl @@ -144,7 +144,7 @@ services: entrypoint: ${MAPDL_ENTRYPOINT:-"/bin/bash"} command: ["${MAPDL_EXEC_PATH:-ansys}", "-grpc", "${MAPDL_EXTRA_ARGS:-}"] volumes: - - ${ANSYS_INC-/ansys_inc}:/ansys_inc:ro + - ${ANSYS_INC:-/ansys_inc}:/ansys_inc:ro pymapdl-host: # This service mount the local PyMAPDL repository and test it. @@ -178,7 +178,7 @@ services: - mapdl-remote-host-pymapdl-clone - mapdl-local-container-pymapdl-clone - mapdl-local-host-pymapdl-clone - - '' # Default profile + - default # Default profile # container_name: pymapdl-test platform: linux/amd64 networks: From d1ceacf6d9ca01bad4c266c0ebd074ee213e0a12 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:24:50 +0200 Subject: [PATCH 11/19] fix: Correct spelling of MAPDL in documentation and comments --- doc/source/getting_started/docker.rst | 2 +- doc/source/getting_started/launcher.rst | 6 +++--- doc/source/getting_started/macos.rst | 4 ++-- doc/source/user_guide/troubleshoot.rst | 2 +- src/ansys/mapdl/core/database/database.py | 2 +- src/ansys/mapdl/core/mapdl_extended.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/source/getting_started/docker.rst b/doc/source/getting_started/docker.rst index 33180093286..94ff390124e 100644 --- a/doc/source/getting_started/docker.rst +++ b/doc/source/getting_started/docker.rst @@ -261,7 +261,7 @@ you can use the following command to launch MAPDL: Connect to the MAPDL container from Python ========================================== -You can connect to an MAPDL instance as indicated in :ref:`connect_grpc_madpl_session`. +You can connect to an MAPDL instance as indicated in :ref:`connect_grpc_mapdl_session`. You do not need to specify an IP address because Docker maps the ports to the local host. diff --git a/doc/source/getting_started/launcher.rst b/doc/source/getting_started/launcher.rst index 46d56985d05..c7f6a1c4831 100644 --- a/doc/source/getting_started/launcher.rst +++ b/doc/source/getting_started/launcher.rst @@ -48,7 +48,7 @@ Connect PyMAPDL to a local MAPDL instance Connect to a local MAPDL instance requires two steps: launching a local MAPDL session and connect to it. -.. _launch_grpc_madpl_session: +.. _launch_grpc_mapdl_session: Launch a local gRPC MAPDL session ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -115,7 +115,7 @@ From version v0.68, you can use a command line interface to launch, stop, and li local MAPDL instances. For more information, see :ref:`ref_cli`. -.. _connect_grpc_madpl_session: +.. _connect_grpc_mapdl_session: Connect to the local MAPDL instance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -143,7 +143,7 @@ Just make sure that you specify the mapped port instead of the internal MAPDL po For more information, see :ref:`pymapdl_docker`. -.. _connect_grpc_remote_madpl_session: +.. _connect_grpc_remote_mapdl_session: Connect PyMAPDL to a remote MAPDL instance ------------------------------------------ diff --git a/doc/source/getting_started/macos.rst b/doc/source/getting_started/macos.rst index 23504c80e3f..cc82e986b22 100644 --- a/doc/source/getting_started/macos.rst +++ b/doc/source/getting_started/macos.rst @@ -21,7 +21,7 @@ MAPDL is not compatible with a MacOS. There are two options: * **Connect to a remote instance**: You can connect to a remote instance running - on a Windows or Linux machine as indicated in :ref:`connect_grpc_madpl_session`. + on a Windows or Linux machine as indicated in :ref:`connect_grpc_mapdl_session`. * **Launch MAPDL locally using Docker**: You can run MAPDL on a MacOS machine as indicated in :ref:`launch_mapdl_on_macos`. @@ -64,6 +64,6 @@ as shown in this code example: Connect to an MAPDL container ============================= -You can connect to an MAPDL instance as indicated in :ref:`connect_grpc_madpl_session`. +You can connect to an MAPDL instance as indicated in :ref:`connect_grpc_mapdl_session`. diff --git a/doc/source/user_guide/troubleshoot.rst b/doc/source/user_guide/troubleshoot.rst index bf3f7e19cbe..ce47e91f38b 100644 --- a/doc/source/user_guide/troubleshoot.rst +++ b/doc/source/user_guide/troubleshoot.rst @@ -803,7 +803,7 @@ Recommendations When connecting to an instance of MAPDL using gRPC (default), there are some cases where the MAPDL server might exit unexpectedly. There -are several ways to improve MADPL performance and stability: +are several ways to improve MAPDL performance and stability: Use ``mute`` to improve stability ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/ansys/mapdl/core/database/database.py b/src/ansys/mapdl/core/database/database.py index d35bf5c94d2..204b901c03f 100644 --- a/src/ansys/mapdl/core/database/database.py +++ b/src/ansys/mapdl/core/database/database.py @@ -321,7 +321,7 @@ def stop(self): def _status(self): """ - Return the status of the MADPL DB Server. + Return the status of the MAPDL DB Server. Examples -------- diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 2090ff4c2c9..c786fd096ae 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -3079,7 +3079,7 @@ def get_value( This method uses :func:`Mapdl.get`. - See the full MADPL command documentation at `*GET + See the full MAPDL command documentation at `*GET `_ .. note:: From 96dfea81e2fe743c1ddbf230fe570442b724a019 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:25:09 +0200 Subject: [PATCH 12/19] refactor: Clean up .gitignore by standardizing testing entries and removing duplicates --- .gitignore | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index d36f8c19b86..39de7b26a6f 100755 --- a/.gitignore +++ b/.gitignore @@ -42,21 +42,21 @@ doc/source/images/auto-generated/* # Testing +./Testing/ +.benchmarks/ +.coverage +.pytest_cache/ +.tox/ +*,cover +coverage.xml factory/ -Testing/ -UnitTesting/ -TODO +test-output.xml test.sh -.pytest_cache/ tests/.coverage -tests/htmlcov tests/cyclic/htmlcov -.coverage -*,cover -.benchmarks/ -test-output.xml -coverage.xml -.tox/ +tests/htmlcov +TODO +UnitTesting/ \#* .\#* From f81084a0244d4ace9be426b9cd4d0e9c2b83c071 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:07:17 +0200 Subject: [PATCH 13/19] docs: add testing env vars table. --- .../getting_started/develop_pymapdl.rst | 124 +++++++++++------- 1 file changed, 73 insertions(+), 51 deletions(-) diff --git a/doc/source/getting_started/develop_pymapdl.rst b/doc/source/getting_started/develop_pymapdl.rst index d0786ee22b7..b3d784aac2e 100644 --- a/doc/source/getting_started/develop_pymapdl.rst +++ b/doc/source/getting_started/develop_pymapdl.rst @@ -147,6 +147,9 @@ guidelines for developing code in a repository: continuous integration/continuous deployment (CI/CD) pipelines to catch issues early and ensure reliable deployments. For more information, see `Unit testing`_. + .. note:: No pull request is accepted if the amount of test coverage is not sufficient. + If you are adding new code, ensure that it is covered by existing or new unit tests. + #. **Respect code style and standards**: Follow code style guidelines and adhere to coding standards specific to your language or framework. @@ -228,38 +231,6 @@ along with integration tests. The difference between a unit test and an integration test is that the latter tests several units of the code to ensure that they all work together. -To run all the unit tests use the following command: - -.. code:: console - - (.venv) mapdl@machine:~/pymapdl$ pytest - -If you are running on a **Linux machine without display**, you must install ``xvfb`` OS -library and run the preceding command with the ``xvfb-run`` command as prefix. - -.. code:: console - - (.venv) mapdl@machine:~/pymapdl$ xvfb-run pytest - -In case you want to run only a certain subset of tests, you can use the ``-k`` argument -to filter the tests using booleans: - -.. code:: console - - (.venv) mapdl@machine:~/pymapdl$ pytest -k "test_nlist_to_array or test_string_with_literal" - ==================================================== test session starts ==================================================== - platform darwin -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0 - rootdir: /Users/german.ayuso/pymapdl - configfile: pyproject.toml - testpaths: tests - plugins: timeout-2.2.0, cov-4.1.0, sphinx-0.5.0, rerunfailures-13.0, anyio-4.1.0, pytest_pyvista-0.1.9 - collected 1468 items / 1466 deselected / 4 skipped / 2 selected - - tests/test_commands.py .. [100%] - - =============================================== PyMAPDL Pytest short summary ================================================ - ======================================= 2 passed, 4 skipped, 1466 deselected in 2.27s ======================================= - Creation of a unit test ----------------------- @@ -297,34 +268,85 @@ It is executed upstream of each test and not within all tests. Passing the ``cleared`` fixture is also useful since it clears up the MAPDL database and configuration before performing the test. -If you do not have MAPDL installed locally but still want to run the -unit testing, you must set up the following environment variables. -.. tab-set:: +Running PyMAPDL tests +--------------------- + +To run all the unit tests use the following command: + +.. code:: console + + (.venv) mapdl@machine:~/pymapdl$ pytest + +If you just want to run a specific test file, you can provide the path to the file: + +.. code:: console + + (.venv) mapdl@machine:~/pymapdl$ pytest tests/test_commands.py + +In case you want to run only a certain subset of tests, you can use the ``-k`` argument +to filter the tests using booleans: + +.. code:: console - .. tab-item:: Windows - :sync: key1 + (.venv) mapdl@machine:~/pymapdl$ pytest -k "test_nlist_to_array or test_string_with_literal" + ======================================= test session starts ==================================================== + platform darwin -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0 + rootdir: /Users/german.ayuso/pymapdl + configfile: pyproject.toml + testpaths: tests + plugins: timeout-2.2.0, cov-4.1.0, sphinx-0.5.0, rerunfailures-13.0, anyio-4.1.0, pytest_pyvista-0.1.9 + collected 1468 items / 1466 deselected / 4 skipped / 2 selected - .. code:: pwsh-session + tests/test_commands.py .. [100%] - SET PYMAPDL_START_INSTANCE=False - SET PYMAPDL_PORT= (default 50052) - SET PYMAPDL_IP= (default 127.0.0.1) + ================================= PyMAPDL Pytest short summary ================================================ + ========================= 2 passed, 4 skipped, 1466 deselected in 2.27s ======================================= - .. tab-item:: Linux - :sync: key1 - - .. code:: console +If you are running on a **Linux machine without display** (for example running from +a container), you must install ``xvfb`` OS library and run the preceding command with the ``xvfb-run`` command as prefix. - export PYMAPDL_START_INSTANCE=False - export PYMAPDL_PORT= (default 50052) - export PYMAPDL_IP= (default 127.0.0.1) +.. code:: console + (.venv) mapdl@machine:~/pymapdl$ xvfb-run pytest -These environment variables tell PyMAPDL to attempt to connect to the existing -MAPDL service by default when the ``launch_mapdl`` function is used. -Additionally, you can use the :envvar:`PYMAPDL_MAPDL_EXEC` and :envvar:`PYMAPDL_MAPDL_VERSION` +Configuring the test suite +-------------------------- + +PyMAPDL can operate in multiple situations, or configurations. +To test these different configurations, you can use the `pytest` framework with specific environment variables. + +The list of environment variables that can be set includes: + ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Environment variable | Values | Default | Usage | ++===================================+==================+=================+===============================================================================================================================================================================================================================================================+ +| :envvar:`ON_CI` | `True`/`False` | `False` | Tell Pytest it is running on GitHub Actions | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`ON_LOCAL` | `True`/`False` | Detected | Tell Pytest that PyMAPDL is running on local, and the test should match that. The default is to detect whether MAPDL is installed or not. If the environment variable :envvar:`PYMAPDL_START_INSTANCE` is set, then :envvar:`ON_LOCAL` is `False`. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`ON_UBUNTU` | `True`/`False` | Detected | Tell Pytest that PyMAPDL is running on Ubuntu, and the test should match that. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`ON_STUDENT` | `True`/`False` | `False` | Tell Pytest that PyMAPDL is running on a student environment, and the test should match that. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`TESTING_MINIMAL` | `True`/`False` | `False` | Tell Pytest that PyMAPDL is installed with the minimal requirements, hence it won't run tests that requires libraries like Pyvista, DPF, etc. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`PYMAPDL_DEBUG_TESTING` | `True`/`False` | `False` | Tell PyMAPDL to enable debug while testing. This means that the APDL commands are recorded to the file `pymapdl.apdl` and the debug calls are logged into the file `pymapdl.log`. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`HAS_GRPC` | `True`/`False` | Detected | Tell PyMAPDL that the gRPC interface is available for testing. If `TESTING_MINIMAL` is `True`, then this is `True` by default. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`HAS_DPF` | `True`/`False` | `False` | Tell Pytest that DPF should be tested. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`DISTRIBUTED_MODE` | `smp`/`dmp` | `smp` | Tell Pytest that MAPDL is running a given distributed mode. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`SUPPORT_PLOTTING` | `True`/`False` | Detected | Tell Pytest that the machine supports plotting (i.e. it has a display). | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| :envvar:`TEST_DPF_BACKEND` | `Yes`/`No` | `NO` | Tell Pytest that the module `Result` with DPF backend should be tested. | ++-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Additionally, you can use any `PyMAPDL environment variables `_ +like the :envvar:`PYMAPDL_MAPDL_EXEC` and :envvar:`PYMAPDL_MAPDL_VERSION` environment variables to specify the MAPDL executable path and the version to launch (if multiple versions of MAPDL are installed). From af442f0dca41e74fdc8127fdd0ba9931b3a7a172 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:07:57 +0200 Subject: [PATCH 14/19] fix: Simplify comment in has_grpc function to clarify gRPC assumption --- tests/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common.py b/tests/common.py index 4866534bbb1..8d4e742e079 100644 --- a/tests/common.py +++ b/tests/common.py @@ -119,7 +119,7 @@ def has_grpc(): rver = int(rver * 10) return int(rver) >= 211 else: - return True # In remote mode, assume gRPC by default. + return True # Assume gRPC by default. def has_dpf(): From b23c26e34c96c4144155bd218f1ce45b5abd5e8e Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:18:14 +0200 Subject: [PATCH 15/19] fix: Correct indentation in docker-compose.yml for default service --- docker/testing/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index 5dbce18959b..fd281a4dd87 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -85,7 +85,7 @@ services: - mapdl-remote-container - mapdl-remote-container-pymapdl-clone - mapdl-remote-container-pymapdl-host -- default + - default shm_size: '2gb' restart: unless-stopped hostname: mapdl From 00f1d81317466e02c06b62f8a5c445b0f4f8d837 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:36:10 +0200 Subject: [PATCH 16/19] fix: Update docker-compose.yml to add missing comment for volume requirement in mapdl-remote-container --- docker/testing/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml index fd281a4dd87..a84d1c3750e 100644 --- a/docker/testing/docker-compose.yml +++ b/docker/testing/docker-compose.yml @@ -103,9 +103,9 @@ services: "-grpc", "${MAPDL_EXTRA_ARGS:-}" ] - # Required for v261 onwards. working_dir: /workspace volumes: + # Required for v261 onwards. - ./mylocal.ip:/workspace/mylocal.ip:ro mapdl-remote-host: From 8a0a5d1a385928747fa34ae662eddaa2b21f1d6d Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 21 Aug 2025 16:41:11 +0200 Subject: [PATCH 17/19] fix: Update environment variable vocabulary to include DMP and SMP --- doc/source/getting_started/develop_pymapdl.rst | 4 ++-- doc/styles/config/vocabularies/ANSYS/accept.txt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/getting_started/develop_pymapdl.rst b/doc/source/getting_started/develop_pymapdl.rst index b3d784aac2e..3b1fb6274aa 100644 --- a/doc/source/getting_started/develop_pymapdl.rst +++ b/doc/source/getting_started/develop_pymapdl.rst @@ -324,7 +324,7 @@ The list of environment variables that can be set includes: +===================================+==================+=================+===============================================================================================================================================================================================================================================================+ | :envvar:`ON_CI` | `True`/`False` | `False` | Tell Pytest it is running on GitHub Actions | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| :envvar:`ON_LOCAL` | `True`/`False` | Detected | Tell Pytest that PyMAPDL is running on local, and the test should match that. The default is to detect whether MAPDL is installed or not. If the environment variable :envvar:`PYMAPDL_START_INSTANCE` is set, then :envvar:`ON_LOCAL` is `False`. | +| :envvar:`ON_LOCAL` | `True`/`False` | Detected | Tell Pytest that PyMAPDL is running on local, and the test should match that. The default is to detect whether MAPDL is installed or not. If the environment variable :envvar:`PYMAPDL_START_INSTANCE` is set, then :envvar:`ON_LOCAL` is `False`. | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :envvar:`ON_UBUNTU` | `True`/`False` | Detected | Tell Pytest that PyMAPDL is running on Ubuntu, and the test should match that. | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -338,7 +338,7 @@ The list of environment variables that can be set includes: +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :envvar:`HAS_DPF` | `True`/`False` | `False` | Tell Pytest that DPF should be tested. | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| :envvar:`DISTRIBUTED_MODE` | `smp`/`dmp` | `smp` | Tell Pytest that MAPDL is running a given distributed mode. | +| :envvar:`DISTRIBUTED_MODE` | `SMP`/`DMP` | `SMP` | Tell Pytest that MAPDL is running a given distributed mode. | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :envvar:`SUPPORT_PLOTTING` | `True`/`False` | Detected | Tell Pytest that the machine supports plotting (i.e. it has a display). | +-----------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/doc/styles/config/vocabularies/ANSYS/accept.txt b/doc/styles/config/vocabularies/ANSYS/accept.txt index 06131c0bbae..67e3f4242ef 100644 --- a/doc/styles/config/vocabularies/ANSYS/accept.txt +++ b/doc/styles/config/vocabularies/ANSYS/accept.txt @@ -63,6 +63,7 @@ devcontainer DevContainer Dimitris discretisation +DMP dof ect eigenfrequency @@ -162,6 +163,7 @@ singl Slurm SLURM smal +SMP sord spotweld squeue From d3f1fc60d9374c7eaff56a7d9f20eee5eee24814 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 21 Aug 2025 16:41:28 +0200 Subject: [PATCH 18/19] fix: Clarify message regarding insufficient licenses for MAPDL startup --- doc/source/user_guide/troubleshoot.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/troubleshoot.rst b/doc/source/user_guide/troubleshoot.rst index ce47e91f38b..3bbdf326f5d 100644 --- a/doc/source/user_guide/troubleshoot.rst +++ b/doc/source/user_guide/troubleshoot.rst @@ -273,7 +273,7 @@ In such cases, if you try to start MAPDL from the command line you might see an FlexNet Licensing error:-5,357 -If there are not enough licenses available, you might see an error similar to the above one. +This means that there are not enough licenses available to start MAPDL. In these cases you should contact your Ansys license administrator at your organization. If you are responsible for maintaining Ansys licensing or have a personal installation of Ansys, see the online From b20050745ab62d6ffa40340cf1e717abbef3af10 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:23:17 +0000 Subject: [PATCH 19/19] chore: adding changelog file 4186.maintenance.md [dependabot-skip] --- doc/changelog.d/4186.maintenance.md | 1 + doc/changelog.d/4186.miscellaneous.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 doc/changelog.d/4186.maintenance.md delete mode 100644 doc/changelog.d/4186.miscellaneous.md diff --git a/doc/changelog.d/4186.maintenance.md b/doc/changelog.d/4186.maintenance.md new file mode 100644 index 00000000000..45f3777c252 --- /dev/null +++ b/doc/changelog.d/4186.maintenance.md @@ -0,0 +1 @@ +Adding docker compose files for testing diff --git a/doc/changelog.d/4186.miscellaneous.md b/doc/changelog.d/4186.miscellaneous.md deleted file mode 100644 index de3914ac627..00000000000 --- a/doc/changelog.d/4186.miscellaneous.md +++ /dev/null @@ -1 +0,0 @@ -Ci: adding docker compose files for testing