diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-03-05 10:37:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 10:37:47 -0800 |
commit | 41d69e2a5b2ff23488441b82f019b77b243dbdf7 (patch) | |
tree | d155da48c5d01329daaa762efd0ed4d7a383290b /spec/unit | |
parent | 96ae775bb89753871c30311a113c2efa269a2d71 (diff) | |
parent | 7a25e6b270d62f4a2a9a085ea25ed84169911f42 (diff) | |
download | chef-41d69e2a5b2ff23488441b82f019b77b243dbdf7.tar.gz |
Merge pull request #6914 from chef/lcg/no-fork-default-command-line
Don't use supervisor process for one-shot / command-line runs
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/application/client_spec.rb | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index 3f803f2033..0cd3cb3995 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -107,6 +107,7 @@ describe Chef::Application::Client, "reconfigure" do shared_examples "sets the configuration" do |cli_arguments, expected_config| describe cli_arguments do before do + cli_arguments ||= "" ARGV.replace(cli_arguments.split) app.reconfigure end @@ -144,6 +145,36 @@ describe Chef::Application::Client, "reconfigure" do end end + describe "--[no]-fork" do + before do + Chef::Config[:interval] = nil # FIXME: we're overriding the before block setting this + end + + context "by default" do + it_behaves_like "sets the configuration", "", client_fork: false + end + + context "with --fork" do + it_behaves_like "sets the configuration", "--fork", client_fork: true + end + + context "with --no-fork" do + it_behaves_like "sets the configuration", "--no-fork", client_fork: false + end + + context "with an interval" do + it_behaves_like "sets the configuration", "--interval 1800", client_fork: true + end + + context "with once" do + it_behaves_like "sets the configuration", "--once", client_fork: false + end + + context "with daemonize", :unix_only do + it_behaves_like "sets the configuration", "--daemonize", client_fork: true + end + end + describe "--config-option" do context "with a single value" do it_behaves_like "sets the configuration", "--config-option chef_server_url=http://example", @@ -186,21 +217,16 @@ describe Chef::Application::Client, "reconfigure" do Chef::Config[:splay] = nil end - context "when interval is given" do - before do - Chef::Config[:interval] = 600 - allow(ChefConfig).to receive(:windows?).and_return(false) - end - - it "should terminate with message" do - expect(Chef::Application).to receive(:fatal!).with( -"Unforked chef-client interval runs are disabled in Chef 12. + it "should terminal with message when interval is given" do + Chef::Config[:interval] = 600 + allow(ChefConfig).to receive(:windows?).and_return(false) + expect(Chef::Application).to 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 + ) + app.reconfigure end context "when interval is given on windows" do |