Commit Graph

1 Commits

Author SHA1 Message Date
Jarek Prokop
c05390bc53 Fix networking tests failining when only loopback network device is available.
When only a loopback device is available for networking, a few Rinda
tests that rely on multicast fail in addition to a TCP timeout case that
is trying to reach an IP 192.0.2.1 (TEST-NET-1 address block) to fail
on a timeout. However, localhost does not have a route to that address
space without further setup, so just rescuing ENETUNREACH is enough
here.

Similarly to the timeout case, multicast would have to be turned on for
loopback device but also a route added for the device.

These usually require root privileges that we do not have during
mockbuild, so skipping the tests is simpler alternative.

Account for when multicast is not properly setup on the networking device.
appends Errno:ENETUNREACH to existing timeout.

Multicast rescues also ENOBUFS and ENODEV,

Backport
89aa09afaf
94e79e4c2d

Example test cases showing classes of failures fixed:
~~~
  1) Failure:
TestSocket_TCPSocket#test_initialize_connect_timeout [/builddir/build/BUILD/ruby-3.0.7/test/socket/test_tcp.rb:73]:
[Errno::ETIMEDOUT] exception expected, not #<Errno::ENETUNREACH: Network is unreachable - connect(2) for "192.0.2.1" port 80>.

  2) Error:
Rinda::TestRingFinger#test_make_socket_ipv4_multicast:
Errno::ENETUNREACH: Network is unreachable - connect(2) for 239.0.0.1:7647
    /builddir/build/BUILD/ruby-3.0.7/lib/rinda/ring.rb:434:in `connect'
    /builddir/build/BUILD/ruby-3.0.7/lib/rinda/ring.rb:434:in `make_socket'
    /builddir/build/BUILD/ruby-3.0.7/test/rinda/test_rinda.rb:863:in `test_make_socket_ipv4_multicast'

  4) Error:
Rinda::TestRingServer#test_make_socket_ipv4_multicast:
Errno::ENODEV: No such device - setsockopt(2)
    /builddir/build/BUILD/ruby-3.0.7/lib/rinda/ring.rb:152:in `setsockopt'
    /builddir/build/BUILD/ruby-3.0.7/lib/rinda/ring.rb:152:in `make_socket'
    /builddir/build/BUILD/ruby-3.0.7/test/rinda/test_rinda.rb:694:in `test_make_socket_ipv4_multicast'
~~~

Failing test names:
TestSocket_TCPSocket#test_initialize_connect_timeout
Rinda::TestRingFinger#test_make_socket_ipv4_multicast
Rinda::TestRingFinger#test_make_socket_ipv4_multicast_hops
Rinda::TestRingServer#test_make_socket_ipv4_multicast
Rinda::TestRingServer#test_ring_server_ipv4_multicast

Resolves: RHEL-192226
2026-08-11 11:30:11 +02:00