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-16 13:03:35 -0700
commitf893e97b4aded32b0f60dd6416d60072483bf3c8 (patch)
tree5fc4e9550a71d7dd51dd5e6309cef3937d602b6b
parent9fab315cd035ce8c3e91325d8af57c19cbefc9e9 (diff)
downloadchef-f893e97b4aded32b0f60dd6416d60072483bf3c8.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)