From 2b4218828d0a70f6fbc258169524fbdcb970fee6 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 12 Aug 2021 12:18:08 -0400 Subject: [PATCH] Parallelize some tests. --- setup.cfg | 2 ++ test/test_cache.py | 4 ++++ test/test_cached_tiles.py | 3 +++ tox.ini | 4 +++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 53b93b80f..c135cc539 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,8 @@ ignore = D100,D101,D102,D103,D104,D105,D106,D107,D200,D205,D400,D401,E741,W504 addopts = --verbose --strict-markers --showlocals --cov-report="term" --cov-report="xml" --cov --ignore test/utils cache_dir = build/pytest_cache testpaths = test girder/test_girder girder_annotation/test_annotation +markers = + singular: mark a test to run in a non-parallel environment. [coverage:paths] # As of pytest-cov 2.6, all but the first source line is relative to the first diff --git a/test/test_cache.py b/test/test_cache.py index 853e26400..b453e7934 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -57,6 +57,7 @@ def testBadMemcachedUrl(): cache['(2,)'] +@pytest.mark.singular def testGetTileCachePython(): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None @@ -65,6 +66,7 @@ def testGetTileCachePython(): assert isinstance(tileCache, cachetools.LRUCache) +@pytest.mark.singular def testGetTileCacheMemcached(): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None @@ -129,6 +131,7 @@ class ExampleWithMetaclass(metaclass=LruCacheMetaclass): def __init__(self, arg): pass + @pytest.mark.singular def testCachesInfo(self): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None @@ -146,6 +149,7 @@ def testCachesInfo(self): # memcached shows an items record as well assert 'items' in cachesInfo()['tileCache'] + @pytest.mark.singular def testCachesClear(self): large_image.cache_util.cache._tileCache = None large_image.cache_util.cache._tileLock = None diff --git a/test/test_cached_tiles.py b/test/test_cached_tiles.py index 3acb3d3d2..c70818253 100644 --- a/test/test_cached_tiles.py +++ b/test/test_cached_tiles.py @@ -32,6 +32,7 @@ def wrapKey(*args, **kwargs): class LargeImageCachedTilesTest: + @pytest.mark.singular def testTilesFromTest(self, monitorTileCounts): # Create a test tile with the default options params = {'encoding': 'JPEG'} @@ -87,6 +88,7 @@ def testTilesFromTest(self, monitorTileCounts): utilities.checkTilesZXY(source, meta, params, utilities.PNGHeader) assert large_image_source_test._counters['tiles'] == counter3 + @pytest.mark.singular def testLargeRegion(self): imagePath = datastore.fetch( 'sample_jp2k_33003_TCGA-CV-7242-11A-01-TS1.1838afb1-9eee-' @@ -107,6 +109,7 @@ def testLargeRegion(self): image, mimeType = source.getRegion(**params) assert image[:len(utilities.PNGHeader)] == utilities.PNGHeader + @pytest.mark.singular def testTiffClosed(self): # test the Tiff files are properly closed. orig_del = TiledTiffDirectory.__del__ diff --git a/tox.ini b/tox.ini index fc2d8b521..e9aa07831 100644 --- a/tox.ini +++ b/tox.ini @@ -27,10 +27,12 @@ extras = whitelist_externals = rm npx +# Run non-girder tests in parallel and girder tests sequentially commands = rm -rf build/test/coverage/web_temp girder build --dev - pytest --cov-config setup.cfg {posargs} + pytest --numprocesses logical -m 'not singular' --cov-config setup.cfg {posargs} + pytest -m 'singular' --cov-config setup.cfg --cov-append {posargs} - npx nyc report --temp-dir build/test/coverage/web_temp --report-dir build/test/coverage --reporter cobertura --reporter text-summary # Reduce npm chatter setenv =