diff options
author | Peter Lithammer <peter.lithammer@gmail.com> | 2019-02-20 18:35:36 +0100 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2019-02-20 23:35:36 +0600 |
commit | f49188d2f7dc910da973f3c5276863fa8993c1d3 (patch) | |
tree | 90eb70e561ad992256e7d7cfd0b88f1e43546b1f | |
parent | 2415a647765f98fba3eaa41ea8a361837f8bd530 (diff) | |
download | kombu-f49188d2f7dc910da973f3c5276863fa8993c1d3.tar.gz |
Use "_parse_url()" util to parse Sentinel master URL (#1009)
Fixes #1007
-rw-r--r-- | kombu/transport/redis.py | 5 | ||||
-rw-r--r-- | t/unit/transport/test_redis.py | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index 6831f510..af44cdb8 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -1102,8 +1102,9 @@ class SentinelChannel(Channel): additional_params.pop('port', None) connection_list = [] for url in self.connection.client.alt: - if url and 'sentinel://' in url: - connection_list.append(url.split('/')[2].split(':')) + url = _parse_url(url) + if url.scheme == 'sentinel': + connection_list.append([url.hostname, str(url.port)]) sentinel_inst = sentinel.Sentinel( connection_list, min_other_sentinels=getattr(self, 'min_other_sentinels', 0), diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py index 55b2dc09..4d45e8fc 100644 --- a/t/unit/transport/test_redis.py +++ b/t/unit/transport/test_redis.py @@ -1344,7 +1344,10 @@ class test_RedisSentinel: def test_getting_master_from_sentinel(self): with patch('redis.sentinel.Sentinel') as patched: connection = Connection( - 'sentinel://localhost:65534/;sentinel://localhost:65535/;sentinel://localhost:65536/;', # noqa: E501 + 'sentinel://localhost:65532/;' + 'sentinel://user@localhost:65533/;' + 'sentinel://:password@localhost:65534/;' + 'sentinel://user:password@localhost:65535/;', transport_options={ 'master_name': 'not_important', }, @@ -1353,9 +1356,10 @@ class test_RedisSentinel: connection.channel() patched.assert_called_once_with( [ + [u'localhost', u'65532'], + [u'localhost', u'65533'], [u'localhost', u'65534'], [u'localhost', u'65535'], - [u'localhost', u'65536'] ], connection_class=mock.ANY, db=0, max_connections=10, min_other_sentinels=0, password=None, sentinel_kwargs=None, |