diff --git a/test/test_pumactl.rb b/test/test_pumactl.rb index a88bee0537..dba2dca61b 100644 --- a/test/test_pumactl.rb +++ b/test/test_pumactl.rb @@ -175,6 +175,30 @@ def test_control_ssl assert_kind_of Thread, t.join, "server didn't stop" end + def test_control_aunix + skip_unless :aunix + + url = "unix://@test_control_aunix.unix" + + opts = [ + "--control-url", url, + "--control-token", "ctrl", + "--config-file", "test/config/app.rb", + ] + + control_cli = Puma::ControlCLI.new (opts + ["start"]), @ready, @ready + t = Thread.new do + control_cli.run + end + + wait_booted + + assert_command_cli_output opts + ["status"], "Puma is started" + assert_command_cli_output opts + ["stop"], "Command stop sent success" + + assert_kind_of Thread, t.join, "server didn't stop" + end + private def assert_command_cli_output(options, expected_out) diff --git a/test/test_unix_socket.rb b/test/test_unix_socket.rb index bd6dcfe5ec..854d44c4c1 100644 --- a/test/test_unix_socket.rb +++ b/test/test_unix_socket.rb @@ -8,21 +8,21 @@ class TestPumaUnixSocket < Minitest::Test App = lambda { |env| [200, {}, ["Works"]] } - def setup - return unless UNIX_SKT_EXIST - @tmp_socket_path = tmp_path('.sock') + def teardown + return if skipped? + @server.stop(true) + end + + def server_unix(type) + @tmp_socket_path = type == :unix ? tmp_path('.sock') : "@TestPumaUnixSocket" @server = Puma::Server.new App @server.add_unix_listener @tmp_socket_path @server.run end - def teardown - return unless UNIX_SKT_EXIST - @server.stop(true) - end - - def test_server + def test_server_unix skip_unless :unix + server_unix :unix sock = UNIXSocket.new @tmp_socket_path sock << "GET / HTTP/1.0\r\nHost: blah.com\r\n\r\n" @@ -31,4 +31,16 @@ def test_server assert_equal expected, sock.read(expected.size) end + + def test_server_aunix + skip_unless :aunix + server_unix :aunix + sock = UNIXSocket.new @tmp_socket_path.sub(/\A@/, "\0") + + sock << "GET / HTTP/1.0\r\nHost: blah.com\r\n\r\n" + + expected = "HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nWorks" + + assert_equal expected, sock.read(expected.size) + end end