Skip to content

Commit

Permalink
CI: Run integration tests for rabbitmq and redis
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Oct 22, 2016
1 parent 68e3be2 commit 0d0d00d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ omit =
*celery/backends/riak.py
*celery/concurrency/asynpool.py
*celery/utils/debug.py
*celery/contrib/testing/*
*celery/contrib/pytest.py
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions celery/contrib/testing/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@

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."""

Expand Down
3 changes: 2 additions & 1 deletion celery/utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 1 addition & 3 deletions t/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -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://')
Expand All @@ -11,6 +8,7 @@

@pytest.fixture(scope='session')
def celery_config():
assert TEST_BACKEND == 'rpc'
return {
'broker_url': TEST_BROKER,
'result_backend': TEST_BACKEND
Expand Down
5 changes: 4 additions & 1 deletion t/integration/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -97,6 +98,8 @@ def test_parent_ids(self, manager):
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 = (
Expand Down
20 changes: 9 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0d0d00d

Please sign in to comment.