summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@gmail.com>2020-04-30 00:01:12 +0200
committerAsif Saif Uddin <auvipy@gmail.com>2020-05-03 09:39:28 +0600
commit75667082e0d6031ef5029956bd8dcff3c44f1d73 (patch)
treeb10477100595413e94b94d05ad6a872c8cd2b809
parent1b89912a83124f8887e2fd601f64e432b942d7e2 (diff)
downloadkombu-75667082e0d6031ef5029956bd8dcff3c44f1d73.tar.gz
Initial redis integration tests implementation
-rw-r--r--.travis.yml21
-rw-r--r--t/integration/test_redis.py73
-rw-r--r--tox.ini11
3 files changed, 105 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 1c98525c..ac321744 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -75,6 +75,27 @@ jobs:
- python: pypy3.5-7.0
<<: *integration_job
env: TOXENV=pypy3-integration-py-amqp
+ - python: 2.7
+ <<: *integration_job
+ env: TOXENV=2.7-integration-redis
+ - python: 3.5
+ <<: *integration_job
+ env: TOXENV=3.5-integration-redis
+ - python: 3.6
+ <<: *integration_job
+ env: TOXENV=3.6-integration-redis
+ - python: 3.7
+ <<: *integration_job
+ env: TOXENV=3.7-linux-integration-redis
+ - python: 3.8
+ <<: *integration_job
+ env: TOXENV=3.8-linux-integration-redis
+ - python: pypy2.7-7.1.1
+ <<: *integration_job
+ env: TOXENV=pypy-integration-redis
+ - python: pypy3.5-7.0
+ <<: *integration_job
+ env: TOXENV=pypy3-integration-redis
install:
- pip --disable-pip-version-check install -U pip setuptools wheel | cat
diff --git a/t/integration/test_redis.py b/t/integration/test_redis.py
new file mode 100644
index 00000000..f4a94a95
--- /dev/null
+++ b/t/integration/test_redis.py
@@ -0,0 +1,73 @@
+from __future__ import absolute_import, unicode_literals
+
+from contextlib import closing
+import os
+
+import pytest
+import kombu
+
+def get_connection(
+ hostname, port, vhost):
+ return kombu.Connection('redis://{}:{}'.format(hostname, port))
+
+
+@pytest.fixture()
+def connection(request):
+ # this fixture yields plain connections to broker and TLS encrypted
+ return get_connection(
+ hostname=os.environ.get('REDIS_HOST', 'localhost'),
+ port=os.environ.get('REDIS_6379_TCP', '6379'),
+ vhost=getattr(
+ request.config, "slaveinput", {}
+ ).get("slaveid", None),
+ )
+
+@pytest.mark.env('redis')
+@pytest.mark.flaky(reruns=5, reruns_delay=2)
+def test_connect(connection):
+ connection.connect()
+ connection.close()
+
+@pytest.mark.env('redis')
+@pytest.mark.flaky(reruns=5, reruns_delay=2)
+def test_publish_consume(connection):
+ test_queue = kombu.Queue('test', routing_key='test')
+
+ def callback(body, message):
+ assert body == {'hello': 'world'}
+ assert message.content_type == 'application/x-python-serialize'
+ message.delivery_info['routing_key'] == 'test'
+ message.delivery_info['exchange'] == ''
+ message.ack()
+ assert message.payload == body
+
+ with connection as conn:
+ with conn.channel() as channel:
+ producer = kombu.Producer(channel)
+ producer.publish(
+ {'hello': 'world'},
+ retry=True,
+ exchange=test_queue.exchange,
+ routing_key=test_queue.routing_key,
+ declare=[test_queue],
+ serializer='pickle'
+ )
+
+ consumer = kombu.Consumer(conn, [test_queue], accept=['pickle'])
+ consumer.register_callback(callback)
+ with consumer:
+ conn.drain_events(timeout=1)
+
+
+@pytest.mark.env('redis')
+@pytest.mark.flaky(reruns=5, reruns_delay=2)
+def test_simple_publish_consume(connection):
+ with connection as conn:
+ with closing(conn.SimpleQueue('simple_test')) as queue:
+ queue.put({'Hello': 'World'}, headers={'k1': 'v1'})
+ message = queue.get(timeout=1)
+ assert message.payload == {'Hello': 'World'}
+ assert message.content_type == 'application/json'
+ assert message.content_encoding == 'utf-8'
+ assert message.headers == {'k1': 'v1'}
+ message.ack()
diff --git a/tox.ini b/tox.ini
index 6a95c602..3d665f4f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,6 +2,7 @@
envlist =
{2.7,pypy,pypy3,3.5,3.6,3.7-{linux,windows},3.8{linux,windows}}-unit
{2.7,pypy,pypy3,3.5,3.6,3.7-{linux,windows},3.8{linux,windows}}-integration-py-amqp
+ {2.7,pypy,pypy3,3.5,3.6,3.7-{linux,windows},3.8{linux,windows}}-integration-redis
flake8
flakeplus
apicheck
@@ -27,6 +28,7 @@ deps=
commands =
unit: python -bb -m pytest -rxs -xv --cov=kombu --cov-report=xml --no-cov-on-fail {posargs}
integration-py-amqp: py.test -xv -E py-amqp t/integration {posargs:-n2}
+ integration-redis: py.test -xv -E redis t/integration {posargs:-n2}
basepython =
2.7,flakeplus,flake8,linkcheck,cov: python2.7
@@ -40,6 +42,7 @@ install_command = python -m pip --disable-pip-version-check install {opts} {pack
docker =
integration-py-amqp: rabbitmq:alpine
+ integration-redis: redis:alpine
dockerenv =
PYAMQP_INTEGRATION_INSTANCE=1
@@ -53,6 +56,14 @@ healthcheck_timeout = 10
healthcheck_retries = 30
healthcheck_start_period = 5
+[docker:redis:alpine]
+ports = 6379:6379/tcp
+healthcheck_cmd = /bin/sh -c 'redis-cli ping'
+healthcheck_interval = 10
+healthcheck_timeout = 10
+healthcheck_retries = 30
+healthcheck_start_period = 5
+
[testenv:apicheck]
commands = pip install -U -r{toxinidir}/requirements/dev.txt
sphinx-build -j2 -b apicheck -d {envtmpdir}/doctrees docs docs/_build/apicheck