diff options
author | danielsdeleo <dan@opscode.com> | 2014-03-07 10:37:54 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-03-07 11:55:01 -0800 |
commit | cbb4de9fd775342b307deef997f9e08aa9f54cd8 (patch) | |
tree | 8e96feae8932556cb9bae82d579bdee1455fd81b /spec/mixlib | |
parent | 9e0081916130a50a4207afd81ca94026fcf5e5ca (diff) | |
download | mixlib-shellout-cbb4de9fd775342b307deef997f9e08aa9f54cd8.tar.gz |
Add debugging to volatile specs
Attempting to reproduce this in isolation hasn't worked. Add debug
information permanently so we may get a hint of why this test sometimes
fails if we see it again.
Diffstat (limited to 'spec/mixlib')
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 3d0a04f..42f2714 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -944,19 +944,37 @@ describe Mixlib::ShellOut do CODE end + it "should TERM the wayward child and grandchild, then KILL whoever is left" do # note: let blocks don't correctly memoize if an exception is raised, # so can't use executed_cmd lambda { shell_cmd.run_command}.should raise_error(Mixlib::ShellOut::CommandTimeout) - shell_cmd.stdout.should include("got term in child") - shell_cmd.stdout.should include("got term in grandchild") + begin - # A little janky. We get the process group id out of the command - # object, then try to kill a process in it to make sure none - # exists. Trusting the system under test like this isn't great but - # it's difficult to test otherwise. - lambda { Process.kill(:INT, shell_cmd.send(:child_pgid)) }.should raise_error(Errno::ESRCH) + # A little janky. We get the process group id out of the command + # object, then try to kill a process in it to make sure none + # exists. Trusting the system under test like this isn't great but + # it's difficult to test otherwise. + child_pgid = shell_cmd.send(:child_pgid) + initial_process_listing = `ps -j` + + shell_cmd.stdout.should include("got term in child") + shell_cmd.stdout.should include("got term in grandchild") + + Process.kill(:INT, child_pgid) # should raise ESRCH + + # Debug the failure: + puts "child pgid=#{child_pgid.inspect}" + Process.wait + puts "collected process: #{$?.inspect}" + puts "initial process listing:\n#{initial_process_listing}" + puts "current process listing:" + puts `ps -j` + raise "Failed to kill all expected processes" + rescue Errno::ESRCH + # this is what we want + end end end |