diff options
author | Eric Wong <e@80x24.org> | 2015-11-11 01:43:06 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-11-11 02:39:49 +0000 |
commit | 0312c1e6220ef4280268a0f48f24db90738037bd (patch) | |
tree | cd94cedf0acef03617ca5d56e788b74063a0edb6 /test/inherit.rb | |
parent | 97ade9d8d5d751c197b61faee5f3ae6589b6b432 (diff) | |
download | cmogstored-0312c1e6220ef4280268a0f48f24db90738037bd.tar.gz |
While I have my reservations about systemd, socket activation alone is a good idea and we already have existing infrastructure for supporting it in SIGUSR2 upgrades. We are intentionally avoiding linkage to libsystemd to avoid dealing with ABI compatibility issues between old and new systems. This also allows us to integrate more easily with non-systemd systems which use the same environment variables as systemd.
Diffstat (limited to 'test/inherit.rb')
-rw-r--r-- | test/inherit.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/inherit.rb b/test/inherit.rb index b342ab0..34aa52f 100644 --- a/test/inherit.rb +++ b/test/inherit.rb @@ -142,4 +142,36 @@ class TestInherit < Test::Unit::TestCase @err.rewind assert_match(/failed to parse/, @err.read) end + + def test_inherit_systemd + # disabled test on old Rubies: https://bugs.ruby-lang.org/issues/11336 + # [ruby-core:69895] [Bug #11336] fixed by r51576 + return unless RUBY_VERSION.to_f >= 2.3 + + mgmt = TCPServer.new(@host, 0) + @to_close << mgmt + mport = mgmt.addr[1] + cmd = %W(cmogstored --docroot=#@tmpdir --httplisten=#@host:#@port + --mgmtlisten=#@host:#{mport} --maxconns=100) + @pid = fork do + ENV['LISTEN_PID'] = "#$$" + ENV['LISTEN_FDS'] = '2' + exec(*cmd, 3 => mgmt.fileno, 4 => @srv.fileno) + end + + # just ensure HTTP works after being inherited + Net::HTTP.start(@host, @port) do |http| + [ Net::HTTP::Get, Net::HTTP::Head ].each do |meth| + resp = http.request(meth.new("/")) + assert_kind_of Net::HTTPOK, resp + end + end + + # still works since drop is open in _this_ process + c = TCPSocket.new(@host, mport) + assert_instance_of(TCPSocket, c) + @to_close << c + c.write "hello\n" + assert_match /ERROR: unknown command/, c.gets + end end |