Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_ftplib timeouts #62992

Closed
pitrou opened this issue Aug 20, 2013 · 14 comments
Closed

test_ftplib timeouts #62992

pitrou opened this issue Aug 20, 2013 · 14 comments
Labels
easy tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Aug 20, 2013

BPO 18792
Nosy @gpshead, @pitrou, @giampaolo
Files
  • support_host.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-08-21.22:59:07.352>
    created_at = <Date 2013-08-20.21:01:29.186>
    labels = ['easy', 'type-bug', 'tests']
    title = 'test_ftplib timeouts'
    updated_at = <Date 2017-02-24.01:35:26.802>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2017-02-24.01:35:26.802>
    actor = 'gregory.p.smith'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-08-21.22:59:07.352>
    closer = 'pitrou'
    components = ['Tests']
    creation = <Date 2013-08-20.21:01:29.186>
    creator = 'pitrou'
    dependencies = []
    files = ['31395']
    hgrepos = []
    issue_num = 18792
    keywords = ['patch', 'easy']
    message_count = 14.0
    messages = ['195717', '195750', '195752', '195754', '195766', '195770', '195779', '195806', '195831', '195833', '195834', '195835', '288497', '288499']
    nosy_count = 5.0
    nosy_names = ['gregory.p.smith', 'pitrou', 'giampaolo.rodola', 'neologix', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18792'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 20, 2013

    Some ftplib tests sometimes time out. Seem they seem to try to connect to "localhost" (rather than "127.0.0.1"), I was wondering if this could be a DNS issue and if we should resolve "localhost" in advance like Charles-François did for some other tests (or simply hardcode "127.0.0.1", actually).

    http://buildbot.python.org/all/builders/x86%20Windows7%203.x/builds/7060/steps/test/logs/stdio

    (example:

    ======================================================================
    ERROR: testTimeoutDefault (test.test_ftplib.TestTimeouts)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_ftplib.py", line 953, in testTimeoutDefault
        ftp = ftplib.FTP("localhost")
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\ftplib.py", line 115, in __init__
        self.connect(host)
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\ftplib.py", line 150, in connect
        source_address=self.source_address)
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\socket.py", line 454, in create_connection
        raise err
      File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\socket.py", line 445, in create_connection
        sock.connect(sa)
    socket.timeout: timed out

    )

    @pitrou pitrou added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Aug 20, 2013
    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Aug 21, 2013

    Some ftplib tests sometimes time out. Seem they seem to try to connect to "localhost" (rather than "127.0.0.1"), I was wondering if this could be a DNS issue and if we should resolve "localhost" in advance like Charles-François did for some other tests (or simply hardcode "127.0.0.1", actually).

    If it only happens on Windows >= 7 buildbots, then it's likely a
    consequence of this:
    http://serverfault.com/questions/4689/windows-7-localhost-name-resolution-is-handled-within-dns-itself-why

    Apparently, since Windows 7, "localhost" doesn't appear in the hosts
    file anymore: so, depending on your DNS resolver settings, this could
    perfectly explain such timeouts (assuming it's not a firewall issue).

    Hard-cording 127.0.0.1 for this test should be OK, because the server
    setup explicitly binds an AF_INET socket. We'll probably have to check
    the rest of the test suite for similar issues.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 21, 2013

    Hard-cording 127.0.0.1 for this test should be OK, because the server
    setup explicitly binds an AF_INET socket. We'll probably have to check
    the rest of the test suite for similar issues.

    Ok, let's do it!

    @pitrou pitrou added the easy label Aug 21, 2013
    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 21, 2013

    Here is a patch for default.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Aug 21, 2013

    Changing support.HOST from 'localhost' to '127.0.0.1' means that on dual-stack
    hosts (I don't think the test suite would run on IPv6-only hosts anyway), the
    tests will now always use IPv4, whereas they are currently using either IPv6 or
    IPv4 addresses depending on the host's name resolution settings.
    For example, on a RHEL6 box:

    >>> socket.getaddrinfo('localhost', 0)
    [(10, 1, 6, '', ('::1', 0, 0, 0)), (10, 2, 17, '', ('::1', 0, 0, 0)),
    (10, 3, 0, '', ('::1', 0, 0, 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2,
    2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))]

    So on this host, 'localhost' resolves to '::1'. I think it would be
    better to have support.HOST set to socket.getaddrinfo('localhost', 0)[0][4][0]
    (sic), so that the test will use the preferred protocol on the target host, and
    also that IPv6 is also tested in tests which don't explicitely use
    '::1'. But this
    means that we should have an support.HOSTv4 for tests that explicitly rely on
    IPv4, e.g. test_ftplib.

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 21, 2013

    Changing support.HOST from 'localhost' to '127.0.0.1' means that on
    dual-stack
    hosts (I don't think the test suite would run on IPv6-only hosts
    anyway), the
    tests will now always use IPv4, whereas they are currently using
    either IPv6 or
    IPv4 addresses depending on the host's name resolution settings.

    That would only be true if the server we are contacting happens to
    listen on both IPv6 and IPv4, right? I don't think we have such a
    situation in the test suite. Clients can use create_connection()
    for transparent support of IPv6 and IPv4, but servers have to choose
    a family when creating their socket.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Aug 21, 2013

    That would only be true if the server we are contacting happens to
    listen on both IPv6 and IPv4, right? I don't think we have such a
    situation in the test suite.

    Ah, I thought some code was using getaddrinfo() to select an arbitrary
    bind() address for localhost.

    That's OK then.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Aug 21, 2013

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 21, 2013

    New changeset 085ba7d85eb2 by Antoine Pitrou in branch 'default':
    Issue bpo-18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as possible, since "localhost" goes through a DNS lookup under recent Windows versions.
    http://hg.python.org/cpython/rev/085ba7d85eb2

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 21, 2013

    New changeset 7728b073c77c by Antoine Pitrou in branch '3.3':
    Issue bpo-18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as possible, since "localhost" goes through a DNS lookup under recent Windows versions.
    http://hg.python.org/cpython/rev/7728b073c77c

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 21, 2013

    New changeset 48de8df194d9 by Antoine Pitrou in branch '2.7':
    Issue bpo-18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as possible, since "localhost" goes through a DNS lookup under recent Windows versions.
    http://hg.python.org/cpython/rev/48de8df194d9

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 21, 2013

    Done, thanks :)

    @pitrou pitrou closed this as completed Aug 21, 2013
    @gpshead
    Copy link
    Member

    gpshead commented Feb 24, 2017

    FYI - hardcoding these addresses is now causing me problems as I try to get our test suite passing on IPv6 only hosts. "localhost" is correct.

    IMNSHO if for some reason a system cannot resolve "localhost" into a correct address, it should be banned from running any form of networking related test. :/

    I should not have to write messy conditional code to try and determine which type of socket I will likely need to bind to to determine which format of IP address string I need to supply as the localhost bind address. That is backwards!

    @gpshead
    Copy link
    Member

    gpshead commented Feb 24, 2017

    https://bugs.python.org/issue29639 opened to track undoing this when appropriate.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants