|
32 | 32 | @provider.current_resource = @current_resource |
33 | 33 |
|
34 | 34 | @pid, @stdin, @stdout, @stderr = nil, nil, nil, nil |
| 35 | + |
35 | 36 | end |
36 | 37 |
|
37 | 38 | it "ensures /usr/sbin/update-rc.d is available" do |
38 | 39 | File.should_receive(:exists?).with("/usr/sbin/update-rc.d").and_return(false) |
39 | 40 | lambda { @provider.assert_update_rcd_available }.should raise_error(Chef::Exceptions::Service) |
40 | 41 | end |
41 | 42 |
|
42 | | - describe "when using squeeze/earlier and update-rc.d shows the init script linked to rc*.d/" do |
43 | | - before do |
44 | | - @provider.stub!(:run_command) |
45 | | - @provider.stub!(:assert_update_rcd_available) |
46 | | - @status = mock("Status", :exitstatus => 0) |
47 | | - |
48 | | - @stdout = StringIO.new("update-rc.d: using dependency based boot sequencing") |
49 | | - result2=<<-UPDATE_RC_D_SUCCESS |
50 | | -insserv: remove service /etc/init.d/../rc0.d/K20chef-client |
51 | | -insserv: remove service /etc/init.d/../rc1.d/K20chef-client |
52 | | -insserv: remove service /etc/init.d/../rc2.d/S20chef-client |
53 | | -insserv: remove service /etc/init.d/../rc3.d/S20chef-client |
54 | | -insserv: remove service /etc/init.d/../rc4.d/S20chef-client |
55 | | -insserv: remove service /etc/init.d/../rc5.d/S20chef-client |
56 | | -insserv: remove service /etc/init.d/../rc6.d/K20chef-client |
57 | | -insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop |
58 | | -UPDATE_RC_D_SUCCESS |
59 | | - @stderr = StringIO.new(result2) |
60 | | - @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
61 | | - end |
62 | | - |
63 | | - it "says the service is enabled" do |
64 | | - @provider.service_currently_enabled?.should be_true |
65 | | - end |
66 | | - |
67 | | - it "stores the 'enabled' state" do |
68 | | - Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
69 | | - @provider.load_current_resource.should equal(@current_resource) |
70 | | - @current_resource.enabled.should be_true |
71 | | - end |
72 | | - |
73 | | - it "stores the start/stop priorities of the service" do |
74 | | - @provider.load_current_resource |
75 | | - expected_priorities = {"6"=>[:stop, "20"], |
76 | | - "0"=>[:stop, "20"], |
77 | | - "1"=>[:stop, "20"], |
78 | | - "2"=>[:start, "20"], |
79 | | - "3"=>[:start, "20"], |
80 | | - "4"=>[:start, "20"], |
81 | | - "5"=>[:start, "20"]} |
82 | | - @provider.current_resource.priority.should == expected_priorities |
83 | | - end |
84 | | - end |
85 | | - |
86 | | - describe "when using squeeze/earlier and update-rc.d shows the init script isn't linked to rc*.d" do |
87 | | - before do |
88 | | - @provider.stub!(:run_command) |
89 | | - @provider.stub!(:assert_update_rcd_available) |
90 | | - @status = mock("Status", :exitstatus => 0) |
91 | | - @stdout = StringIO.new("update-rc.d: using dependency based boot sequencing") |
92 | | - @stderr = StringIO.new("") |
93 | | - @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
94 | | - end |
95 | | - |
96 | | - it "says the service is disabled" do |
97 | | - @provider.service_currently_enabled?.should be_false |
98 | | - end |
99 | | - |
100 | | - it "stores the 'disabled' state" do |
101 | | - Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
102 | | - @provider.load_current_resource.should equal(@current_resource) |
103 | | - @current_resource.enabled.should be_false |
104 | | - end |
105 | | - end |
106 | | - |
107 | | - describe "when using lenny/older and update-rc.d shows the init script linked to rc*.d/" do |
108 | | - before do |
109 | | - @provider.stub!(:run_command) |
110 | | - @provider.stub!(:assert_update_rcd_available) |
111 | | - @status = mock("Status", :exitstatus => 0) |
112 | | - |
113 | | - result=<<-UPDATE_RC_D_SUCCESS |
114 | | - Removing any system startup links for /etc/init.d/chef ... |
| 43 | + |
| 44 | + {"Debian/Lenny and older" => { |
| 45 | + "linked" => { |
| 46 | + "stdout" => " Removing any system startup links for /etc/init.d/chef ... |
115 | 47 | /etc/rc0.d/K20chef |
116 | 48 | /etc/rc1.d/K20chef |
117 | 49 | /etc/rc2.d/S20chef |
118 | 50 | /etc/rc3.d/S20chef |
119 | 51 | /etc/rc4.d/S20chef |
120 | 52 | /etc/rc5.d/S20chef |
121 | | - /etc/rc6.d/K20chef |
122 | | -UPDATE_RC_D_SUCCESS |
123 | | - @stdout = StringIO.new(result) |
124 | | - @stderr = StringIO.new("") |
125 | | - @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
126 | | - end |
127 | | - |
128 | | - it "says the service is enabled" do |
129 | | - @provider.service_currently_enabled?.should be_true |
130 | | - end |
131 | | - |
132 | | - it "stores the 'enabled' state" do |
133 | | - Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
134 | | - @provider.load_current_resource.should equal(@current_resource) |
135 | | - @current_resource.enabled.should be_true |
136 | | - end |
137 | | - |
138 | | - it "stores the start/stop priorities of the service" do |
139 | | - @provider.load_current_resource |
140 | | - expected_priorities = {"6"=>[:stop, "20"], |
141 | | - "0"=>[:stop, "20"], |
142 | | - "1"=>[:stop, "20"], |
143 | | - "2"=>[:start, "20"], |
144 | | - "3"=>[:start, "20"], |
145 | | - "4"=>[:start, "20"], |
146 | | - "5"=>[:start, "20"]} |
147 | | - @provider.current_resource.priority.should == expected_priorities |
148 | | - end |
149 | | - end |
150 | | - |
151 | | - describe "when using lenny/older and update-rc.d shows the init script isn't linked to rc*.d" do |
152 | | - before do |
153 | | - @provider.stub!(:run_command) |
154 | | - @provider.stub!(:assert_update_rcd_available) |
155 | | - @status = mock("Status", :exitstatus => 0) |
156 | | - @stdout = StringIO.new(" Removing any system startup links for /etc/init.d/chef ...") |
157 | | - @stderr = StringIO.new("") |
158 | | - @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
159 | | - end |
160 | | - |
161 | | - it "says the service is disabled" do |
162 | | - @provider.service_currently_enabled?.should be_false |
163 | | - end |
164 | | - |
165 | | - it "stores the 'disabled' state" do |
166 | | - Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
167 | | - @provider.load_current_resource.should equal(@current_resource) |
168 | | - @current_resource.enabled.should be_false |
| 53 | + /etc/rc6.d/K20chef", |
| 54 | + "stderr" => "" |
| 55 | + }, |
| 56 | + "not linked" => { |
| 57 | + "stdout" => " Removing any system startup links for /etc/init.d/chef ...", |
| 58 | + "stderr" => "" |
| 59 | + }, |
| 60 | + }, |
| 61 | + "Debian/Squeeze and earlier" => { |
| 62 | + "linked" => { |
| 63 | + "stdout" => "update-rc.d: using dependency based boot sequencing", |
| 64 | + "stderr" => "insserv: remove service /etc/init.d/../rc0.d/K20chef-client |
| 65 | +insserv: remove service /etc/init.d/../rc1.d/K20chef-client |
| 66 | +insserv: remove service /etc/init.d/../rc2.d/S20chef-client |
| 67 | +insserv: remove service /etc/init.d/../rc3.d/S20chef-client |
| 68 | +insserv: remove service /etc/init.d/../rc4.d/S20chef-client |
| 69 | +insserv: remove service /etc/init.d/../rc5.d/S20chef-client |
| 70 | +insserv: remove service /etc/init.d/../rc6.d/K20chef-client |
| 71 | +insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop" |
| 72 | + }, |
| 73 | + "not linked" => { |
| 74 | + "stdout" => "update-rc.d: using dependency based boot sequencing", |
| 75 | + "stderr" => "" |
| 76 | + } |
| 77 | + } |
| 78 | + }.each do |model, streams| |
| 79 | + describe "when update-rc.d shows the init script linked to rc*.d/" do |
| 80 | + before do |
| 81 | + @provider.stub!(:run_command) |
| 82 | + @provider.stub!(:assert_update_rcd_available) |
| 83 | + @status = mock("Status", :exitstatus => 0) |
| 84 | + |
| 85 | + @stdout = StringIO.new(streams["linked"]["stdout"]) |
| 86 | + @stderr = StringIO.new(streams["linked"]["stderr"]) |
| 87 | + @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 88 | + end |
| 89 | + |
| 90 | + it "says the service is enabled" do |
| 91 | + @provider.service_currently_enabled?.should be_true |
| 92 | + end |
| 93 | + |
| 94 | + it "stores the 'enabled' state" do |
| 95 | + Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
| 96 | + @provider.load_current_resource.should equal(@current_resource) |
| 97 | + @current_resource.enabled.should be_true |
| 98 | + end |
| 99 | + |
| 100 | + it "stores the start/stop priorities of the service" do |
| 101 | + @provider.load_current_resource |
| 102 | + expected_priorities = {"6"=>[:stop, "20"], |
| 103 | + "0"=>[:stop, "20"], |
| 104 | + "1"=>[:stop, "20"], |
| 105 | + "2"=>[:start, "20"], |
| 106 | + "3"=>[:start, "20"], |
| 107 | + "4"=>[:start, "20"], |
| 108 | + "5"=>[:start, "20"]} |
| 109 | + @provider.current_resource.priority.should == expected_priorities |
| 110 | + end |
| 111 | + end |
| 112 | + |
| 113 | + describe "when using squeeze/earlier and update-rc.d shows the init script isn't linked to rc*.d" do |
| 114 | + before do |
| 115 | + @provider.stub!(:run_command) |
| 116 | + @provider.stub!(:assert_update_rcd_available) |
| 117 | + @status = mock("Status", :exitstatus => 0) |
| 118 | + @stdout = StringIO.new(streams["not linked"]["stdout"]) |
| 119 | + @stderr = StringIO.new(streams["not linked"]["stderr"]) |
| 120 | + @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 121 | + end |
| 122 | + |
| 123 | + it "says the service is disabled" do |
| 124 | + @provider.service_currently_enabled?.should be_false |
| 125 | + end |
| 126 | + |
| 127 | + it "stores the 'disabled' state" do |
| 128 | + Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
| 129 | + @provider.load_current_resource.should equal(@current_resource) |
| 130 | + @current_resource.enabled.should be_false |
| 131 | + end |
169 | 132 | end |
170 | 133 | end |
171 | 134 |
|
|
0 commit comments