diff options
author | James Brown <jbrown@easypost.com> | 2016-04-11 16:52:35 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2016-04-24 16:20:22 -0700 |
commit | 434802dfa17f8c9d6b17b02d12bf0f7bee6240cd (patch) | |
tree | 9eced0688e60bb9f16f28aa6a99676be2bc4e54d /test/fixtures.py | |
parent | a12be0af80a1c0903eb92566e75a63bcec988806 (diff) | |
download | kafka-python-434802dfa17f8c9d6b17b02d12bf0f7bee6240cd.tar.gz |
More thorough IPv6 support that uses getaddrinfo to resolve names
Fixes #641
Diffstat (limited to 'test/fixtures.py')
-rw-r--r-- | test/fixtures.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/fixtures.py b/test/fixtures.py index 826d037..654e636 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -9,7 +9,7 @@ import time import uuid from six.moves import urllib -from six.moves.urllib.parse import urlparse # pylint: disable=E0611,F0401 +from six.moves.urllib.parse import urlparse # pylint: disable=E0611,F0401 from test.service import ExternalService, SpawnedService from test.testutil import get_open_port @@ -193,7 +193,21 @@ class KafkaFixture(Fixture): else: if port is None: port = get_open_port() - host = "127.0.0.1" + # force IPv6 here because of a confusing point: + # + # - if the string "localhost" is passed, Kafka will *only* bind to the IPv4 address of localhost + # (127.0.0.1); however, kafka-python will attempt to connect on ::1 and fail + # + # - if the address literal 127.0.0.1 is passed, the metadata request during bootstrap will return + # the name "localhost" and we'll go back to the first case. This is odd! + # + # Ideally, Kafka would bind to all loopback addresses when we tell it to listen on "localhost" the + # way it makes an IPv6 socket bound to both 0.0.0.0/0 and ::/0 when we tell it to bind to "" (that is + # to say, when we make a listener of PLAINTEXT://:port. + # + # Note that even though we specify the bind host in bracket notation, Kafka responds to the bootstrap + # metadata request without square brackets later. + host = "[::1]" fixture = KafkaFixture(host, port, broker_id, zk_host, zk_port, zk_chroot, transport=transport, |