summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-09-22 15:31:47 -0700
committerClaire McQuin <claire@getchef.com>2014-10-01 14:31:05 -0700
commit97b628a766d14a6a8fe6b3b2febb604a570e0cde (patch)
tree29f7f11b43250010a8e71c787c8d01eae0f1b97a /spec
parent00ecc94e206da3c09cf5dac8d698deaba970d8b2 (diff)
downloadchef-97b628a766d14a6a8fe6b3b2febb604a570e0cde.tar.gz
Disable unforked interval runs.
Clarify error message. Move fork and interval logic to application (specs pending). Clean code logic, fix specs. Allow unforked client runs with daemonize or splay
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/application/client_spec.rb37
-rw-r--r--spec/unit/application/solo_spec.rb26
-rw-r--r--spec/unit/client_spec.rb25
3 files changed, 62 insertions, 26 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 3bc6b97d3d..f0b4f3bda8 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -39,6 +39,43 @@ describe Chef::Application::Client, "reconfigure" do
ARGV.replace(@original_argv)
end
+ describe "when configured to not fork the client process" do
+ before do
+ Chef::Config[:client_fork] = false
+ Chef::Config[:daemonize] = false
+ Chef::Config[:interval] = nil
+ Chef::Config[:splay] = nil
+ end
+
+ context "when interval is given" do
+ before do
+ Chef::Config[:interval] = 600
+ end
+
+ it "should terminate with message" do
+ Chef::Application.should_receive(:fatal!).with(
+"Unforked chef-client interval runs are disabled in Chef 12.
+Configuration settings:
+ interval = 600 seconds
+Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ )
+ @app.reconfigure
+ end
+ end
+
+ context "when configured to run once" do
+ before do
+ Chef::Config[:once] = true
+ Chef::Config[:interval] = 1000
+ end
+
+ it "should reconfigure chef-client" do
+ @app.reconfigure
+ Chef::Config[:interval].should be_nil
+ end
+ end
+ end
+
describe "when in daemonized mode and no interval has been set" do
before do
Chef::Config[:daemonize] = true
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 787f9ff43c..e29fcc9367 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -36,6 +36,31 @@ describe Chef::Application::Solo do
Chef::Config[:solo].should be_true
end
+ describe "when configured to not fork the client process" do
+ before do
+ Chef::Config[:client_fork] = false
+ Chef::Config[:daemonize] = false
+ Chef::Config[:interval] = nil
+ Chef::Config[:splay] = nil
+ end
+
+ context "when interval is given" do
+ before do
+ Chef::Config[:interval] = 600
+ end
+
+ it "should terminate with message" do
+ Chef::Application.should_receive(:fatal!).with(
+"Unforked chef-client interval runs are disabled in Chef 12.
+Configuration settings:
+ interval = 600 seconds
+Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ )
+ @app.reconfigure
+ end
+ end
+ end
+
describe "when in daemonized mode and no interval has been set" do
before do
Chef::Config[:daemonize] = true
@@ -142,4 +167,3 @@ describe Chef::Application::Solo do
end
end
-
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 37a2dc09ca..e05245c413 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -301,25 +301,6 @@ describe Chef::Client do
include_examples "a successful client run"
end
- describe "when running chef-client with forking enabled", :unix_only do
- include_examples "a successful client run" do
- let(:process_status) do
- double("Process::Status")
- end
-
- let(:enable_fork) { true }
-
- before do
- Process.should_receive(:waitpid2).and_return([1, process_status])
-
- process_status.should_receive(:success?).and_return(true)
- client.should_receive(:exit).and_return(nil)
- client.should_receive(:fork).and_yield
- end
- end
-
- end
-
describe "when the client key already exists" do
let(:api_client_exists?) { true }
@@ -389,7 +370,6 @@ describe Chef::Client do
client.run
node.run_list.should == Chef::RunList.new(new_runlist)
end
-
end
end
@@ -409,11 +389,6 @@ describe Chef::Client do
client = Chef::Client.new
client.stub(:load_node).and_raise(Exception)
@run_lock.should_receive(:release)
- if(Chef::Config[:client_fork] && !windows?)
- client.should_receive(:fork) do |&block|
- block.call
- end
- end
lambda { client.run }.should raise_error(Exception)
end
end