Commit 4878481a authored by Jason Madden's avatar Jason Madden Committed by GitHub

Dns test love (#908)

* Resolve the DNS test differences.

Also document some of the known ways that c-ares is different as a
result of these test fixes.

Fixes #774.

* spurious assert statement.

* disable the ipv6 dual stack test even without ares, it has the same issue on travis ci. must have a different resolver configuration than I do.

* more dns tweaks for travis

* One small failure on travis.
parent c15b77d3
......@@ -7,7 +7,9 @@
1.2b1 (unreleased)
==================
- TBD
- The c-ares DNS resolver ignores bad flags to getnameinfo, like the
system resolver does. Discovered when cleaning up the DNS resolver
tests to produce more reliable results. See :issue:`774`.
1.2a2 (Dec 9, 2017)
===================
......
......@@ -446,4 +446,9 @@ cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresCh
cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
def getnameinfo(self, object callback, tuple sockaddr, int flags):
return self._getnameinfo(callback, sockaddr, _convert_cares_flags(flags))
try:
flags = _convert_cares_flags(flags)
except gaierror:
# The stdlib just ignores bad flags
flags = 0
return self._getnameinfo(callback, sockaddr, flags)
......@@ -31,6 +31,25 @@ class Resolver(object):
the threaded resolver). However, because it does not use threads,
it may scale better for applications that make many lookups.
There are some known differences from the system resolver:
- ``gethostbyname_ex`` and ``gethostbyaddr`` may return different
for the ``aliaslist`` tuple member. (Sometimes the same,
sometimes in a different order, sometimes a different alias
altogether.)
- ``gethostbyname_ex`` may return the ``ipaddrlist`` in a different order.
- ``getaddrinfo`` does not return ``SOCK_RAW`` results.
- ``getaddrinfo`` may return results in a different order.
- Handling of ``.local`` (mDNS) names may be different, even if they are listed in
the hosts file.
- c-ares will not resolve ``broadcasthost``, even if listed in the hosts file.
- This implementation may raise ``gaierror(4)`` where the system implementation would raise
``herror(1)``.
- The results for ``localhost`` may be different. In particular, some system
resolvers will return more results from ``getaddrinfo`` than c-ares does,
such as SOCK_DGRAM results, and c-ares may report more ips on a multi-homed
host.
.. caution:: This module is considered extremely experimental on PyPy, and
due to its implementation in cython, it may be slower. It may also lead to
interpreter crashes.
......
......@@ -36,22 +36,6 @@ FAILING_TESTS = [
]
if os.environ.get('GEVENT_RESOLVER') == 'ares' or LEAKTEST:
# XXX fix this
FAILING_TESTS += [
'FLAKY test__socket_dns.py',
'FLAKY test__socket_dns6.py',
]
else:
FAILING_TESTS += [
# A number of the host names hardcoded have multiple, load
# balanced DNS entries. Therefore, multiple sequential calls
# of the resolution function, whether gevent or stdlib, can
# return non-equal results, possibly dependent on the host
# dns configuration
'FLAKY test__socket_dns6.py',
]
if sys.platform == 'win32':
# other Windows-related issues (need investigating)
FAILING_TESTS += [
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import greentest
import socket
from test__socket_dns import TestCase, add
from test__socket_dns import TestCase, add, RESOLVER_IS_ARES
class Test6(TestCase):
......@@ -26,15 +26,34 @@ class Test6(TestCase):
class Test6_google(Test6):
host = 'ipv6.google.com'
def _normalize_result_getnameinfo(self, result):
if greentest.RUNNING_ON_CI and RESOLVER_IS_ARES:
# Disabled, there are multiple possibilities
# and we can get different ones, rarely.
return ()
return result
class Test6_ds(Test6):
add(Test6, Test6.host)
add(Test6_google, Test6_google.host)
if not greentest.RUNNING_ON_CI:
# We can't control the DNS servers we use there
# for the system. This works best with the google DNS servers
# The getnameinfo test can fail on CI
class Test6_ds(Test6):
# host that has both A and AAAA records
host = 'ds.test-ipv6.com'
def _normalize_result_gethostbyaddr(self, result):
# This test is effectively disabled. There are multiple address
# that resolve and which ones you get depend on the settings
# of the system and ares. They don't match exactly.
return ()
add(Test6, Test6.host)
add(Test6_google, Test6_google.host)
add(Test6_ds, Test6_ds.host)
_normalize_result_gethostbyname = _normalize_result_gethostbyaddr
add(Test6_ds, Test6_ds.host)
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment