summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-02-26 20:47:12 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2015-02-26 20:47:12 -0800
commit57bb33185992637a6e9cb60adbc5f54d46a90269 (patch)
treec817bbe0e3fd6bd31085056dc1f53ccc29b1d349
parentebad0fd6a6af04df1a7cc561e4c63958f9171c3c (diff)
downloadchef-57bb33185992637a6e9cb60adbc5f54d46a90269.tar.gz
Add spec to check timeout is passed to shellout
-rw-r--r--spec/unit/windows_service_spec.rb39
1 files changed, 28 insertions, 11 deletions
diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb
index 6596529937..71ed8bf0de 100644
--- a/spec/unit/windows_service_spec.rb
+++ b/spec/unit/windows_service_spec.rb
@@ -39,16 +39,33 @@ describe "Chef::Application::WindowsService", :windows_only do
allow(instance).to receive(:state).and_return(4)
instance.service_main
end
- it "passes config params to new process with a default timeout of 1200 seconds (20 minutes)" do
- Chef::Config.merge!({:log_location => tempfile.path, :config_file => "test_config_file", :log_level => :info})
- expect(instance).to receive(:configure_chef).twice
- instance.service_init
- allow(instance).to receive(:running?).and_return(true, false)
- allow(instance.instance_variable_get(:@service_signal)).to receive(:wait)
- allow(instance).to receive(:state).and_return(4)
- expect(instance).to receive(:run_chef_client).and_call_original
- expect(instance).to receive(:shell_out).with("chef-client --no-fork -c test_config_file -L #{tempfile.path}", {:timeout => 1200}).and_return(shell_out_result)
- instance.service_main
- tempfile.unlink
+
+ context 'when running chef-client' do
+ it "passes config params to new process with a default timeout of 1200 seconds (20 minutes)" do
+ Chef::Config.merge!({:log_location => tempfile.path, :config_file => "test_config_file", :log_level => :info})
+ expect(instance).to receive(:configure_chef).twice
+ instance.service_init
+ allow(instance).to receive(:running?).and_return(true, false)
+ allow(instance.instance_variable_get(:@service_signal)).to receive(:wait)
+ allow(instance).to receive(:state).and_return(4)
+ expect(instance).to receive(:run_chef_client).and_call_original
+ expect(instance).to receive(:shell_out).with("chef-client --no-fork -c test_config_file -L #{tempfile.path}", {:timeout => 1200}).and_return(shell_out_result)
+ instance.service_main
+ tempfile.unlink
+ end
+
+ it "passes config params to new process with a the timeout specified in the config" do
+ Chef::Config.merge!({:log_location => tempfile.path, :config_file => "test_config_file", :log_level => :info})
+ Chef::Config[:windows_service][:watchdog_timeout] = 10
+ expect(instance).to receive(:configure_chef).twice
+ instance.service_init
+ allow(instance).to receive(:running?).and_return(true, false)
+ allow(instance.instance_variable_get(:@service_signal)).to receive(:wait)
+ allow(instance).to receive(:state).and_return(4)
+ expect(instance).to receive(:run_chef_client).and_call_original
+ expect(instance).to receive(:shell_out).with("chef-client --no-fork -c test_config_file -L #{tempfile.path}", {:timeout => 10}).and_return(shell_out_result)
+ instance.service_main
+ tempfile.unlink
+ end
end
end