From cb9fe34d274130f2ec90fa52d90754bb0a333e41 Mon Sep 17 00:00:00 2001 From: Vsevolod Novikov Date: Thu, 29 May 2025 09:02:14 +0300 Subject: [PATCH 1/9] Tests for py3.11, py3.12, custom test hosts --- .travis.yml | 2 ++ channels_rabbitmq/core.py | 6 +++--- pyproject.toml | 5 ++++- tests/test_core.py | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f9aafe..2b1ba2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: - "3.8" - "3.9" - "3.10" + - "3.11" + - "3.12" services: - docker 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..539af20 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 = {py38,py39,py310,py311,py312}-{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 From 455a310a0cbf00ab84ef67e34bffe9fe1fde588f Mon Sep 17 00:00:00 2001 From: Vsevolod Novikov Date: Thu, 29 May 2025 09:29:27 +0300 Subject: [PATCH 2/9] README fixed to describe the available development env vars --- README.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 ~~~~~~~~~ From 887a9bb705f3b725dd5af0a32ac36797f68639c4 Mon Sep 17 00:00:00 2001 From: adamhooper Date: Thu, 10 Jul 2025 22:00:56 -0400 Subject: [PATCH 3/9] Upgrade Travis Ubuntu image --- .travis.yml | 26 ++++++++++++++++---------- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b1ba2d..6cd9618 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,22 @@ +arch: amd64 os: linux -dist: focal -language: python - -python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" +dist: noble +language: minimal services: - docker + +addons: + apt: + sources: + - deadsnakes + packages: + - python3.9 + - python3.10 + - python3.11 + - python3.12 + - python3.13 + before_install: - ssl/prepare-certs.sh # Use Docker rabbitmq instead of Travis'. Travis's gave us test failures @@ -19,7 +25,7 @@ before_install: - 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 + - python -m pip install poetry~=1.1.0 tox install: poetry install -v script: tox diff --git a/pyproject.toml b/pyproject.toml index 539af20..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,py311,py312}-{pyflakes,black,isort,pytest} +envlist = {py39,py310,py311,py312,py313}-{pyflakes,black,isort,pytest} [flake8] exclude = venv/*,tox/*,specs/*,build/* From 3b98885900ca31d281cb189952f370f64f0a7289 Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:30:05 -0400 Subject: [PATCH 4/9] Does this fix Python install? --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6cd9618..92adf8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ addons: - python3.13 before_install: + - sudo apt-get -y install libxml2-dev - 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. From da7f66669232aadd0122f3a2689435bd9f7e5f22 Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:33:29 -0400 Subject: [PATCH 5/9] Skip apt addon --- .travis.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92adf8c..2dde7a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,19 +6,11 @@ language: minimal services: - docker -addons: - apt: - sources: - - deadsnakes - packages: - - python3.9 - - python3.10 - - python3.11 - - python3.12 - - python3.13 - before_install: - sudo apt-get -y install libxml2-dev + - sudo add-apt-repository 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. From 9aff96dce5df7de0093452339cbb2afb0601af14 Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:43:59 -0400 Subject: [PATCH 6/9] Use `jobs` section --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2dde7a2..abc0786 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,12 @@ before_install: # 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 -install: poetry install -v -script: tox jobs: include: + - stage: test + install: poetry install -v + script: tox - stage: deploy python: "3.10" before_install: python -m pip install poetry From ec18c12c34373f39cf88bf44625830dc3717776e Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:47:39 -0400 Subject: [PATCH 7/9] Add a -y --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index abc0786..8867da3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ services: before_install: - sudo apt-get -y install libxml2-dev - - sudo add-apt-repository ppa:deadsnakes + - 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 From 47ccd0848f7d9de387d7d4755eb876ce8832d6a8 Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:52:39 -0400 Subject: [PATCH 8/9] Disable RabbitMQ --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8867da3..0b2db82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,9 @@ before_install: # it's extremely likely rabbitmq will be up before pytest starts. - python -m pip install poetry~=1.1.0 tox +before_script: + sudo service rabbitmq stop + jobs: include: - stage: test From 40ccaf4bfec8d0d92a6d952256751a687425e50d Mon Sep 17 00:00:00 2001 From: adamhooper Date: Fri, 11 Jul 2025 08:55:29 -0400 Subject: [PATCH 9/9] Stop RabbitMQ earlier --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b2db82..e19d76d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,15 +14,13 @@ before_install: - 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 -before_script: - sudo service rabbitmq stop - jobs: include: - stage: test