Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
arch: amd64
os: linux
dist: focal
language: python

python:
- "3.8"
- "3.9"
- "3.10"
dist: noble
language: minimal

services:
- docker

before_install:
- sudo apt-get -y install libxml2-dev
- sudo add-apt-repository -y ppa:deadsnakes
- sudo apt-get update
- sudo apt-get -y install python3.9 python3.10 python3.11 python3.12 python3.13
- ssl/prepare-certs.sh
# Use Docker rabbitmq instead of Travis'. Travis's gave us test failures
# with our ChannelFull features, possibly because of feature differences.
- sudo service rabbitmq stop
- docker pull rabbitmq:3.8.11-alpine
- docker run --rm -d -p 5671:5671 -p 5672:5672 -v "/${TRAVIS_BUILD_DIR}"/ssl:/ssl -e RABBITMQ_SSL_CACERTFILE=/ssl/ca.cert -e RABBITMQ_SSL_CERTFILE=/ssl/server.cert -e RABBITMQ_SSL_KEYFILE=/ssl/server.key -e RABBITMQ_SSL_VERIFY=verify_peer -e RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT=true rabbitmq:3.8.11-alpine
# Now it'll start up while we're doing our install. There's a race, but
# it's extremely likely rabbitmq will be up before pytest starts.
- python -m pip install poetry~=1.1.0 tox-travis
install: poetry install -v
script: tox
- python -m pip install poetry~=1.1.0 tox

jobs:
include:
- stage: test
install: poetry install -v
script: tox
- stage: deploy
python: "3.10"
before_install: python -m pip install poetry
Expand Down
21 changes: 21 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,27 @@ Now take on the development cycle:
#. Write new code in ``channels_rabbitmq/`` to make the tests pass.
#. Submit a pull request.

If you have your local system RabbitMQ running on the same ports, use different ports starting the development RabbitMQ::

ssl/prepare-certs.sh # Create SSL certificates used in tests
docker run --rm -it \
-p 5674:5671 \
-p 5675:5672 \
-p 15678:15672 \
-v "/$(pwd)"/ssl:/ssl \
-e RABBITMQ_SSL_CACERTFILE=/ssl/ca.cert \
-e RABBITMQ_SSL_CERTFILE=/ssl/server.cert \
-e RABBITMQ_SSL_KEYFILE=/ssl/server.key \
-e RABBITMQ_SSL_VERIFY=verify_peer \
-e RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT=true \
rabbitmq:3.8.11-management-alpine

(or whatever you would like to use)

Then you need to pass the RabbitMQ endpoints explicitly in the environment::

AMQPS_HOST=amqps://guest:guest@localhost:5674 AMQP_HOST=amqp://guest:guest@localhost:5675 tox

To deploy
~~~~~~~~~

Expand Down
6 changes: 3 additions & 3 deletions channels_rabbitmq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ def __init__(
self._queue_name = "channels_{rand}".format(rand=_random_letters(12))

self._multi_queue = MultiQueue(capacity=local_capacity)
self._carehare_connection: asyncio.Future[
carehare.Connection
] = asyncio.Future()
self._carehare_connection: asyncio.Future[carehare.Connection] = (
asyncio.Future()
)
self._want_close: bool = False

@property
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ legacy_tox_ini = """
[tox]
isolated_build = True
skipsdist = True
envlist = {py38,py39,py310}-{pyflakes,black,isort,pytest}
envlist = {py39,py310,py311,py312,py313}-{pyflakes,black,isort,pytest}

[flake8]
exclude = venv/*,tox/*,specs/*,build/*
Expand All @@ -58,4 +58,7 @@ commands =
black: black --check channels_rabbitmq tests
isort: isort --check --diff channels_rabbitmq tests
pytest: poetry run pytest --cov=channels_rabbitmq --cov-report term-missing -v
setenv =
AMQPS_HOST={env:AMQPS_HOST:amqps://guest:guest@localhost}
AMQP_HOST={env:AMQP_HOST:amqp://guest:guest@localhost}
"""
8 changes: 4 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import contextlib
import os
import ssl
import threading
import time
Expand All @@ -10,7 +11,8 @@

from channels_rabbitmq.core import RabbitmqChannelLayer, ReconnectDelay

HOST = "amqps://guest:guest@localhost"
HOST = os.environ.get("AMQPS_HOST", "amqps://guest:guest@localhost")
HOST2 = os.environ.get("AMQP_HOST", "amqp://guest:guest@localhost")
SSL_CONTEXT = ssl.create_default_context(
cafile=str(Path(__file__).parent.parent / "ssl" / "server.cert")
)
Expand Down Expand Up @@ -527,9 +529,7 @@ async def test_no_ssl():

Assumes the server is listening over both a TLS port and a no-TLS port.
"""
async with open_layer(
queue_name="x", host=HOST.replace("amqps://", "amqp://"), ssl_context=None
) as layer:
async with open_layer(queue_name="x", host=HOST2, ssl_context=None) as layer:
await layer.carehare_connection


Expand Down