summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-03-05 13:33:39 -0800
committerTim Smith <tsmith84@gmail.com>2020-03-31 13:50:03 -0700
commit0c08fb5afd066b7ebf0c625e43bedc1e30c1b758 (patch)
tree630b059ea66237d707839a82e3696499ceb6e739
parente6a5a2335ca2d333b2f82b751fe1917fcbe2ad13 (diff)
downloadchef-0c08fb5afd066b7ebf0c625e43bedc1e30c1b758.tar.gz
Fix file descriptor leak in our tests
Mac has a default max fd of 256 which this can pretty much blow out by leaking PIPE objects which last until the garbage collector destroys the instances, this forces the pipes to be closed when the stop function is called here. Cuts down on over 200 leaking file descriptors from this test which leak into the subsequent tests. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--spec/functional/run_lock_spec.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index d9a8bd2d0e..5410d1941c 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software, Inc.
+# Copyright:: Copyright 2012-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -404,6 +404,10 @@ describe Chef::RunLock do
example.log_event("#{name}.stop finished (pid #{pid} wasn't running)")
end
end
+ @read_from_process.close rescue nil
+ @write_to_tests.close rescue nil
+ @read_from_tests.close rescue nil
+ @write_to_process.close rescue nil
end
def fire_event(event)