diff --git a/django_elasticache/cluster_utils.py b/django_elasticache/cluster_utils.py index 9c7dc1e..21b4f89 100644 --- a/django_elasticache/cluster_utils.py +++ b/django_elasticache/cluster_utils.py @@ -32,7 +32,7 @@ def get_cluster_info(host, port): client.write(b'version\n') res = client.read_until(b'\r\n').strip() version_list = res.split(b' ') - if len(version_list) != 2 or version_list[0] != b'VERSION': + if not len(version_list) in [2, 3] or version_list[0] != b'VERSION': raise WrongProtocolData('version', res) version = version_list[1] if StrictVersion(smart_text(version)) >= StrictVersion('1.4.14'): diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 6776207..3bb21a2 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -18,6 +18,10 @@ b'CONFIG cluster 0 138\r\n1\nhost|ip|port host||port\n\r\nEND\r\n', ] +TEST_PROTOCOL_3 = [ + b'VERSION 1.4.14 (Ubuntu)', + b'CONFIG cluster 0 138\r\n1\nhost|ip|port host||port\n\r\nEND\r\n', +] @patch('django_elasticache.cluster_utils.Telnet') def test_happy_path(Telnet): @@ -54,3 +58,20 @@ def test_prev_versions(Telnet): call(b'version\n'), call(b'get AmazonElastiCache:cluster\n'), ]) + + +@patch('django_elasticache.cluster_utils.Telnet') +def test_ubuntu_protocol(Telnet): + client = Telnet.return_value + client.read_until.side_effect = TEST_PROTOCOL_3 + + try: + get_cluster_info('', 0) + except WrongProtocolData: + raise AssertionError('Raised WrongProtocolData with Ubuntu version.') + + client.write.assert_has_calls([ + call(b'version\n'), + call(b'config get cluster\n'), + ]) +