Issue #13864 has been reported by vo.x (Vit Ondruch).

----------------------------------------
Bug #13864: Rinda multicast test failures due to missing default route
https://bugs.ruby-lang.org/issues/13864

* Author: vo.x (Vit Ondruch)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Trying to build Ruby for Fedora, we are using tool called mock [1]. This tools allows to execute the build in container, using systemd-nspawn on background [2] and this in turn allows the container to be isolated from network [3]. However, in this setup, there are some Rinda multicast test failures:

~~~
$ sudo systemd-nspawn '-D' '/var/lib/mock/fedora-rawhide-x86_64/root' --private-network
Spawning container root on /var/lib/mock/fedora-rawhide-x86_64/root.
Press ^] three times within 1s to kill container.
-bash: cannot set terminal process group (-1): Inappropriate ioctl for device
-bash: no job control in this shell
-bash-4.4# su - mockbuild
-bash: cannot set terminal process group (1): Inappropriate ioctl for device
-bash: no job control in this shell
[mockbuild@root ~]$ cd /mnt/
[mockbuild@root mnt]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
[mockbuild@root ~]$ ip route
[mockbuild@root mnt]$  
Run options: 

# Running tests:

[ 1/39] Rinda::TestRingFinger#test_make_socket_ipv4_multicast = 0.00 s
  1) Error:
Rinda::TestRingFinger#test_make_socket_ipv4_multicast:
Errno::ENETUNREACH: Network is unreachable - connect(2) for 239.0.0.1:7647
    /usr/share/ruby/rinda/ring.rb:431:in `connect'
    /usr/share/ruby/rinda/ring.rb:431:in `make_socket'
    test/rinda/test_rinda.rb:804:in `test_make_socket_ipv4_multicast'

[ 2/39] Rinda::TestRingFinger#test_make_socket_ipv4_multicast_hops = 0.00 s
  2) Error:
Rinda::TestRingFinger#test_make_socket_ipv4_multicast_hops:
Errno::ENETUNREACH: Network is unreachable - connect(2) for 239.0.0.1:7647
    /usr/share/ruby/rinda/ring.rb:431:in `connect'
    /usr/share/ruby/rinda/ring.rb:431:in `make_socket'
    test/rinda/test_rinda.rb:821:in `test_make_socket_ipv4_multicast_hops'

[ 8/39] Rinda::TestRingServer#test_make_socket_ipv4_multicast = 0.00 s     
  3) Error:
Rinda::TestRingServer#test_make_socket_ipv4_multicast:
Errno::ENODEV: No such device - setsockopt(2)
    /usr/share/ruby/rinda/ring.rb:154:in `setsockopt'
    /usr/share/ruby/rinda/ring.rb:154:in `make_socket'
    test/rinda/test_rinda.rb:647:in `test_make_socket_ipv4_multicast'

[11/39] Rinda::TestRingServer#test_ring_server_ipv4_multicast = 0.00 s
  4) Error:
Rinda::TestRingServer#test_ring_server_ipv4_multicast:
Errno::ENODEV: No such device - setsockopt(2)
    /usr/share/ruby/rinda/ring.rb:154:in `setsockopt'
    /usr/share/ruby/rinda/ring.rb:154:in `make_socket'
    /usr/share/ruby/rinda/ring.rb:108:in `block in initialize'
    /usr/share/ruby/rinda/ring.rb:106:in `each'
    /usr/share/ruby/rinda/ring.rb:106:in `initialize'
    test/rinda/test_rinda.rb:689:in `new'
    test/rinda/test_rinda.rb:689:in `test_ring_server_ipv4_multicast'

Leaked file descriptor: Rinda::TestRingServer#test_ring_server_ipv4_multicast: 10 : #<Socket:fd 10>
Closed file descriptor: Rinda::TestRingServer#test_ring_server_ipv6_multicast: 10
Finished tests in 0.977804s, 39.8853 tests/s, 266.9247 assertions/s.  
39 tests, 261 assertions, 0 failures, 4 errors, 4 skips

ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
~~~

As you can see from the output, there is only loopback device and no default route specified. If I added the default route via ```ip route add default via 127.0.0.1```, the tests would succeed.

Now, there are several possibilities to narrow this, not really sure which I should choose:

1. Just disable the tests in Fedora.
2. Add the default route.
3. It could be possible to detect this scenario and skip the tests either by the test suite or by the build script.
4. The Rinda::RingServer#make_socket actually allows to specify interface, so if that is explicitly specified to '127.0.0.1', the test could be made to pass, but Rinda::RingFinger#make_socket does not support this :/

I should also note, that it seems that systemd guys don't intend to add the default route while mock upstream considers the option to make it available [4], but this involves some hackery. So I thought I'll ask here ...



[1]: https://github.com/rpm-software-management/mock/
[2]: https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html
[3]: https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html#--private-network
[4]: https://github.com/rpm-software-management/mock/issues/113#issuecomment-325695971



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>