Skip to content

Commit 60e3693

Browse files
authored
test: improve Sigdump test for Windows (#4847)
**Which issue(s) this PR fixes**: None. Related to * #4063 * #4846 **What this PR does / why we need it**: Sigdump.dump iterates ObjectSpace. If there are DoubleDefinition objects of RR, it can set some expectations of RR unexpectedly. It can cause test failure. By doing GC, we can remove DoubleDefinition objects made in other tests. This allows us to simplify this test. See #4063 **Docs Changes**: Not needed. **Release Note**: Not needed. Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
1 parent c0e654b commit 60e3693

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

test/test_supervisor.rb

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -490,34 +490,31 @@ def test_fluentsigdump_get_path_with_pid(data)
490490
def test_supervisor_event_dump_windows
491491
omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
492492

493+
# https://github.com/fluent/fluentd/issues/4063
494+
GC.start
495+
496+
ENV['SIGDUMP_PATH'] = TMP_DIR + "/sigdump.log"
497+
493498
server = DummyServer.new
494499
def server.config
495500
{:signame => "TestFluentdEvent"}
496501
end
497502
server.install_windows_event_handler
498503

499-
assert_rr do
500-
# Have to use mock because `Sigdump.dump` seems to be somehow incompatible with RR.
501-
# The `mock(server).restart(true) { nil }` line in `test_rpc_server_windows` cause the next error.
502-
# Failure: test_supervisor_event_dump_windows(SupervisorTest):
503-
# class()
504-
# Called 0 times.
505-
# Expected 1 times.
506-
# .../Ruby26-x64/lib/ruby/gems/2.6.0/gems/sigdump-0.2.4/lib/sigdump.rb:74:in `block in dump_object_count'
507-
# 73: ObjectSpace.each_object {|o|
508-
# 74: c = o.class <-- HERE!
509-
mock(Sigdump).dump(anything)
510-
511-
begin
512-
sleep 0.1 # Wait for starting windows event thread
513-
event = Win32::Event.open("TestFluentdEvent_CONT")
514-
event.set
515-
event.close
516-
sleep 1.0 # Wait for dumping
517-
ensure
518-
server.stop_windows_event_thread
519-
end
504+
begin
505+
sleep 0.1 # Wait for starting windows event thread
506+
event = Win32::Event.open("TestFluentdEvent_CONT")
507+
event.set
508+
event.close
509+
sleep 1.0 # Wait for dumping
510+
ensure
511+
server.stop_windows_event_thread
520512
end
513+
514+
result_filepaths = Dir.glob("#{TMP_DIR}/*")
515+
assert {result_filepaths.length > 0}
516+
ensure
517+
ENV.delete('SIGDUMP_PATH')
521518
end
522519

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

0 commit comments

Comments
 (0)