Skip to content

Conversation

@stapelberg
Copy link
Contributor

Our CI environment intentionally does not offer IPv4 and does not
guarantee that all port numbers are available.
To make the tests work, I:

  • Replaced the IPv4 address 127.0.0.1 with the DNS name localhost,
    which resolves to either address family depending on availability.

  • Replaced string concatenation of addresses and ports with using
    net.JoinHostPort(), which also works for IPv6 addresses,
    such as the ::1 address that httptest will use in IPv6-only envs.

  • Replaced all port numbers with port 0, which will make the OS
    pick an available port automatically (in listen addresses).
    This also allows for running multiple instances of the tests.

Our CI environment intentionally does not offer IPv4 and does not
guarantee that all port numbers are available.
To make the tests work, I:

• Replaced the IPv4 address 127.0.0.1 with the DNS name localhost,
  which resolves to either address family depending on availability.

• Replaced string concatenation of addresses and ports with using
  net.JoinHostPort(), which also works for IPv6 addresses,
  such as the ::1 address that httptest will use in IPv6-only envs.

• Replaced all port numbers with port 0, which will make the OS
  pick an available port automatically (in listen addresses).
  This also allows for running multiple instances of the tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant