diff --git a/.travis.yml b/.travis.yml index 7f9aafe..e19d76d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.rst b/README.rst index 0faa590..1f0482f 100644 --- a/README.rst +++ b/README.rst @@ -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 ~~~~~~~~~ diff --git a/channels_rabbitmq/core.py b/channels_rabbitmq/core.py index d6d3db7..89444ff 100644 --- a/channels_rabbitmq/core.py +++ b/channels_rabbitmq/core.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 85ffa1c..0b5c58a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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/* @@ -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} """ diff --git a/tests/test_core.py b/tests/test_core.py index ed70b4c..1e43a4b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,5 +1,6 @@ import asyncio import contextlib +import os import ssl import threading import time @@ -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") ) @@ -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