summaryrefslogtreecommitdiff
path: root/test/rinda
diff options
context:
space:
mode:
authorshirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 15:43:22 +0000
committershirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 15:43:22 +0000
commit93ed9f08ad9e9aa1aa44d83e6dc850721e1fd112 (patch)
treecea4e64116f5ced38ae921571c35bb5bd1053e12 /test/rinda
parent0cfa2e54a237069da4f1c8a1ccc92c05d2ab6983 (diff)
ring.rb: specify multicast interface
* lib/rinda/ring.rb (Rinda::RingServer#initialize): accept array arguments of address to specify multicast interface. * lib/rinda/ring.rb (Rinda::RingServer#make_socket): add optional arguments for multicast interface. * test/rinda/test_rinda.rb (TestRingFinger#test_ring_server_ipv4_multicast, TestRingFinger#test_ring_server_ipv6_multicast): add tests for above change. * test/rinda/test_rinda.rb (TestRingServer#test_make_socket_ipv4_multicast, TestRingServer#test_make_socket_ipv6_multicast): change bound interface address because multicast address is not allowed on Linux or Windows. [ruby-core:53692] [Bug #8159] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rinda')
-rw-r--r--test/rinda/test_rinda.rb42
1 files changed, 39 insertions, 3 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index 577eb1a..263dbfb 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -575,8 +575,8 @@ class TestRingServer < Test::Unit::TestCase
assert(v4mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool)
end
- assert_equal('239.0.0.1', v4mc.local_address.ip_address)
- assert_equal(@port, v4mc.local_address.ip_port)
+ assert_equal('0.0.0.0', v4mc.local_address.ip_address)
+ assert_equal(@port, v4mc.local_address.ip_port)
end
def test_make_socket_ipv6_multicast
@@ -595,7 +595,43 @@ class TestRingServer < Test::Unit::TestCase
assert v6mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool
end
- assert_equal('ff02::1', v6mc.local_address.ip_address)
+ assert_equal('::1', v6mc.local_address.ip_address)
+ assert_equal(@port, v6mc.local_address.ip_port)
+ end
+
+ def test_ring_server_ipv4_multicast
+ @rs = Rinda::RingServer.new(@ts, [['239.0.0.1', '0.0.0.0']], @port)
+ v4mc = @rs.instance_variable_get('@sockets').first
+
+ if Socket.const_defined?(:SO_REUSEPORT) then
+ assert(v4mc.getsockopt(:SOCKET, :SO_REUSEPORT).bool)
+ else
+ assert(v4mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool)
+ end
+
+ assert_equal('0.0.0.0', v4mc.local_address.ip_address)
+ assert_equal(@port, v4mc.local_address.ip_port)
+ end
+
+ def test_ring_server_ipv6_multicast
+ skip 'IPv6 not available' unless
+ Socket.ip_address_list.any? { |addrinfo| addrinfo.ipv6? }
+
+ begin
+ @rs = Rinda::RingServer.new(@ts, [['ff02::1', '::1', 0]], @port)
+ rescue Errno::EADDRNOTAVAIL
+ return # IPv6 address for multicast not available
+ end
+
+ v6mc = @rs.instance_variable_get('@sockets').first
+
+ if Socket.const_defined?(:SO_REUSEPORT) then
+ assert v6mc.getsockopt(:SOCKET, :SO_REUSEPORT).bool
+ else
+ assert v6mc.getsockopt(:SOCKET, :SO_REUSEADDR).bool
+ end
+
+ assert_equal('::1', v6mc.local_address.ip_address)
assert_equal(@port, v6mc.local_address.ip_port)
end