Network operation (socket.getfqdn) takes too long on macos-latest
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) =========================
Fixed by #11822
Not going to fix this, too weird, and not very important
Reopen - since it WILL pop up again, and this may serve as a reminder? We have still some tests that run, slowly, and is because of this.
Can confirm that this is still an issue with macos 15.7.1 and python 3.12, 3.13. If anything even slower.
============================= slowest 10 durations =============================
140.07s call tests/ert/slow_mac_test.py::test_get_host_list
35.03s call tests/ert/slow_mac_test.py::test_socket_getfqdn
0.01s setup tests/ert/slow_mac_test.py::test_get_host_list
0.01s setup tests/ert/slow_mac_test.py::test_socket_gethostname
0.00s setup tests/ert/slow_mac_test.py::test_get_machine_name
0.00s call tests/ert/slow_mac_test.py::test_socket_gethostname
0.00s teardown tests/ert/slow_mac_test.py::test_socket_getfqdn
0.00s teardown tests/ert/slow_mac_test.py::test_get_host_list
0.00s teardown tests/ert/slow_mac_test.py::test_get_machine_name
0.00s setup tests/ert/slow_mac_test.py::test_socket_getfqdn
======================== 4 passed in 176.38s (0:02:56) =========================