summaryrefslogtreecommitdiff
path: root/spec/unit/application
diff options
context:
space:
mode:
authorAlex Rakoczy & Matthew Horan <pair+arakoczy+mhoran@pivotallabs.com>2012-12-14 10:24:12 -0500
committerBryan McLellan <btm@opscode.com>2013-05-24 10:13:55 -0700
commit3dcb917507b14b6f557e8513bc5943a007cdd6ad (patch)
tree66c8dae1442ad333bee3526972b967c593b2616a /spec/unit/application
parentd74ffe26802f149d39e5be3b959ff6d219d01dc7 (diff)
downloadchef-3dcb917507b14b6f557e8513bc5943a007cdd6ad.tar.gz
CHEF-1761: Exit gracefully on SIGTERM
(cherry picked from commit 079ac748c314116c7a78249b2800b52de82ac370)
Diffstat (limited to 'spec/unit/application')
-rw-r--r--spec/unit/application/client_spec.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 04a86bee8d..e894b8f702 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -19,7 +19,7 @@ require 'spec_helper'
describe Chef::Application::Client, "reconfigure" do
before do
- @original_config = Chef::Config.configuration
+ @original_config = Chef::Config.configuration.dup
@app = Chef::Application::Client.new
@app.stub!(:configure_opt_parser).and_return(true)
@@ -148,4 +148,27 @@ describe Chef::Application::Client, "configure_chef" do
Chef::Config[:color].should be_true
end
end
-end \ No newline at end of file
+end
+
+describe Chef::Application::Client, "run_application", :unix_only do
+ before do
+ @pipe = IO.pipe
+ @app = Chef::Application::Client.new
+ @app.stub(:run_chef_client) do
+ @pipe[1].puts 'started'
+ sleep 1
+ @pipe[1].puts 'finished'
+ end
+ end
+
+ it "should exit gracefully when sent SIGTERM" do
+ pid = fork do
+ @app.run_application
+ end
+ @pipe[0].gets.should == "started\n"
+ Process.kill("TERM", pid)
+ Process.wait
+ IO.select([@pipe[0]], nil, nil, 0).should_not be_nil
+ @pipe[0].gets.should == "finished\n"
+ end
+end