Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
This test works fine on its own, but some other tests make it fail.
Use mock to solve this problem.

Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom committed Mar 24, 2022
1 parent dafde43 commit 0d126de
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,34 @@ def test_fluentsigdump_get_path_with_pid(data)
def test_supervisor_event_dump_windows
omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?

ENV['SIGDUMP_PATH'] = TMP_DIR + "/sigdump.log"

server = DummyServer.new
def server.config
{:signame => "TestFluentdEvent"}
end
server.install_windows_event_handler
begin
sleep 0.1 # Wait for starting windows event thread
event = Win32::Event.open("TestFluentdEvent_CONT")
event.set
event.close
sleep 1.0 # Wait for dumping
ensure
server.stop_windows_event_thread
end

result_filepaths = Dir.glob("#{TMP_DIR}/*")
assert {result_filepaths.length > 0}
ensure
ENV.delete('SIGDUMP_PATH')
assert_rr do
# Have to use mock because `Sigdump.dump` seems to be somehow incompatible with RR.
# The `mock(server).restart(true) { nil }` line in `test_rpc_server_windows` cause the next error.
# Failure: test_supervisor_event_dump_windows(SupervisorTest):
# class()
# Called 0 times.
# Expected 1 times.
# .../Ruby26-x64/lib/ruby/gems/2.6.0/gems/sigdump-0.2.4/lib/sigdump.rb:74:in `block in dump_object_count'
# 73: ObjectSpace.each_object {|o|
# 74: c = o.class <-- HERE!
mock(Sigdump).dump(anything)

begin
sleep 0.1 # Wait for starting windows event thread
event = Win32::Event.open("TestFluentdEvent_CONT")
event.set
event.close
sleep 1.0 # Wait for dumping
ensure
server.stop_windows_event_thread
end
end
end

data(:ipv4 => ["0.0.0.0", "127.0.0.1", false],
Expand Down

0 comments on commit 0d126de

Please sign in to comment.