Skip to content

Commit

Permalink
fixup! Add cluster option to result backend
Browse files Browse the repository at this point in the history
  • Loading branch information
stinovlas committed Nov 7, 2023
1 parent e79fa11 commit ae672c5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 33 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,14 @@ jobs:
- name: Run lint check
run: poetry run pre-commit run -a ${{ matrix.cmd }}
pytest:
services:
redis:
image: bitnami/redis:6.2.5
env:
ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd="redis-cli ping"
--health-interval=5s
--health-timeout=5s
--health-retries=30
ports:
- 6379:6379
redis-cluster:
image: bitnami/redis-cluster:6.2.5
env:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "localhost"
options: >-
--health-cmd="redis-cli ping"
--health-interval=5s
--health-timeout=5s
--health-retries=30
ports:
- 7000:6379
strategy:
matrix:
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: shogo82148/actions-setup-redis@v1
with:
redis-version: "6.x"
auto-start: false
- name: Set up single-node Redis cluster
run: redis-cli -h localhost -p 7000 --cluster-yes CLUSTER ADDSLOTS {0..16383}
- name: Set up Redis instance and Redis cluster
run: docker-compose up -d
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
60 changes: 60 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: '3.2'

services:
redis:
image: bitnami/redis:6.2.5
environment:
ALLOW_EMPTY_PASSWORD: "yes"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 3
start_period: 10s
ports:
- 7000:6379
redis-node-0:
image: docker.io/bitnami/redis-cluster:7.2
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"

redis-node-1:
image: docker.io/bitnami/redis-cluster:7.2
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"

redis-node-2:
image: docker.io/bitnami/redis-cluster:7.2
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"

redis-node-3:
image: docker.io/bitnami/redis-cluster:7.2
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"

redis-node-4:
image: docker.io/bitnami/redis-cluster:7.2
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"

redis-node-5:
image: docker.io/bitnami/redis-cluster:7.2
depends_on:
- redis-node-0
- redis-node-1
- redis-node-2
- redis-node-3
- redis-node-4
environment:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_NODES: "redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5"
REDIS_CLUSTER_REPLICAS: 1
REDIS_CLUSTER_CREATOR: "yes"
ports:
- 7001:6379
2 changes: 1 addition & 1 deletion taskiq_redis/redis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(

async def shutdown(self) -> None:
"""Closes redis connection."""
await self.redis.close()
await self.redis.aclose() # type: ignore[attr-defined]
await super().shutdown()

async def set_result(
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def redis_url() -> str:
:return: URL string.
"""
return os.environ.get("TEST_REDIS_URL", "redis://localhost")
return os.environ.get("TEST_REDIS_URL", "redis://localhost:7000")


@pytest.fixture
Expand All @@ -39,4 +39,4 @@ def redis_cluster_url() -> str:
:return: URL string.
"""
return os.environ.get("TEST_REDIS_CLUSTER_URL", "redis://localhost:7000")
return os.environ.get("TEST_REDIS_CLUSTER_URL", "redis://localhost:7001")

0 comments on commit ae672c5

Please sign in to comment.