Skip to content

Commit 06b6d44

Browse files
authored
Merge pull request #136 from Earlopain/port-more-tests
Port more tests
2 parents 846415a + 0aeb770 commit 06b6d44

File tree

7 files changed

+43
-185
lines changed

7 files changed

+43
-185
lines changed

lib/pitchfork/worker.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ def to_io # IO.select-compatible
110110
@to_io.to_io
111111
end
112112

113-
# master fakes SIGQUIT using this
114-
def quit # :nodoc:
115-
@master = @master.close if @master
116-
end
117-
118113
def master=(socket)
119114
@master = MessageSocket.new(socket)
120115
end

test/integration/t0020-at_exit-handler.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/integration/t0022-listener_names-preload_app.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/integration/t2000-promote-worker.sh

Lines changed: 0 additions & 90 deletions
This file was deleted.

test/integration/t2000.ru

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/integration/test_configuration.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ def test_listen_queues
154154
assert_clean_shutdown(pid)
155155
end
156156

157+
def test_listener_names
158+
addr, port = unused_port
159+
160+
pid = spawn_server(app: File.join(ROOT, "test/integration/apps/listener_names.ru"), config: <<~CONFIG)
161+
listen "#{addr}:#{port}"
162+
worker_processes 1
163+
CONFIG
164+
165+
assert_healthy("http://#{addr}:#{port}")
166+
listener_names = Net::HTTP.get(URI("http://#{addr}:#{port}"))
167+
168+
assert_equal(["#{addr}:#{port}"].inspect, listener_names)
169+
assert_clean_shutdown(pid)
170+
end
171+
157172
def test_modify_internals
158173
addr, port = unused_port
159174

@@ -173,4 +188,32 @@ def test_modify_internals
173188

174189
assert_clean_shutdown(pid)
175190
end
191+
192+
def test_at_exit_handlers
193+
addr, port = unused_port
194+
195+
pid = spawn_server(app: File.join(ROOT, "test/integration/pid.ru"), config: <<~CONFIG)
196+
listen "#{addr}:#{port}"
197+
198+
at_exit { \$stderr.puts("\#{Process.pid} BOTH") }
199+
END { \$stderr.puts("\#{Process.pid} END BOTH") }
200+
after_worker_fork do |_,_|
201+
at_exit { \$stderr.puts("\#{Process.pid} WORKER ONLY") }
202+
END { \$stderr.puts("\#{Process.pid} END WORKER ONLY") }
203+
end
204+
CONFIG
205+
206+
assert_healthy("http://#{addr}:#{port}")
207+
208+
worker_pid = Net::HTTP.get(URI("http://#{addr}:#{port}")).strip
209+
210+
assert_clean_shutdown(pid)
211+
212+
assert_stderr("#{worker_pid} BOTH")
213+
assert_stderr("#{pid} BOTH")
214+
assert_stderr("#{worker_pid} END BOTH")
215+
assert_stderr("#{pid} END BOTH")
216+
assert_stderr("#{worker_pid} WORKER ONLY")
217+
assert_stderr("#{worker_pid} END WORKER ONLY")
218+
end
176219
end

0 commit comments

Comments
 (0)