mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 10:25:17 +00:00
Change resolver again to have better behavior
This commit is contained in:
parent
24ab17905d
commit
d58558e56d
@ -333,7 +333,7 @@ class AddressWizard:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not address_str:
|
if not address_str:
|
||||||
raise RuntimeError("Mandatory option was not specified: address")
|
raise RuntimeError("Mandatory option was not specified: address")
|
||||||
|
|
||||||
logging.debug("Trying to resolve address string: %s", address_str)
|
logging.debug("Trying to resolve address string: %s", address_str)
|
||||||
|
|
||||||
@ -360,6 +360,7 @@ class AddressWizard:
|
|||||||
port = int(parts[1])
|
port = int(parts[1])
|
||||||
|
|
||||||
resolved = self.lookup_fn(address_str, port)
|
resolved = self.lookup_fn(address_str, port)
|
||||||
|
logging.debug("Lookup result: %s", resolved)
|
||||||
|
|
||||||
for (family, socktype, proto, canonname, sockaddr) in resolved:
|
for (family, socktype, proto, canonname, sockaddr) in resolved:
|
||||||
is_v6 = family == socket.AF_INET6
|
is_v6 = family == socket.AF_INET6
|
||||||
@ -373,25 +374,24 @@ class AddressWizard:
|
|||||||
|
|
||||||
if do_test:
|
if do_test:
|
||||||
try:
|
try:
|
||||||
self.__test(parsed_ip, port)
|
self.__test(family, sockaddr)
|
||||||
except RuntimeError, exc:
|
except RuntimeError, exc:
|
||||||
logging.warn("Failed TCP connection test using [%s]:%s", parsed_ip, port)
|
logging.warn("Failed TCP connection test using [%s]:%s", parsed_ip, port)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
logging.info("Successfully resolved address into [%s]:%s", parsed_ip, port)
|
||||||
return is_v6, parsed_ip, int(port), address_str
|
return is_v6, parsed_ip, int(port), address_str
|
||||||
|
|
||||||
msg = "All connection attempts failed for %s, use phantom.connection_test=0 to disable it"
|
msg = "All connection attempts failed for %s, use phantom.connection_test=0 to disable it"
|
||||||
raise RuntimeError(msg % address_str)
|
raise RuntimeError(msg % address_str)
|
||||||
|
|
||||||
def __test(self, resolved_ip, port):
|
def __test(self, af, sa):
|
||||||
lookup = socket.getaddrinfo(resolved_ip, port, socket.AF_UNSPEC, socket.SOCK_STREAM)
|
test_sock = self.socket_class(af)
|
||||||
af, socktype, proto, canonname, sa = lookup.pop(0)
|
|
||||||
test_sock = self.socket_class(af, socktype, proto)
|
|
||||||
try:
|
try:
|
||||||
test_sock.settimeout(5)
|
test_sock.settimeout(5)
|
||||||
test_sock.connect(sa)
|
test_sock.connect(sa)
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
msg = "TCP Connection test failed for %s:%s, use phantom.connection_test=0 to disable it"
|
msg = "TCP Connection test failed for [%s]:%s, use phantom.connection_test=0 to disable it"
|
||||||
raise RuntimeError(msg % (resolved_ip, port))
|
raise RuntimeError(msg % (sa[0], sa[1]))
|
||||||
finally:
|
finally:
|
||||||
test_sock.close()
|
test_sock.close()
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
yandex-load-tank-base (1.6.7) precise; urgency=medium
|
||||||
|
|
||||||
|
* fix resolver for multi-address server
|
||||||
|
|
||||||
|
-- Andrey Pohilko (undera) <undera@yandex-team.ru> Fri, 04 Jul 2014 18:00:02 +0400
|
||||||
|
|
||||||
yandex-load-tank-base (1.6.6) precise; urgency=medium
|
yandex-load-tank-base (1.6.6) precise; urgency=medium
|
||||||
|
|
||||||
* fix wrong port parsing
|
* fix wrong port parsing
|
||||||
|
Loading…
Reference in New Issue
Block a user