Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Sentinel discovery fix #380

Merged
merged 2 commits into from
Feb 15, 2018
Merged
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
6 changes: 3 additions & 3 deletions aioredis/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ def _drop_closed(self):
async def _fill_free(self, *, override_min):
# drop closed connections first
self._drop_closed()
address = self._address
# address = self._address
while self.size < self.minsize:
self._acquiring += 1
try:
conn = await self._create_new_connection(address)
conn = await self._create_new_connection(self._address)
# check the healthy of that connection, if
# something went wrong just trigger the Exception
await conn.execute('ping')
Expand All @@ -400,7 +400,7 @@ async def _fill_free(self, *, override_min):
while not self._pool and self.size < self.maxsize:
self._acquiring += 1
try:
conn = await self._create_new_connection(address)
conn = await self._create_new_connection(self._address)
self._pool.append(conn)
finally:
self._acquiring -= 1
Expand Down
20 changes: 20 additions & 0 deletions tests/sentinel_commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from aioredis import RedisError, ReplyError, PoolClosedError
from aioredis.errors import MasterReplyError
from aioredis.sentinel.commands import RedisSentinel
from aioredis.abc import AbcPool

pytestmark = pytest.redis_version(2, 8, 12, reason="Sentinel v2 required")
if sys.platform == 'win32':
Expand Down Expand Up @@ -286,3 +287,22 @@ async def test_monitor(redis_sentinel, start_server, loop, unused_port):

_, port = await redis_sentinel.master_address('master-to-monitor')
assert port == m1.tcp_address.port


@pytest.mark.run_loop(timeout=5)
async def test_sentinel_master_pool_size(sentinel, create_sentinel):
redis_s = await create_sentinel([sentinel.tcp_address], timeout=1,
minsize=10, maxsize=10)
master = redis_s.master_for('master-no-fail')
assert isinstance(master.connection, AbcPool)
assert master.connection.size == 0

with pytest.logs('aioredis.sentinel', 'DEBUG') as cm:
assert await master.ping()
assert len(cm.output) == 1
assert cm.output == [
"DEBUG:aioredis.sentinel:Discoverred new address {}"
" for master-no-fail".format(master.address),
]
assert master.connection.size == 10
assert master.connection.freesize == 10