Skip to content

Commit

Permalink
Test updates for sentinel 7.0
Browse files Browse the repository at this point in the history
the bitnami image for sentinel 7.0 has a config error
with a custom master name
  • Loading branch information
alisaifee committed Jun 6, 2022
1 parent b580201 commit 042e2e9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ services:
image: 'bitnami/redis-sentinel:${LIMITS_REDIS_SENTINEL_SERVER_VERSION:-latest}'
depends_on: [redis-sentinel-slave]
environment:
- REDIS_MASTER_SET=localhost-redis-sentinel
- REDIS_MASTER_HOST=${HOST_IP}
- REDIS_MASTER_PORT_NUMBER=6380
ports:
Expand All @@ -55,7 +54,6 @@ services:
image: 'bitnami/redis-sentinel:${LIMITS_REDIS_SENTINEL_SERVER_VERSION:-latest}'
depends_on: [redis-sentinel-slave-auth]
environment:
- REDIS_MASTER_SET=localhost-redis-sentinel
- REDIS_MASTER_HOST=${HOST_IP}
- REDIS_MASTER_PASSWORD=sekret
- REDIS_MASTER_PORT_NUMBER=6382
Expand Down
4 changes: 2 additions & 2 deletions tests/aio/storage/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class TestAsyncRedisSentinelStorage(AsyncSharedRedisTests):
@pytest.fixture(autouse=True)
def setup(self, redis_sentinel):
self.storage_url = "redis+sentinel://localhost:26379"
self.service_name = "localhost-redis-sentinel"
self.service_name = "mymaster"
self.storage = RedisSentinelStorage(
f"async+{self.storage_url}", service_name=self.service_name
)
Expand Down Expand Up @@ -211,7 +211,7 @@ async def test_auth_connect(
):
storage_url = (
f"async+redis+sentinel://{username}:{sentinel_password}@localhost:36379/"
"localhost-redis-sentinel"
"mymaster"
)
args = {}
if password:
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def check_sentinel_ready(host, port):
try:
return (
redis.sentinel.Sentinel([(host, port)])
.master_for("localhost-redis-sentinel")
.master_for("mymaster")
.ping()
)
except: # noqa
Expand All @@ -37,7 +37,7 @@ def check_sentinel_auth_ready(host, port):
sentinel_kwargs={"password": "sekret"},
password="sekret",
)
.master_for("localhost-redis-sentinel")
.master_for("mymaster")
.ping()
)
except: # noqa
Expand Down Expand Up @@ -229,14 +229,14 @@ def redis_cluster(redis_cluster_client):

@pytest.fixture
def redis_sentinel(redis_sentinel_client):
redis_sentinel_client.master_for("localhost-redis-sentinel").flushall()
redis_sentinel_client.master_for("mymaster").flushall()

return redis_sentinel


@pytest.fixture
def redis_sentinel_auth(redis_sentinel_auth_client):
redis_sentinel_auth_client.master_for("localhost-redis-sentinel").flushall()
redis_sentinel_auth_client.master_for("mymaster").flushall()

return redis_sentinel_auth_client

Expand Down
4 changes: 2 additions & 2 deletions tests/storage/test_redis_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestRedisSentinelStorage(SharedRedisTests):
@pytest.fixture(autouse=True)
def setup(self, redis_sentinel):
self.storage_url = "redis+sentinel://localhost:26379"
self.service_name = "localhost-redis-sentinel"
self.service_name = "mymaster"
self.storage = RedisSentinelStorage(
self.storage_url, service_name=self.service_name
)
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_auth_connect(
redis_sentinel_auth.master_for(self.service_name).flushall()
storage_url = (
f"redis+sentinel://{username}:{sentinel_password}@localhost:36379/"
"localhost-redis-sentinel"
"mymaster"
)
args = {}
if password:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ class TestBaseStorage:
),
pytest.param(
"redis+sentinel://localhost:26379",
{"service_name": "localhost-redis-sentinel"},
{"service_name": "mymaster"},
RedisSentinelStorage,
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
),
pytest.param(
"redis+sentinel://localhost:26379/localhost-redis-sentinel",
"redis+sentinel://localhost:26379/mymaster",
{},
RedisSentinelStorage,
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
),
pytest.param(
"redis+sentinel://:sekret@localhost:26379/localhost-redis-sentinel",
"redis+sentinel://:sekret@localhost:26379/mymaster",
{"password": "sekret"},
RedisSentinelStorage,
pytest.lazy_fixture("redis_sentinel_auth"),
Expand Down Expand Up @@ -152,18 +152,18 @@ def test_invalid_storage_string(self, uri, args):
),
pytest.param(
"redis+sentinel://localhost:26379",
{"service_name": "localhost-redis-sentinel"},
{"service_name": "mymaster"},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
),
pytest.param(
"redis+sentinel://localhost:26379/localhost-redis-sentinel",
"redis+sentinel://localhost:26379/mymaster",
{},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
),
pytest.param(
"redis+sentinel://:sekret@localhost:36379/localhost-redis-sentinel",
"redis+sentinel://:sekret@localhost:36379/mymaster",
{"password": "sekret"},
pytest.lazy_fixture("redis_sentinel_auth"),
marks=pytest.mark.redis_sentinel,
Expand Down
8 changes: 4 additions & 4 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def async_window(delay_end: float, delay: Optional[float] = None):
marks=pytest.mark.redis_cluster,
),
pytest.param(
"redis+sentinel://localhost:26379/localhost-redis-sentinel",
"redis+sentinel://localhost:26379/mymaster",
{"use_replicas": False},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
Expand Down Expand Up @@ -108,7 +108,7 @@ async def async_window(delay_end: float, delay: Optional[float] = None):
marks=pytest.mark.redis_cluster,
),
pytest.param(
"redis+sentinel://localhost:26379/localhost-redis-sentinel",
"redis+sentinel://localhost:26379/mymaster",
{"use_replicas": False},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
Expand Down Expand Up @@ -151,7 +151,7 @@ async def async_window(delay_end: float, delay: Optional[float] = None):
marks=pytest.mark.redis_cluster,
),
pytest.param(
"async+redis+sentinel://localhost:26379/localhost-redis-sentinel",
"async+redis+sentinel://localhost:26379/mymaster",
{"use_replicas": False},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
Expand Down Expand Up @@ -182,7 +182,7 @@ async def async_window(delay_end: float, delay: Optional[float] = None):
marks=pytest.mark.redis_cluster,
),
pytest.param(
"async+redis+sentinel://localhost:26379/localhost-redis-sentinel",
"async+redis+sentinel://localhost:26379/mymaster",
{"use_replicas": False},
pytest.lazy_fixture("redis_sentinel"),
marks=pytest.mark.redis_sentinel,
Expand Down

0 comments on commit 042e2e9

Please sign in to comment.