Network operation (socket.getfqdn) takes too long on macos-latest
- Dominant language
- Python
- Stars
- 161
- Forks
- 141
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 138
Description
It _appears_ that the reason quite a few of the tests in tests/ert/unit_tests/services/test_storage_service.py takes very long time (and some fail) is that the socket.getfqdn() command takes long time (or perhaps times out?).
This is used quite a few places, and some of the certificate and connection tests touches this.
Perhaps relevant: https://github.com/actions/runner-images/issues/8649
NOTE: It might even "fail" after eg. 30 seconds? Should be investigated.
How to reproduce: Make a simple unit test, and run it on the runner (eg. on private fork or by running the mac runner on PR).
```
import socket
from ert.services._storage_main import _get_host_list
from ert.shared import net_utils
def test_get_host_list():
hosts = _get_host_list()
assert len(hosts) > 0
print(hosts)
def test_socket_gethostname():
print(socket.gethostname())
def test_socket_getfqdn():
print(socket.getfqdn())
def test_get_machine_name():
print(net_utils.get_machine_name())
```
When running this (ish) on ubuntu-latest and macos-latest, with durations and -svv option to pytest:
Ubuntu (looks fine):
```
tests/ert/fqdn_test/test_fqdn.py::test_get_host_list Host list ['runnervmf4ws1.n2uxqdsfspmehakds0m4kccnuc.phxx.internal.cloudapp.net', 'runnervmf4ws1']
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname gethostname runnervmf4ws1
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn getfqdn runnervmf4ws1.n2uxqdsfspmehakds0m4kccnuc.phxx.internal.cloudapp.net
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name net_utils runnervmf4ws1
PASSED
============================== slowest durations ===============================
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
============================== 4 passed in 0.90s ===============================
```
Macos (slow and different):
```
tests/ert/fqdn_test/test_fqdn.py::test_get_host_list Host list ['localhost', 'Mac-1757918302460.local']
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname gethostname Mac-1757918302460.local
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn getfqdn Mac-1757918302460.local
PASSED
tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name net_utils localhost
PASSED
============================== slowest durations ===============================
70.03s call tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
35.02s call tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.01s setup tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
0.01s setup tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_get_host_list
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_get_machine_name
0.00s call tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
0.00s setup tests/ert/fqdn_test/test_fqdn.py::test_socket_getfqdn
0.00s teardown tests/ert/fqdn_test/test_fqdn.py::test_socket_gethostname
======================== 4 passed in 106.11s (0:01:46) =========================
```
Contributor guide
Research direction
Start with tests/ert/fqdn_test/test_fqdn.py and reproduce the timing difference on macos-latest using pytest durations and -svv. Trace the calls into ert/services/_storage_main.py and ert/shared/net_utils.py, then compare the socket operations on Ubuntu and macOS. Done means the cause is identified, the affected behavior is addressed, and regression coverage verifies the macOS path without the long delay.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python
- Domain
- networking, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100