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/ \#* .\#* 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/source/getting_started/develop_pymapdl.rst b/doc/source/getting_started/develop_pymapdl.rst index d0786ee22b7..3b1fb6274aa 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). 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/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/doc/source/user_guide/troubleshoot.rst b/doc/source/user_guide/troubleshoot.rst index bf3f7e19cbe..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 @@ -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/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 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 diff --git a/docker/testing/Dockerfile b/docker/testing/Dockerfile new file mode 100644 index 00000000000..44467219d36 --- /dev/null +++ b/docker/testing/Dockerfile @@ -0,0 +1,217 @@ +# PyMAPDL docker image that runs the tests. + +# 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 +####################################################### + +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 \ + 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 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 \ + 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 +# 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 + +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=false + +####################################################### +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 /workspace/* >/dev/null 2>&1 + +####################################################### +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 +# To 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 +# 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" ] diff --git a/docker/testing/docker-compose.yml b/docker/testing/docker-compose.yml new file mode 100644 index 00000000000..a84d1c3750e --- /dev/null +++ b/docker/testing/docker-compose.yml @@ -0,0 +1,253 @@ +# 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-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-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 + profiles: + - mapdl-remote-container + - mapdl-remote-container-pymapdl-clone + - mapdl-remote-container-pymapdl-host + - default + shm_size: '2gb' + restart: unless-stopped + hostname: mapdl + networks: + - pymapdl-net + environment: + - ANSYSLMD_LICENSE_FILE=${ANSYSLMD_LICENSE_FILE} + - ANSYS_LOCK=OFF + image: ${DOCKER_IMAGE} + platform: linux/amd64 + # You might want to customize it + entrypoint: ${MAPDL_ENTRYPOINT:-"/bin/bash"} + command: [ + "${MAPDL_EXEC_PATH:-ansys}", + "-grpc", + "${MAPDL_EXTRA_ARGS:-}" + ] + working_dir: /workspace + volumes: + # Required for v261 onwards. + - ./mylocal.ip:/workspace/mylocal.ip:ro + + 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 + container_name: pymapdl-test + platform: linux/amd64 + networks: + - pymapdl-net + build: + context: . + dockerfile: Dockerfile + target: test-local-pymapdl + environment: + - PYMAPDL_IP=mapdl # Use the MAPDL service name + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} + working_dir: /workspace/pymapdl + volumes: + - ../../../:/workspace + + pymapdl-clone: + # This service clones the PyMAPDL repository and test against it. + profiles: + - pymapdl-clone + - mapdl-remote-container-pymapdl-clone + - mapdl-remote-host-pymapdl-clone + - mapdl-local-container-pymapdl-clone + - mapdl-local-host-pymapdl-clone + - default # Default profile + # container_name: pymapdl-test + platform: linux/amd64 + networks: + - pymapdl-net + build: + context: . + dockerfile: Dockerfile + target: test-clone-pymapdl + environment: + - PYMAPDL_IP=mapdl # Use the MAPDL service name + # 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. + # + # 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:-main} + + 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 + target: mapdl-local-container-pymapdl + args: + - DOCKER_IMAGE=${DOCKER_IMAGE} + environment: + # If empty, it will use the default 'main' branch + - PYMAPDL_BRANCH=${PYMAPDL_BRANCH:-main} + volumes: + - ../../../:/workspace + +networks: + pymapdl-net: + driver: bridge \ No newline at end of file diff --git a/docker/testing/mylocal.ip b/docker/testing/mylocal.ip new file mode 100644 index 00000000000..d690dc0d591 --- /dev/null +++ b/docker/testing/mylocal.ip @@ -0,0 +1 @@ +0.0.0.0 diff --git a/docker/testing/start.sh b/docker/testing/start.sh new file mode 100644 index 00000000000..e5369a929b5 --- /dev/null +++ b/docker/testing/start.sh @@ -0,0 +1,27 @@ +#! /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}" > /dev/null 2>&1 + git checkout "${PYMAPDL_BRANCH}" +fi + +if [[ "${USE_LOCAL_REPO}" == "true" ]]; then + echo "Using local PyMAPDL repository for testing." + # Uncomment if you expect changes in the dependencies. + # python3 -m pip install '.[tests]' + +else + echo "Using cloned PyMAPDL repository for testing." +fi + +echo "Using pytest arguments: ${PYTEST_ARGUMENTS}" + +# shellcheck disable=SC2086 +xvfb-run pytest ${PYTEST_ARGUMENTS} \ No newline at end of file diff --git a/src/ansys/mapdl/core/database/database.py b/src/ansys/mapdl/core/database/database.py index cf2316bae57..2fbbbfe69ff 100644 --- a/src/ansys/mapdl/core/database/database.py +++ b/src/ansys/mapdl/core/database/database.py @@ -318,7 +318,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 b947a6ed2ad..8cf1e6486ea 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -3310,7 +3310,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:: 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():