From 7afbe4d7d1855ee7adcadd4dce3809493d7e3b2e Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 29 Aug 2019 17:37:35 +0200 Subject: [PATCH 1/3] mark test tutorials as slow test --- tests/pytest/conftest.py | 20 ++++++++++++++++++++ tests/pytest/test_tutorials.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/pytest/conftest.py diff --git a/tests/pytest/conftest.py b/tests/pytest/conftest.py new file mode 100644 index 00000000..9eb2f24e --- /dev/null +++ b/tests/pytest/conftest.py @@ -0,0 +1,20 @@ +""" +Pytest configuration file to run slow test only if pytest is started with option --runslow or if +environment variable RUN_SLOW_TESTS is set. +""" + +import pytest, os + +def pytest_addoption(parser): + parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") + +def pytest_configure(config): + config.addinivalue_line("markers", "slow: mark test as slow to run") + + +def pytest_collection_modifyitems(config, items): + if not (('RUN_SLOW_TESTS' in os.environ and os.environ['RUN_SLOW_TESTS']) or config.getoption("--runslow")): + skip_slow = pytest.mark.skip(reason="need --runslow option to run") + for item in items: + if "slow" in item.keywords: + item.add_marker(skip_slow) diff --git a/tests/pytest/test_tutorials.py b/tests/pytest/test_tutorials.py index a5e1bd84..9bc9f780 100644 --- a/tests/pytest/test_tutorials.py +++ b/tests/pytest/test_tutorials.py @@ -1,7 +1,6 @@ import os, pytest from netgen.meshing import meshsize, MeshingParameters, SetMessageImportance -import netgen.gui import netgen.csg as csg import netgen.stl as stl try: @@ -61,6 +60,7 @@ def generateMesh(filename, mp): geo = occ.OCCGeometry(os.path.join("..","..","tutorials", filename)) return geo.GenerateMesh(**mp) +@pytest.mark.slow @pytest.mark.parametrize("filename, checkFunc", [(f, getCheckFunc(f)) for f in _geofiles]) def test_geoFiles(filename, checkFunc): for i, mp in enumerate(getMeshingparameters(filename)): From 25371510a5fc748e30cd5ad4f5594a62cd80a00a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 29 Aug 2019 17:41:22 +0200 Subject: [PATCH 2/3] Don't run slow tests in docker --- .gitlab-ci.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4bc6ed1a..6fe2c47b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,7 +85,14 @@ build_ubuntu_debug: script: - docker build -t netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile . - rm -f netgen_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id - - docker run --cidfile netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id -e CCACHE_DIR=/ccache -v /mnt/ccache:/ccache netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} bash /root/src/netgen/tests/build_debug.sh + - >- + docker run + --cidfile netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id + -e CCACHE_DIR=/ccache + -e RUN_SLOW_TESTS=${RUN_SLOW_TESTS} + -v /mnt/ccache:/ccache + netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} + bash /root/src/netgen/tests/build_debug.sh - docker commit `cat netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} - rm netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id @@ -95,7 +102,14 @@ build_ubuntu_mpi: script: - docker build -t netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile_mpi . - rm -f netgen_mpi_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id_mpi - - docker run --cidfile netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id -e CCACHE_DIR=/ccache -v /mnt/ccache:/ccache netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} bash /root/src/netgen/tests/build_mpi.sh + - >- + docker run>- + --cidfile netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id>- + -e CCACHE_DIR=/ccache + -e RUN_SLOW_TESTS=${RUN_SLOW_TESTS} + -v /mnt/ccache:/ccache + netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} + bash /root/src/netgen/tests/build_mpi.sh - docker commit `cat netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} - rm netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id @@ -105,6 +119,7 @@ test_ubuntu: script: - >- docker run + -e RUN_SLOW_TESTS=${RUN_SLOW_TESTS} -e NETGENDIR=/opt/netgen/bin -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} @@ -116,6 +131,7 @@ test_ubuntu_mpi: script: - >- docker run + -e RUN_SLOW_TESTS=${RUN_SLOW_TESTS} -e NETGENDIR=/opt/netgen/bin -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} From 23a6231c211588f17881a55e9bf3e942446a20ff Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 29 Aug 2019 17:56:47 +0200 Subject: [PATCH 3/3] mark only slow tutorials as slow --- tests/pytest/test_tutorials.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/pytest/test_tutorials.py b/tests/pytest/test_tutorials.py index 9bc9f780..6fabaa60 100644 --- a/tests/pytest/test_tutorials.py +++ b/tests/pytest/test_tutorials.py @@ -45,12 +45,10 @@ def getMeshingparameters(filename): return standard[3:] # coarser meshes don't work here return standard -# TODO: step files do not respect gui meshsizes yet. _geofiles = [f for f in getFiles(".geo")] + [f for f in getFiles(".stl")] if has_occ: _geofiles += [f for f in getFiles(".step")] - def generateMesh(filename, mp): if filename.endswith(".geo"): geo = csg.CSGeometry(os.path.join("..","..","tutorials", filename)) @@ -60,8 +58,17 @@ def generateMesh(filename, mp): geo = occ.OCCGeometry(os.path.join("..","..","tutorials", filename)) return geo.GenerateMesh(**mp) -@pytest.mark.slow -@pytest.mark.parametrize("filename, checkFunc", [(f, getCheckFunc(f)) for f in _geofiles]) +def isSlowTest(filename): + return filename in ["cubemcyl.geo", "frame.step", "revolution.geo", "manyholes.geo", "torus.geo", + "cubemsphere.geo", "manyholes2.geo", "matrix.geo", "trafo.geo", "ellipticcone.geo", + "period.geo", "shaft.geo", "cubeandring.geo", "ellipticcyl.geo", + "ellipsoid.geo", "cone.geo"] + +def getParamForTest(filename): + return pytest.param(filename, getCheckFunc(filename), marks=pytest.mark.slow) if isSlowTest(filename) \ + else (filename, getCheckFunc(filename)) + +@pytest.mark.parametrize(("filename, checkFunc"), [getParamForTest(f) for f in _geofiles]) def test_geoFiles(filename, checkFunc): for i, mp in enumerate(getMeshingparameters(filename)): print("load geo", filename)