Skip to content
Closed
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
2 changes: 1 addition & 1 deletion django_elasticache/cluster_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
21 changes: 21 additions & 0 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'),
])