Skip to content

Commit

Permalink
fix to identify test problems on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Nov 8, 2016
1 parent 34b81e6 commit 555e7a2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install:
- bundle install
build: off
test_script:
- bundle exec rake test
- bundle exec rake test TESTOPTS=-v

branches:
only:
Expand Down
3 changes: 3 additions & 0 deletions lib/fluent/plugin_helper/child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def child_process_exist?(pid)
true
end

# on_exit_callback = ->(status){ ... }
# status is an instance of Process::Status
# On Windows, exitstatus=0 and termsig=nil even when child process was killed.
def child_process_execute(
title, command,
arguments: nil, subprocess_name: nil, interval: nil, immediate: false, parallel: false,
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_out_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def create_test_data
sub_test_case 'when executed process dies unexpectedly' do
setup do
@gen_config = ->(num){ <<EOC
command ruby -e 'ARGV.first.to_i == 0 ? open(ARGV[1]){|f| STDOUT.write f.read} : (sleep 1 ; exit ARGV.first.to_i)' #{num} >#{TMP_DIR}/fail_out
command ruby -e "ARGV.first.to_i == 0 ? open(ARGV[1]){|f| STDOUT.write f.read} : (sleep 1 ; exit ARGV.first.to_i)" #{num} >#{TMP_DIR}/fail_out
<inject>
tag_key tag
time_key time
Expand Down
3 changes: 2 additions & 1 deletion test/plugin/test_out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ def create_driver(conf)
pid = event[2]['child_pid']
pid_list << pid unless pid_list.include?(pid)
end
assert_equal 20, pid_list.size, "the number of pids should be same with number of child processes: #{pid_list.inspect}"
# the number of pids should be same with number of child processes
assert{ pid_list.size >= 18 }

logs = d.instance.log.out.logs
assert{ logs.select{|l| l.include?("child process exits with error code") }.size >= 18 } # 20
Expand Down
15 changes: 10 additions & 5 deletions test/plugin_helper/test_child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ def configure(conf)
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
pid = nil
@d.child_process_execute(:st1, "ruby", arguments: args, mode: [:read], on_exit_callback: cb) do |readio|
Process.kill(:QUIT, @d.instance_eval{ child_process_id })
pid = @d.instance_eval{ child_process_id }
Process.kill(:QUIT, pid)
str = readio.read.chomp rescue nil # empty string before EOF
block_exits = true
end
Expand Down Expand Up @@ -754,8 +755,10 @@ def configure(conf)

assert callback_called
assert exit_status
assert_nil exit_status.exitstatus
assert_equal 9, exit_status.termsig # SIGKILL
unless Fluent.windows? # On Windows, exitstatus is always 0 and termsig is nil
assert_nil exit_status.exitstatus
assert_equal 9, exit_status.termsig # SIGKILL
end
assert File.exist?(@temp_path)
end

Expand All @@ -776,8 +779,10 @@ def configure(conf)

assert callback_called
assert exit_status
assert_nil exit_status.exitstatus
assert_equal 9, exit_status.termsig # SIGKILL
unless Fluent.windows? # On Windows, exitstatus is always 0 and termsig is nil
assert_nil exit_status.exitstatus
assert_equal 9, exit_status.termsig # SIGKILL
end
assert File.exist?(@temp_path)
end
end
Expand Down

0 comments on commit 555e7a2

Please sign in to comment.