diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-02 13:42:02 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-02 13:42:02 -0700 |
commit | b1ec7f48bfc4528446ec10dc9ff5552050f1798e (patch) | |
tree | 6675f3d9e92ea276f196e507ba2dece2275f5bbe | |
parent | 990343b34cd42b1448d12b9cbd8dfd08b502c673 (diff) | |
download | chef-b1ec7f48bfc4528446ec10dc9ff5552050f1798e.tar.gz |
use threads to workaround Process.spawn buginesslcg/fix-solo-spec-test
there's a WONTFIX closed bug in ruby-lang.org on this bug:
https://bugs.ruby-lang.org/issues/10583
they seem to be favoring speed over accuracy with the result
that if you're doing I/O synchronization (like our run_lock?)
inside of a Process.spawn chain like this that you have to
wrap the spawn calls inside of threads.
probably a best practice to wrap every spawn call with a
Thread.
this probably also explains why we had the silly-long 20
second timeout?
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | spec/integration/solo/solo_spec.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index efbbde2af9..bfcb74b45c 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -133,16 +133,21 @@ EOM Timeout.timeout(120) do chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..") + threads = [] + # Instantiate the first chef-solo run - s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \ --l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + threads << Thread.new do + s1 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + Process.waitpid(s1) + end # Instantiate the second chef-solo run - s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \ --l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + threads << Thread.new do + s2 = Process.spawn("#{chef_solo} -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir) + Process.waitpid(s2) + end - Process.waitpid(s1) - Process.waitpid(s2) + threads.each(&:join) end end.not_to raise_error |