Skip to content

Commit 500ac03

Browse files
authored
Backport(v1.16) test: improve Sigdump test for Windows (#4847) (#4862)
**Which issue(s) this PR fixes**: * Backport #4847 **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 9e93a65 commit 500ac03

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
@@ -402,34 +402,31 @@ def test_fluentsigdump_get_path_with_pid(data)
402402
def test_supervisor_event_dump_windows
403403
omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
404404

405+
# https://github.com/fluent/fluentd/issues/4063
406+
GC.start
407+
408+
ENV['SIGDUMP_PATH'] = TMP_DIR + "/sigdump.log"
409+
405410
server = DummyServer.new
406411
def server.config
407412
{:signame => "TestFluentdEvent"}
408413
end
409414
server.install_windows_event_handler
410415

411-
assert_rr do
412-
# Have to use mock because `Sigdump.dump` seems to be somehow incompatible with RR.
413-
# The `mock(server).restart(true) { nil }` line in `test_rpc_server_windows` cause the next error.
414-
# Failure: test_supervisor_event_dump_windows(SupervisorTest):
415-
# class()
416-
# Called 0 times.
417-
# Expected 1 times.
418-
# .../Ruby26-x64/lib/ruby/gems/2.6.0/gems/sigdump-0.2.4/lib/sigdump.rb:74:in `block in dump_object_count'
419-
# 73: ObjectSpace.each_object {|o|
420-
# 74: c = o.class <-- HERE!
421-
mock(Sigdump).dump(anything)
422-
423-
begin
424-
sleep 0.1 # Wait for starting windows event thread
425-
event = Win32::Event.open("TestFluentdEvent_CONT")
426-
event.set
427-
event.close
428-
sleep 1.0 # Wait for dumping
429-
ensure
430-
server.stop_windows_event_thread
431-
end
416+
begin
417+
sleep 0.1 # Wait for starting windows event thread
418+
event = Win32::Event.open("TestFluentdEvent_CONT")
419+
event.set
420+
event.close
421+
sleep 1.0 # Wait for dumping
422+
ensure
423+
server.stop_windows_event_thread
432424
end
425+
426+
result_filepaths = Dir.glob("#{TMP_DIR}/*")
427+
assert {result_filepaths.length > 0}
428+
ensure
429+
ENV.delete('SIGDUMP_PATH')
433430
end
434431

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

0 commit comments

Comments
 (0)