1 # -*- encoding: binary -*-
2 # frozen_string_literal: false
3 require "./test/rack_unicorn"
4 require "./test/ipv6_enabled"
5 $stderr.sync = $stdout.sync = true
7 class TestMiddlewareUnicornIPv6 < Test::Unit::TestCase
10 @host = ENV["TEST_HOST6"] || "::1"
11 sock = TCPServer.new @host, 0
13 ENV["UNICORN_FD"] = sock.fileno.to_s
14 @host_with_port = "[#@host]:#@port"
15 @opts = { :listeners => [ @host_with_port ] }
16 @addr_regexp = Regexp.escape @host_with_port
19 def test_auto_listener
20 @app = Rack::Builder.new do
21 use Raindrops::Middleware
24 @srv = fork { Unicorn::HttpServer.new(@app, @opts).start.join }
25 s = TCPSocket.new @host, @port
26 s.write "GET /_raindrops HTTP/1.0\r\n\r\n"
28 _, body = resp.split(/\r\n\r\n/, 2)
29 assert_match %r{^#@addr_regexp active: 1$}, body
30 assert_match %r{^#@addr_regexp queued: 0$}, body
34 Process.kill :QUIT, @srv
35 _, status = Process.waitpid2 @srv
36 assert status.success?
38 end if defined?(Unicorn) && RUBY_PLATFORM =~ /linux/ && ipv6_enabled?