diff options
author | markgibbons <mark.gibbons@nordstrom.com> | 2016-11-09 16:00:48 -0800 |
---|---|---|
committer | markgibbons <mark.gibbons@nordstrom.com> | 2016-11-15 16:32:21 -0800 |
commit | 58c5137e854782329215182364110021a0418a2e (patch) | |
tree | 2dff664831c2f8bbc82eb1abafdfd35b6f10ff9f /spec | |
parent | fc0ead5b9ec6aa28ae263f8f9c6bc4c7310c9471 (diff) | |
download | chef-58c5137e854782329215182364110021a0418a2e.tar.gz |
smf_recursive_dependencies: Allow solaris services to start recursively.
Svcadm enable -s service only starts the named service. This commit adds the
recursive option to start service dependencies recursively. The resulting command
"svcadm enable -sr service" will try to start service dependencies before
starting the named service.
Signed-off-by: markgibbons <mark.gibbons@nordstrom.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/service/solaris_smf_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/unit/resource/service_spec.rb | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index c6835bed64..98b0ed34e0 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -198,6 +198,23 @@ describe Chef::Provider::Service::Solaris do end end + describe "when enabling the service recursively" do + before(:each) do + @new_resource.recursive(true) + @provider.current_resource = @current_resource + end + + it "should call svcadm enable -sr chef" do + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) + expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-sr", @current_resource.service_name).and_return(@success) + @provider.load_current_resource + + expect(@provider.enable_service).to be_truthy + expect(@current_resource.enabled).to be_truthy + end + end + describe "when disabling the service" do before(:each) do @provider.current_resource = @current_resource diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 7aadc55532..4114a8ec3e 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -124,6 +124,22 @@ describe Chef::Resource::Service do end.to raise_error(ArgumentError) end + it "should accept true for recursive" do + @resource.recursive true + expect(@resource.send("recursive")).to eql(true) + end + + it "should accept false for recursive" do + @resource.recursive false + expect(@resource.send("recursive")).to eql(false) + end + + it "should not accept a string for recursive" do + expect do + @resource.recursive "poop" + end.to raise_error(ArgumentError) + end + %w{enabled running}.each do |attrib| it "should accept true for #{attrib}" do @resource.send(attrib, true) |