Skip to content

Commit

Permalink
Merge pull request #636 from girder/parallel-test
Browse files Browse the repository at this point in the history
Parallelize some tests.
  • Loading branch information
manthey authored Aug 12, 2021
2 parents 903dd61 + 2b42188 commit bdf0461
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/test_cached_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand Down Expand Up @@ -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-'
Expand All @@ -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__
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit bdf0461

Please sign in to comment.