python icon indicating copy to clipboard operation
python copied to clipboard

keepalive_test.py fails on macOS (TCP_KEEPIDLE, SO_KEEPALIVE readback)

Open ArfiArfath21 opened this issue 1 month ago • 0 comments

kubernetes/utils/keepalive_test.py fails on macOS: 3 of its 11 tests error before reaching any assertion about the code under test.

$ pytest kubernetes/utils/keepalive_test.py
FAILED ...::test_defaults_match_client_go      AttributeError: module 'socket' has no attribute 'TCP_KEEPIDLE'
FAILED ...::test_custom_timings                AttributeError: module 'socket' has no attribute 'TCP_KEEPIDLE'
FAILED ...::test_options_apply_to_a_socket     AttributeError (TCP_KEEPIDLE); after fixing that, AssertionError: 1 != 8

keepalive.py already handles this correctly (macOS spells the idle option TCP_KEEPALIVE), but the tests reference socket.TCP_KEEPIDLE directly, and test_options_apply_to_a_socket expects getsockopt(SO_KEEPALIVE) to return exactly 1 while macOS returns a non-zero flag (8).

The fix is test-only: resolve the idle option the same way keepalive.py does, skip when the platform has neither, and assert non-zero for the boolean option. I have it ready and will open a PR once I've signed the CLA.

Disclosure: I found this while running the test suite with the help of an AI assistant (Claude Code). Python 3.12, macOS, current master.

ArfiArfath21 avatar Oct 16 '26 18:10 ArfiArfath21