Browse Source

CI: Run integration tests for rabbitmq and redis

Ask Solem 8 năm trước cách đây
mục cha
commit
0d0d00dd31
7 tập tin đã thay đổi với 30 bổ sung31 xóa
  1. 2 0
      .coveragerc
  2. 10 5
      .travis.yml
  3. 2 10
      celery/contrib/testing/manager.py
  4. 2 1
      celery/utils/time.py
  5. 1 3
      t/integration/conftest.py
  6. 4 1
      t/integration/test_canvas.py
  7. 9 11
      tox.ini

+ 2 - 0
.coveragerc

@@ -19,3 +19,5 @@ omit =
     *celery/backends/riak.py
     *celery/concurrency/asynpool.py
     *celery/utils/debug.py
+    *celery/contrib/testing/*
+    *celery/contrib/pytest.py

+ 10 - 5
.travis.yml

@@ -10,15 +10,20 @@ env:
     PYTHONUNBUFFERED=yes
   matrix:
     - TOXENV=2.7-unit
-    - TOXENV=2.7-integration
+    - TOXENV=2.7-integration-rabbitmq
+    - TOXENV=2.7-integration-redis
     - TOXENV=3.4-unit
-    - TOXENV=3.4-integration
+    - TOXENV=3.4-integration-rabbitmq
+    - TOXENV=3.4-integration-redis
     - TOXENV=3.5-unit
-    - TOXENV=3.5-integration
+    - TOXENV=3.5-integration-rabbitmq
+    - TOXENV=3.5-integration-redis
     - TOXENV=pypy-unit PYPY_VERSION="5.3"
-    - TOXENV=pypy-integration PYPY_VERSION="5.3"
+    - TOXENV=pypy-integration-rabbitmq PYPY_VERSION="5.3"
+    - TOXENV=pypy-integration-redis PYPY_VERSION="5.3"
     - TOXENV=pypy3-unit
-    - TOXENV=pypy3-integration
+    - TOXENV=pypy3-integration-rabbitmq
+    - TOXENV=pypy3-integration-redis
     - TOXENV=flake8
     - TOXENV=flakeplus
     - TOXENV=apicheck

+ 2 - 10
celery/contrib/testing/manager.py

@@ -18,21 +18,13 @@ from celery.utils.time import humanize_seconds as _humanize_seconds
 
 E_STILL_WAITING = 'Still waiting for {0}.  Trying again {when}: {exc!r}'
 
+humanize_seconds = partial(_humanize_seconds, microseconds=True)
+
 
 class Sentinel(Exception):
     """Signifies the end of something."""
 
 
-def humanize_seconds(secs, prefix='', sep='', now='now', **kwargs):
-    # type: (float, str, str, str, **Any) -> str
-    """Represent seconds in a human readable way."""
-    s = _humanize_seconds(secs, prefix, sep, now, **kwargs)
-    if s == now and secs > 0:
-        return '{prefix}{sep}{0:.2f} seconds'.format(
-            float(secs), prefix=prefix, sep=sep)
-    return s
-
-
 class ManagerMixin(object):
     """Mixin that adds :class:`Manager` capabilities."""
 

+ 2 - 1
celery/utils/time.py

@@ -260,7 +260,8 @@ def humanize_seconds(secs, prefix='', sep='', now='now', microseconds=False):
             return '{0}{1}{2} {3}'.format(prefix, sep, formatter(w),
                                           pluralize(w, unit))
     if microseconds and secs > 0.0:
-        return '{prefix}{0:.2f} seconds'.format(secs, prefix=prefix)
+        return '{prefix}{sep}{0:.2f} seconds'.format(
+            secs, sep=sep, prefix=prefix)
     return now
 
 

+ 1 - 3
t/integration/conftest.py

@@ -1,8 +1,5 @@
-from __future__ import absolute_import, unicode_literals
-
 import os
 import pytest
-
 from celery.contrib.testing.manager import Manager
 
 TEST_BROKER = os.environ.get('TEST_BROKER', 'pyamqp://')
@@ -11,6 +8,7 @@ TEST_BACKEND = os.environ.get('TEST_BACKEND', 'redis://')
 
 @pytest.fixture(scope='session')
 def celery_config():
+    assert TEST_BACKEND == 'rpc'
     return {
         'broker_url': TEST_BROKER,
         'result_backend': TEST_BACKEND

+ 4 - 1
t/integration/test_canvas.py

@@ -81,10 +81,11 @@ def assert_ids(r, expected_value, expected_root_id, expected_parent_id):
     assert parent_id == expected_parent_id
 
 
-@pytest.mark.celery(result_backend='redis://')
 class test_chord:
 
     def test_parent_ids(self, manager):
+        if not manager.app.conf.result_backend.startswith('redis'):
+            raise pytest.skip('Requires redis result backend.')
         root = ids.si(i=1)
         expected_root_id = root.freeze().id
         g = chain(
@@ -97,6 +98,8 @@ class test_chord:
         self.assert_parentids_chord(g(), expected_root_id)
 
     def test_parent_ids__OR(self, manager):
+        if not manager.app.conf.result_backend.startswith('redis'):
+            raise pytest.skip('Requires redis result backend.')
         root = ids.si(i=1)
         expected_root_id = root.freeze().id
         g = (

+ 9 - 11
tox.ini

@@ -1,6 +1,8 @@
 [tox]
 envlist =
-    {2.7,pypy,3.4,3.5,pypy3}-{unit,integration}
+    {2.7,pypy,3.4,3.5,pypy3}-unit
+    {2.7,pypy,3.4,3.5,pypy3}-integration-{rabbitmq,redis}
+
     flake8
     flakeplus
     apicheck
@@ -30,6 +32,12 @@ commands =
 setenv =
     WORKER_LOGLEVEL = INFO
 
+    rabbitmq: TEST_BROKER=pyamqp://
+    rabbitmq: TEST_BACKEND=rpc
+
+    redis: TEST_BROKER=redis://
+    redis: TEST_BACKEND=redis://
+
 basepython =
     2.7: python2.7
     3.4: python3.4
@@ -38,16 +46,6 @@ basepython =
     pypy3: pypy3
     flake8,flakeplus,apicheck,linkcheck,configcheck,pydocstyle,cov: python2.7
 
-[testenv:redis]
-setenv =
-    TEST_BROKER = redis://
-    TEST_BACKEND = redis://
-
-[testenv:rabbitmq]
-setenv =
-    TEST_BROKER = pyamqp://
-    TEST_BACKEND = rpc
-
 [testenv:cov]
 commands =
     pip install -U -r{toxinidir}/requirements/dev.txt