summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-11-04 21:48:19 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-11-04 21:57:14 -0500
commit3e77d698d6109f8bc681033f3bdb8b6383cc6e0a (patch)
treefbbb986eb940190e509e783b1cb7d83e0ebdab90
parent9e16bb8e5ac2694845c1e3e7cb6781cbac6dc0d2 (diff)
downloaddogpile-cache-3e77d698d6109f8bc681033f3bdb8b6383cc6e0a.tar.gz
mark thread-intensive tests and disable by default
using the tox 'full' environment marker will enable them. Fixes: #151 Fixes: #118 Fixes: #59 Change-Id: Ida5a9572ddd7f83ef4580e9e53fe2ae8acb64496
-rw-r--r--setup.cfg2
-rw-r--r--tests/cache/_fixtures.py4
-rw-r--r--tests/test_lock.py9
-rw-r--r--tox.ini53
4 files changed, 41 insertions, 27 deletions
diff --git a/setup.cfg b/setup.cfg
index 2f43889..319c4b9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -68,7 +68,7 @@ application-import-names = dogpile,tests
[tool:pytest]
-addopts= --tb native -v -r fxX -p no:logging -p no:warnings
+addopts= --tb native -v -r fxX -p no:logging -p no:warnings -m "not time_intensive"
python_files=tests/*test_*.py
filterwarnings =
error
diff --git a/tests/cache/_fixtures.py b/tests/cache/_fixtures.py
index c97ceb6..9d8176c 100644
--- a/tests/cache/_fixtures.py
+++ b/tests/cache/_fixtures.py
@@ -184,6 +184,7 @@ class _GenericBackendTest(_GenericBackendFixture, TestCase):
eq_(reg.get_or_create("some key", creator), "some value")
+ @pytest.mark.time_intensive
def test_threaded_dogpile(self):
# run a basic dogpile concurrency test.
# note the concurrency of dogpile itself
@@ -214,6 +215,7 @@ class _GenericBackendTest(_GenericBackendFixture, TestCase):
if not reg.backend.has_lock_timeout():
assert False not in canary
+ @pytest.mark.time_intensive
def test_threaded_get_multi(self):
reg = self._region(config_args={"expiration_time": 0.25})
locks = dict((str(i), Lock()) for i in range(11))
@@ -270,6 +272,7 @@ class _GenericBackendTest(_GenericBackendFixture, TestCase):
reg.delete("some key")
eq_(reg.get("some key"), NO_VALUE)
+ @pytest.mark.time_intensive
def test_region_expire(self):
# TODO: ideally tests like these would not be using actual
# time(); instead, an artificial function where the increment
@@ -344,6 +347,7 @@ class _GenericMutexTest(_GenericBackendFixture, TestCase):
assert ac3
mutex.release()
+ @pytest.mark.time_intensive
def test_mutex_threaded(self):
backend = self._backend()
backend.get_mutex("foo")
diff --git a/tests/test_lock.py b/tests/test_lock.py
index 4cec3cf..71dd192 100644
--- a/tests/test_lock.py
+++ b/tests/test_lock.py
@@ -6,6 +6,8 @@ import time
from unittest import mock
from unittest import TestCase
+import pytest
+
from dogpile import Lock
from dogpile import NeedRegenerationException
from dogpile.util import ReadWriteMutex
@@ -18,9 +20,11 @@ class ConcurrencyTest(TestCase):
_assertion_lock = threading.Lock()
+ @pytest.mark.time_intensive
def test_quick(self):
self._test_multi(10, 2, 0.5, 50, 0.05, 0.1)
+ @pytest.mark.time_intensive
def test_slow(self):
self._test_multi(10, 5, 2, 50, 0.1, 0.1)
@@ -32,20 +36,25 @@ class ConcurrencyTest(TestCase):
# slow_write_time=2
# )
+ @pytest.mark.time_intensive
def test_return_while_in_progress(self):
self._test_multi(10, 5, 2, 50, 1, 0.1)
+ @pytest.mark.time_intensive
def test_get_value_plus_created_long_create(self):
self._test_multi(10, 2, 2.5, 50, 0.05, 0.1)
+ @pytest.mark.time_intensive
def test_get_value_plus_created_registry_unsafe_cache(self):
self._test_multi(
10, 1, 0.6, 100, 0.05, 0.1, cache_expire_time="unsafe"
)
+ @pytest.mark.time_intensive
def test_get_value_plus_created_registry_safe_cache_quick(self):
self._test_multi(10, 2, 0.5, 50, 0.05, 0.1, cache_expire_time="safe")
+ @pytest.mark.time_intensive
def test_get_value_plus_created_registry_safe_cache_slow(self):
self._test_multi(10, 5, 2, 50, 0.1, 0.1, cache_expire_time="safe")
diff --git a/tox.ini b/tox.ini
index 799c875..01c588a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,44 +6,45 @@ cov_args=--cov=dogpile --cov-append --cov-report term --cov-report xml
setenv=
- BASECOMMAND=python -m pytest
+ BASECOMMAND=python -m pytest
- {generic}: RUNTESTS=-k 'not test_dbm_backend and not test_memcached_backend and not test_redis_backend'
+ {generic}: RUNTESTS=-k 'not test_dbm_backend and not test_memcached_backend and not test_redis_backend'
- {memcached}: PIFPAF=pifpaf --env-prefix DOGPILE run memcached --port {env:TOX_DOGPILE_PORT:11234} --
- {memcached}: PIFPAF_TLS=pifpaf --env-prefix DOGPILE_TLS run memcached --port {env:TOX_DOGPILE_TLS_PORT:11212} --ssl_chain_cert=tests/tls/server_chain.pem --ssl_key=tests/tls/server.key --
- {memcached}: RUNTESTS=tests/cache/test_memcached_backend.py
+ {memcached}: PIFPAF=pifpaf --env-prefix DOGPILE run memcached --port {env:TOX_DOGPILE_PORT:11234} --
+ {memcached}: PIFPAF_TLS=pifpaf --env-prefix DOGPILE_TLS run memcached --port {env:TOX_DOGPILE_TLS_PORT:11212} --ssl_chain_cert=tests/tls/server_chain.pem --ssl_key=tests/tls/server.key --
+ {memcached}: RUNTESTS=tests/cache/test_memcached_backend.py
- {redis}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --
- {redis}: RUNTESTS=tests/cache/test_redis_backend.py
+ {redis}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --
+ {redis}: RUNTESTS=tests/cache/test_redis_backend.py
- {redis_sentinel}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --sentinel --sentinel-port {env:TOX_DOGPILE_SENTINEL_PORT:11235} --
- {redis_sentinel}: RUNTESTS=tests/cache/test_redis_sentinel_backend.py
+ {redis_sentinel}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --sentinel --sentinel-port {env:TOX_DOGPILE_SENTINEL_PORT:11235} --
+ {redis_sentinel}: RUNTESTS=tests/cache/test_redis_sentinel_backend.py
- {dbm}: RUNTESTS=tests/cache/test_dbm_backend.py
+ {dbm}: RUNTESTS=tests/cache/test_dbm_backend.py
{cov}: COVERAGE={[testenv]cov_args}
+ {full}: FULL=-m ''
deps=
- pytest
- Mako
- decorator>=4.0.0
- # Needed for an async runner test.
- {memcached}: pylibmc
-
- # the py3k python-memcached fails for multiple
- # delete
- {memcached}: python-binary-memcached>=0.29.0
- {memcached}: pifpaf>=2.5.0
- {redis}: redis
- {redis}: pifpaf
- {redis_sentinel}: redis
- {redis_sentinel}: pifpaf
- {cov}: pytest-cov
+ pytest
+ Mako
+ decorator>=4.0.0
+ # Needed for an async runner test.
+ {memcached}: pylibmc
+
+ # the py3k python-memcached fails for multiple
+ # delete
+ {memcached}: python-binary-memcached>=0.29.0
+ {memcached}: pifpaf>=2.5.0
+ {redis}: redis
+ {redis}: pifpaf
+ {redis_sentinel}: redis
+ {redis_sentinel}: pifpaf
+ {cov}: pytest-cov
commands=
- {env:PIFPAF:} {env:PIFPAF_TLS:} {env:BASECOMMAND} {env:COVERAGE:} {env:RUNTESTS:} {posargs}
+ {env:PIFPAF:} {env:PIFPAF_TLS:} {env:BASECOMMAND} {env:COVERAGE:} {env:FULL:} {env:RUNTESTS:} {posargs}
sitepackages=False
usedevelop=True