Skip to content

tests: localhost name lookup takes 1sec on Windows in github actions #1257

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

Closed
jku opened this issue Jan 11, 2021 · 1 comment
Closed

tests: localhost name lookup takes 1sec on Windows in github actions #1257

jku opened this issue Jan 11, 2021 · 1 comment
Labels

Comments

@jku
Copy link
Member

jku commented Jan 11, 2021

This was found in PR #1250: on windows (Github Actions) the lookup for localhost takes 1 second.

This is because:

  • Windows retries connect() with a timeout
  • the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
  • the test clients connect to "localhost"

This combination leads to every test first spending 1 second trying to connect to localhost on IPv6 (this fails because the server is only IPv4). Eventually connect() succeeds on IPv4.

I would be nice if we could have the test servers bind the port on both IPv4 and IPv6 but unfortunately socketserver.TCPServer does not seem to support IPv6 before 3.8. This works on later versions:

class DualServer(six.moves.socketserver.TCPServer):
    address_family = socket.AF_INET6

# this leads to serving on both INET4 and INET6
server = DualServer(('::', 0), SimpleHTTPRequestHandler)
server.serve_forever()

I think the correct choice at the moment is to just use "127.0.0.1" instead of "localhost" in the tests (clients) -- this should mean we don't waste time trying IPv6. Maybe Teodora wants to fix this there but I'm filing this so we don't lose track.

@jku jku added the testing label Jan 11, 2021
sechkova added a commit to sechkova/tuf that referenced this issue Jan 18, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Jan 22, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Jan 22, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Jan 22, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Feb 10, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Feb 16, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
sechkova added a commit to sechkova/tuf that referenced this issue Feb 23, 2021
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See theupdateframework#1257

Signed-off-by: Teodora Sechkova <[email protected]>
@jku
Copy link
Member Author

jku commented Mar 3, 2021

last windows builds are >2 minutes faster 👍 👍 thanks @sechkova

@jku jku closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant