diff options
author | Tim Evens <tievens@cisco.com> | 2016-03-30 15:32:05 -0700 |
---|---|---|
committer | Tim Evens <tievens@cisco.com> | 2016-03-30 15:32:25 -0700 |
commit | 0f78d57c604e864fab51f7cfb8fa69c9c4e623c7 (patch) | |
tree | 649c0953a56f39719761751901da5da11b9589f0 /test/test_conn.py | |
parent | c6c862ad29ec5d0ae61d635c2020fb925b405c44 (diff) | |
download | kafka-python-0f78d57c604e864fab51f7cfb8fa69c9c4e623c7.tar.gz |
Kafka IPv6 Support.
IPv6 address without port can be defined as the IPv6 address. If the address
is a hostname or if a port is included, then the address MUST be wrapped
in brackets [] (E.g. [somehost]:1234 or [fd00:1001::2]:1234).
Diffstat (limited to 'test/test_conn.py')
-rw-r--r-- | test/test_conn.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/test/test_conn.py b/test/test_conn.py index 684ffe5..f0ef8fb 100644 --- a/test/test_conn.py +++ b/test/test_conn.py @@ -51,21 +51,37 @@ class ConnTest(unittest.TestCase): results = collect_hosts(hosts) self.assertEqual(set(results), set([ - ('localhost', 1234), - ('localhost', 9092), + ('localhost', 1234, socket.AF_INET), + ('localhost', 9092, socket.AF_INET), + ])) + + def test_collect_hosts__ipv6(self): + hosts = "[localhost]:1234,[2001:1000:2000::1],[2001:1000:2000::1]:1234" + results = collect_hosts(hosts) + + self.assertEqual(set(results), set([ + ('localhost', 1234, socket.AF_INET6), + ('2001:1000:2000::1', 9092, socket.AF_INET6), + ('2001:1000:2000::1', 1234, socket.AF_INET6), ])) def test_collect_hosts__string_list(self): hosts = [ 'localhost:1234', 'localhost', + '[localhost]', + '2001::1', + '[2001::1]:1234', ] results = collect_hosts(hosts) self.assertEqual(set(results), set([ - ('localhost', 1234), - ('localhost', 9092), + ('localhost', 1234, socket.AF_INET), + ('localhost', 9092, socket.AF_INET), + ('localhost', 9092, socket.AF_INET6), + ('2001::1', 9092, socket.AF_INET6), + ('2001::1', 1234, socket.AF_INET6), ])) def test_collect_hosts__with_spaces(self): @@ -73,10 +89,11 @@ class ConnTest(unittest.TestCase): results = collect_hosts(hosts) self.assertEqual(set(results), set([ - ('localhost', 1234), - ('localhost', 9092), + ('localhost', 1234, socket.AF_INET), + ('localhost', 9092, socket.AF_INET), ])) + def test_send(self): self.conn.send(self.config['request_id'], self.config['payload']) self.conn._sock.sendall.assert_called_with(self.config['payload']) |