chef 11.14.0.alpha.4 → 11.14.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +0 -4
- data/README.md +1 -1
- data/distro/common/man/man1/chef-shell.1 +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +14 -11
- data/distro/common/man/man1/knife-client.1 +14 -11
- data/distro/common/man/man1/knife-configure.1 +7 -7
- data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
- data/distro/common/man/man1/knife-cookbook.1 +23 -23
- data/distro/common/man/man1/knife-data-bag.1 +13 -13
- data/distro/common/man/man1/knife-delete.1 +9 -9
- data/distro/common/man/man1/knife-deps.1 +9 -9
- data/distro/common/man/man1/knife-diff.1 +10 -10
- data/distro/common/man/man1/knife-download.1 +9 -9
- data/distro/common/man/man1/knife-edit.1 +7 -7
- data/distro/common/man/man1/knife-environment.1 +10 -10
- data/distro/common/man/man1/knife-exec.1 +7 -7
- data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
- data/distro/common/man/man1/knife-list.1 +12 -12
- data/distro/common/man/man1/knife-node.1 +12 -9
- data/distro/common/man/man1/knife-raw.1 +7 -7
- data/distro/common/man/man1/knife-recipe-list.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +8 -8
- data/distro/common/man/man1/knife-search.1 +9 -9
- data/distro/common/man/man1/knife-serve.1 +109 -0
- data/distro/common/man/man1/knife-show.1 +8 -8
- data/distro/common/man/man1/knife-ssh.1 +9 -9
- data/distro/common/man/man1/knife-ssl-check.1 +9 -9
- data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
- data/distro/common/man/man1/knife-status.1 +9 -9
- data/distro/common/man/man1/knife-tag.1 +7 -7
- data/distro/common/man/man1/knife-upload.1 +10 -10
- data/distro/common/man/man1/knife-user.1 +9 -9
- data/distro/common/man/man1/knife-xargs.1 +7 -7
- data/distro/common/man/man1/knife.1 +118 -14
- data/distro/common/man/man8/chef-client.8 +13 -10
- data/distro/common/man/man8/chef-solo.8 +13 -14
- data/distro/common/markdown/man1/knife.mkd +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/application/windows_service.rb +0 -1
- data/lib/chef/chef_fs/file_system.rb +6 -2
- data/lib/chef/config.rb +3 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +20 -14
- data/lib/chef/cookbook/synchronizer.rb +24 -13
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
- data/lib/chef/http.rb +6 -1
- data/lib/chef/http/http_request.rb +9 -1
- data/lib/chef/http/simple.rb +2 -1
- data/lib/chef/json_compat.rb +5 -16
- data/lib/chef/knife/bootstrap.rb +2 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/core/object_loader.rb +3 -1
- data/lib/chef/knife/ssh.rb +14 -7
- data/lib/chef/mixin/convert_to_class_name.rb +1 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
- data/lib/chef/platform/provider_mapping.rb +13 -0
- data/lib/chef/provider/env/windows.rb +3 -6
- data/lib/chef/provider/git.rb +1 -2
- data/lib/chef/provider/log.rb +15 -1
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +35 -16
- data/lib/chef/provider/package/paludis.rb +91 -0
- data/lib/chef/provider/package/rpm.rb +3 -2
- data/lib/chef/provider/package/yum-dump.py +6 -6
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/registry_key.rb +4 -5
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +2 -1
- data/lib/chef/provider/service/windows.rb +37 -9
- data/lib/chef/provider/user/pw.rb +1 -1
- data/lib/chef/provider/user/useradd.rb +1 -1
- data/lib/chef/provider/windows_script.rb +2 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +10 -0
- data/lib/chef/resource/file.rb +0 -9
- data/lib/chef/resource/package.rb +14 -4
- data/lib/chef/resource/paludis_package.rb +33 -0
- data/lib/chef/resource/registry_key.rb +62 -3
- data/lib/chef/resource/service.rb +21 -4
- data/lib/chef/resource_reporter.rb +10 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +14 -10
- data/lib/chef/shell.rb +8 -0
- data/lib/chef/shell/shell_session.rb +3 -3
- data/lib/chef/user.rb +12 -11
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +6 -5
- data/lib/chef/win32/api/process.rb +1 -0
- data/lib/chef/win32/api/system.rb +14 -0
- data/lib/chef/win32/error.rb +1 -1
- data/lib/chef/win32/security.rb +5 -5
- data/lib/chef/win32/version.rb +6 -2
- data/spec/data/trusted_certs/opscode.pem +57 -35
- data/spec/functional/application_spec.rb +2 -2
- data/spec/functional/resource/mount_spec.rb +3 -1
- data/spec/functional/shell_spec.rb +10 -0
- data/spec/functional/tiny_server_spec.rb +2 -2
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/securable_resource.rb +11 -2
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
- data/spec/tiny_server.rb +1 -1
- data/spec/unit/config_spec.rb +5 -0
- data/spec/unit/cookbook/metadata_spec.rb +24 -0
- data/spec/unit/environment_spec.rb +6 -0
- data/spec/unit/http/http_request_spec.rb +91 -0
- data/spec/unit/http_spec.rb +23 -0
- data/spec/unit/knife/bootstrap_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +7 -13
- data/spec/unit/knife_spec.rb +1 -1
- data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
- data/spec/unit/provider/git_spec.rb +2 -2
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/mount/solaris_spec.rb +3 -1
- data/spec/unit/provider/package/apt_spec.rb +85 -40
- data/spec/unit/provider/package/dpkg_spec.rb +24 -48
- data/spec/unit/provider/package/paludis_spec.rb +135 -0
- data/spec/unit/provider/package/rpm_spec.rb +40 -32
- data/spec/unit/provider/package/yum_spec.rb +11 -4
- data/spec/unit/provider/registry_key_spec.rb +67 -53
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
- data/spec/unit/provider/service/windows_spec.rb +72 -0
- data/spec/unit/provider/user/pw_spec.rb +21 -4
- data/spec/unit/provider/user/useradd_spec.rb +10 -0
- data/spec/unit/resource/package_spec.rb +26 -18
- data/spec/unit/resource/registry_key_spec.rb +28 -0
- data/spec/unit/resource/service_spec.rb +14 -0
- data/spec/unit/resource_reporter_spec.rb +37 -12
- data/spec/unit/resource_spec.rb +41 -6
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/role_spec.rb +46 -28
- data/spec/unit/shell/shell_session_spec.rb +42 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/user_spec.rb +12 -0
- data/spec/unit/util/selinux_spec.rb +4 -4
- data/spec/unit/version_constraint_spec.rb +14 -2
- metadata +195 -161
- checksums.yaml +0 -7
@@ -78,4 +78,22 @@ describe Chef::Provider::Log::ChefLog do
|
|
78
78
|
@provider.action_write
|
79
79
|
end
|
80
80
|
|
81
|
+
it "should not update the resource if the message was not written to the log" do
|
82
|
+
Chef::Log.level = :fatal
|
83
|
+
@new_resource = Chef::Resource::Log.new(@log_str)
|
84
|
+
@new_resource.level :info
|
85
|
+
@provider = Chef::Provider::Log::ChefLog.new(@new_resource, @run_context)
|
86
|
+
@provider.action_write
|
87
|
+
@new_resource.updated.should be_false
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should update the resource if the message has been written to the log" do
|
91
|
+
Chef::Log.level = :debug
|
92
|
+
@new_resource = Chef::Resource::Log.new(@log_str)
|
93
|
+
@new_resource.level :info
|
94
|
+
@provider = Chef::Provider::Log::ChefLog.new(@new_resource, @run_context)
|
95
|
+
@provider.action_write
|
96
|
+
@new_resource.updated.should be_true
|
97
|
+
end
|
98
|
+
|
81
99
|
end
|
@@ -19,7 +19,9 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
require 'ostruct'
|
21
21
|
|
22
|
-
|
22
|
+
# Do not run these tests on windows because some path handling
|
23
|
+
# code is not implemented to handle windows paths.
|
24
|
+
describe Chef::Provider::Mount::Solaris, :unix_only do
|
23
25
|
let(:node) { Chef::Node.new }
|
24
26
|
|
25
27
|
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
@@ -39,12 +39,16 @@ irssi:
|
|
39
39
|
PKG_STATUS
|
40
40
|
@stderr = ""
|
41
41
|
@shell_out = OpenStruct.new(:stdout => @stdout,:stdin => @stdin,:stderr => @stderr,:status => @status,:exitstatus => 0)
|
42
|
+
@timeout = 900
|
42
43
|
end
|
43
44
|
|
44
45
|
describe "when loading current resource" do
|
45
46
|
|
46
47
|
it "should create a current resource with the name of the new_resource" do
|
47
|
-
@provider.should_receive(:shell_out!).with(
|
48
|
+
@provider.should_receive(:shell_out!).with(
|
49
|
+
"apt-cache policy #{@new_resource.package_name}",
|
50
|
+
:timeout => @timeout
|
51
|
+
).and_return(@shell_out)
|
48
52
|
@provider.load_current_resource
|
49
53
|
|
50
54
|
current_resource = @provider.current_resource
|
@@ -84,7 +88,10 @@ libmysqlclient15-dev:
|
|
84
88
|
Version table:
|
85
89
|
VPKG_STDOUT
|
86
90
|
virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
|
87
|
-
@provider.should_receive(:shell_out!).with(
|
91
|
+
@provider.should_receive(:shell_out!).with(
|
92
|
+
"apt-cache policy libmysqlclient15-dev",
|
93
|
+
:timeout => @timeout
|
94
|
+
).and_return(virtual_package)
|
88
95
|
showpkg_out =<<-SHOWPKG_STDOUT
|
89
96
|
Package: libmysqlclient15-dev
|
90
97
|
Versions:
|
@@ -104,7 +111,10 @@ libmysqlclient-dev 5.1.41-3ubuntu12.10
|
|
104
111
|
libmysqlclient-dev 5.1.41-3ubuntu12
|
105
112
|
SHOWPKG_STDOUT
|
106
113
|
showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
|
107
|
-
@provider.should_receive(:shell_out!).with(
|
114
|
+
@provider.should_receive(:shell_out!).with(
|
115
|
+
"apt-cache showpkg libmysqlclient15-dev",
|
116
|
+
:timeout => @timeout
|
117
|
+
).and_return(showpkg)
|
108
118
|
real_package_out=<<-RPKG_STDOUT
|
109
119
|
libmysqlclient-dev:
|
110
120
|
Installed: 5.1.41-3ubuntu12.10
|
@@ -119,7 +129,10 @@ libmysqlclient-dev:
|
|
119
129
|
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
|
120
130
|
RPKG_STDOUT
|
121
131
|
real_package = double(:stdout => real_package_out,:exitstatus => 0)
|
122
|
-
@provider.should_receive(:shell_out!).with(
|
132
|
+
@provider.should_receive(:shell_out!).with(
|
133
|
+
"apt-cache policy libmysqlclient-dev",
|
134
|
+
:timeout => @timeout
|
135
|
+
).and_return(real_package)
|
123
136
|
@provider.load_current_resource
|
124
137
|
end
|
125
138
|
|
@@ -132,7 +145,10 @@ mp3-decoder:
|
|
132
145
|
Version table:
|
133
146
|
VPKG_STDOUT
|
134
147
|
virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
|
135
|
-
@provider.should_receive(:shell_out!).with(
|
148
|
+
@provider.should_receive(:shell_out!).with(
|
149
|
+
"apt-cache policy mp3-decoder",
|
150
|
+
:timeout => @timeout
|
151
|
+
).and_return(virtual_package)
|
136
152
|
showpkg_out=<<-SHOWPKG_STDOUT
|
137
153
|
Package: mp3-decoder
|
138
154
|
Versions:
|
@@ -155,7 +171,10 @@ mpg321 0.2.10.6
|
|
155
171
|
mpg123 1.12.1-0ubuntu1
|
156
172
|
SHOWPKG_STDOUT
|
157
173
|
showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
|
158
|
-
@provider.should_receive(:shell_out!).with(
|
174
|
+
@provider.should_receive(:shell_out!).with(
|
175
|
+
"apt-cache showpkg mp3-decoder",
|
176
|
+
:timeout => @timeout
|
177
|
+
).and_return(showpkg)
|
159
178
|
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
|
160
179
|
end
|
161
180
|
|
@@ -165,13 +184,17 @@ SHOWPKG_STDOUT
|
|
165
184
|
|
166
185
|
@new_resource.stub(:default_release).and_return("lenny-backports")
|
167
186
|
@new_resource.stub(:provider).and_return("Chef::Provider::Package::Apt")
|
168
|
-
@provider.should_receive(:shell_out!).with(
|
187
|
+
@provider.should_receive(:shell_out!).with(
|
188
|
+
"apt-cache -o APT::Default-Release=lenny-backports policy irssi",
|
189
|
+
:timeout => @timeout
|
190
|
+
).and_return(@shell_out)
|
169
191
|
@provider.load_current_resource
|
170
192
|
end
|
171
193
|
|
172
194
|
it "raises an exception if a source is specified (CHEF-5113)" do
|
173
195
|
@new_resource.source "pluto"
|
174
196
|
@provider.define_resource_requirements
|
197
|
+
@provider.should_receive(:shell_out!).with("apt-cache policy irssi", {:timeout=>900}).and_return(@shell_out)
|
175
198
|
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
176
199
|
end
|
177
200
|
end
|
@@ -184,16 +207,20 @@ SHOWPKG_STDOUT
|
|
184
207
|
|
185
208
|
describe "install_package" do
|
186
209
|
it "should run apt-get install with the package name and version" do
|
187
|
-
@provider.should_receive(:shell_out!).
|
188
|
-
|
189
|
-
|
210
|
+
@provider.should_receive(:shell_out!). with(
|
211
|
+
"apt-get -q -y install irssi=0.8.12-7",
|
212
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
213
|
+
:timeout => @timeout
|
214
|
+
)
|
190
215
|
@provider.install_package("irssi", "0.8.12-7")
|
191
216
|
end
|
192
217
|
|
193
218
|
it "should run apt-get install with the package name and version and options if specified" do
|
194
|
-
@provider.should_receive(:shell_out!).
|
195
|
-
|
196
|
-
|
219
|
+
@provider.should_receive(:shell_out!).with(
|
220
|
+
"apt-get -q -y --force-yes install irssi=0.8.12-7",
|
221
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
222
|
+
:timeout => @timeout
|
223
|
+
)
|
197
224
|
@new_resource.options("--force-yes")
|
198
225
|
@provider.install_package("irssi", "0.8.12-7")
|
199
226
|
end
|
@@ -205,9 +232,11 @@ SHOWPKG_STDOUT
|
|
205
232
|
|
206
233
|
@provider.new_resource = @new_resource
|
207
234
|
|
208
|
-
@provider.should_receive(:shell_out!).
|
209
|
-
|
210
|
-
|
235
|
+
@provider.should_receive(:shell_out!).with(
|
236
|
+
"apt-get -q -y -o APT::Default-Release=lenny-backports install irssi=0.8.12-7",
|
237
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
238
|
+
:timeout => @timeout
|
239
|
+
)
|
211
240
|
|
212
241
|
@provider.install_package("irssi", "0.8.12-7")
|
213
242
|
end
|
@@ -224,16 +253,20 @@ SHOWPKG_STDOUT
|
|
224
253
|
describe Chef::Provider::Package::Apt, "remove_package" do
|
225
254
|
|
226
255
|
it "should run apt-get remove with the package name" do
|
227
|
-
@provider.should_receive(:shell_out!).
|
228
|
-
|
229
|
-
|
256
|
+
@provider.should_receive(:shell_out!).with(
|
257
|
+
"apt-get -q -y remove irssi",
|
258
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
259
|
+
:timeout => @timeout
|
260
|
+
)
|
230
261
|
@provider.remove_package("irssi", "0.8.12-7")
|
231
262
|
end
|
232
263
|
|
233
264
|
it "should run apt-get remove with the package name and options if specified" do
|
234
|
-
@provider.should_receive(:shell_out!).
|
235
|
-
|
236
|
-
|
265
|
+
@provider.should_receive(:shell_out!).with(
|
266
|
+
"apt-get -q -y --force-yes remove irssi",
|
267
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
268
|
+
:timeout => @timeout
|
269
|
+
)
|
237
270
|
@new_resource.options("--force-yes")
|
238
271
|
|
239
272
|
@provider.remove_package("irssi", "0.8.12-7")
|
@@ -243,16 +276,20 @@ SHOWPKG_STDOUT
|
|
243
276
|
describe "when purging a package" do
|
244
277
|
|
245
278
|
it "should run apt-get purge with the package name" do
|
246
|
-
@provider.should_receive(:shell_out!).
|
247
|
-
|
248
|
-
|
279
|
+
@provider.should_receive(:shell_out!).with(
|
280
|
+
"apt-get -q -y purge irssi",
|
281
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
282
|
+
:timeout => @timeout
|
283
|
+
)
|
249
284
|
@provider.purge_package("irssi", "0.8.12-7")
|
250
285
|
end
|
251
286
|
|
252
287
|
it "should run apt-get purge with the package name and options if specified" do
|
253
|
-
@provider.should_receive(:shell_out!).
|
254
|
-
|
255
|
-
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }
|
288
|
+
@provider.should_receive(:shell_out!).with(
|
289
|
+
"apt-get -q -y --force-yes purge irssi",
|
290
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
291
|
+
:timeout => @timeout
|
292
|
+
)
|
256
293
|
@new_resource.options("--force-yes")
|
257
294
|
|
258
295
|
@provider.purge_package("irssi", "0.8.12-7")
|
@@ -268,17 +305,21 @@ SHOWPKG_STDOUT
|
|
268
305
|
@provider.should_receive(:get_preseed_file).with("irssi", "0.8.12-7").and_return("/tmp/irssi-0.8.12-7.seed")
|
269
306
|
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
270
307
|
|
271
|
-
@provider.should_receive(:shell_out!).
|
272
|
-
|
273
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}
|
308
|
+
@provider.should_receive(:shell_out!).with(
|
309
|
+
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
310
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
311
|
+
:timeout => @timeout
|
312
|
+
)
|
274
313
|
|
275
314
|
@provider.preseed_package(file)
|
276
315
|
end
|
277
316
|
|
278
317
|
it "should run debconf-set-selections on the preseed file if it has changed" do
|
279
|
-
@provider.should_receive(:shell_out!).
|
280
|
-
|
281
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil}
|
318
|
+
@provider.should_receive(:shell_out!).with(
|
319
|
+
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
320
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
321
|
+
:timeout => @timeout
|
322
|
+
)
|
282
323
|
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
283
324
|
@provider.preseed_package(file)
|
284
325
|
end
|
@@ -295,9 +336,11 @@ SHOWPKG_STDOUT
|
|
295
336
|
|
296
337
|
describe "when reconfiguring a package" do
|
297
338
|
it "should run dpkg-reconfigure package" do
|
298
|
-
@provider.should_receive(:shell_out!).
|
299
|
-
|
300
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }
|
339
|
+
@provider.should_receive(:shell_out!).with(
|
340
|
+
"dpkg-reconfigure irssi",
|
341
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
342
|
+
:timeout => @timeout
|
343
|
+
)
|
301
344
|
@provider.reconfig_package("irssi", "0.8.12-7")
|
302
345
|
end
|
303
346
|
end
|
@@ -305,9 +348,11 @@ SHOWPKG_STDOUT
|
|
305
348
|
describe "when installing a virtual package" do
|
306
349
|
it "should install the package without specifying a version" do
|
307
350
|
@provider.is_virtual_package = true
|
308
|
-
@provider.should_receive(:shell_out!).
|
309
|
-
|
310
|
-
|
351
|
+
@provider.should_receive(:shell_out!).with(
|
352
|
+
"apt-get -q -y install libmysqlclient-dev",
|
353
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
354
|
+
:timeout => @timeout
|
355
|
+
)
|
311
356
|
@provider.install_package("libmysqlclient-dev", "not_a_real_version")
|
312
357
|
end
|
313
358
|
end
|
@@ -122,46 +122,34 @@ DPKG_S
|
|
122
122
|
|
123
123
|
describe Chef::Provider::Package::Dpkg, "install and upgrade" do
|
124
124
|
it "should run dpkg -i with the package source" do
|
125
|
-
@provider.should_receive(:
|
126
|
-
|
127
|
-
|
128
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
129
|
-
}
|
130
|
-
})
|
125
|
+
@provider.should_receive(:run_noninteractive).with(
|
126
|
+
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
127
|
+
)
|
131
128
|
@provider.install_package("wget", "1.11.4-1ubuntu1")
|
132
129
|
end
|
133
130
|
|
134
131
|
it "should run dpkg -i if the package is a path and the source is nil" do
|
135
132
|
@new_resource = Chef::Resource::Package.new("/tmp/wget_1.11.4-1ubuntu1_amd64.deb")
|
136
133
|
@provider = Chef::Provider::Package::Dpkg.new(@new_resource, @run_context)
|
137
|
-
@provider.should_receive(:
|
138
|
-
|
139
|
-
|
140
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
141
|
-
}
|
142
|
-
})
|
134
|
+
@provider.should_receive(:run_noninteractive).with(
|
135
|
+
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
136
|
+
)
|
143
137
|
@provider.install_package("/tmp/wget_1.11.4-1ubuntu1_amd64.deb", "1.11.4-1ubuntu1")
|
144
138
|
end
|
145
139
|
|
146
140
|
it "should run dpkg -i if the package is a path and the source is nil for an upgrade" do
|
147
141
|
@new_resource = Chef::Resource::Package.new("/tmp/wget_1.11.4-1ubuntu1_amd64.deb")
|
148
142
|
@provider = Chef::Provider::Package::Dpkg.new(@new_resource, @run_context)
|
149
|
-
@provider.should_receive(:
|
150
|
-
|
151
|
-
|
152
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
153
|
-
}
|
154
|
-
})
|
143
|
+
@provider.should_receive(:run_noninteractive).with(
|
144
|
+
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
145
|
+
)
|
155
146
|
@provider.upgrade_package("/tmp/wget_1.11.4-1ubuntu1_amd64.deb", "1.11.4-1ubuntu1")
|
156
147
|
end
|
157
148
|
|
158
149
|
it "should run dpkg -i with the package source and options if specified" do
|
159
|
-
@provider.should_receive(:
|
160
|
-
|
161
|
-
|
162
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
163
|
-
}
|
164
|
-
})
|
150
|
+
@provider.should_receive(:run_noninteractive).with(
|
151
|
+
"dpkg -i --force-yes /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
152
|
+
)
|
165
153
|
@new_resource.stub(:options).and_return("--force-yes")
|
166
154
|
|
167
155
|
@provider.install_package("wget", "1.11.4-1ubuntu1")
|
@@ -174,44 +162,32 @@ DPKG_S
|
|
174
162
|
|
175
163
|
describe Chef::Provider::Package::Dpkg, "remove and purge" do
|
176
164
|
it "should run dpkg -r to remove the package" do
|
177
|
-
@provider.should_receive(:
|
178
|
-
|
179
|
-
|
180
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
181
|
-
}
|
182
|
-
})
|
165
|
+
@provider.should_receive(:run_noninteractive).with(
|
166
|
+
"dpkg -r wget"
|
167
|
+
)
|
183
168
|
@provider.remove_package("wget", "1.11.4-1ubuntu1")
|
184
169
|
end
|
185
170
|
|
186
171
|
it "should run dpkg -r to remove the package with options if specified" do
|
187
|
-
@provider.should_receive(:
|
188
|
-
|
189
|
-
|
190
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
191
|
-
}
|
192
|
-
})
|
172
|
+
@provider.should_receive(:run_noninteractive).with(
|
173
|
+
"dpkg -r --force-yes wget"
|
174
|
+
)
|
193
175
|
@new_resource.stub(:options).and_return("--force-yes")
|
194
176
|
|
195
177
|
@provider.remove_package("wget", "1.11.4-1ubuntu1")
|
196
178
|
end
|
197
179
|
|
198
180
|
it "should run dpkg -P to purge the package" do
|
199
|
-
@provider.should_receive(:
|
200
|
-
|
201
|
-
|
202
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
203
|
-
}
|
204
|
-
})
|
181
|
+
@provider.should_receive(:run_noninteractive).with(
|
182
|
+
"dpkg -P wget"
|
183
|
+
)
|
205
184
|
@provider.purge_package("wget", "1.11.4-1ubuntu1")
|
206
185
|
end
|
207
186
|
|
208
187
|
it "should run dpkg -P to purge the package with options if specified" do
|
209
|
-
@provider.should_receive(:
|
210
|
-
|
211
|
-
|
212
|
-
"DEBIAN_FRONTEND" => "noninteractive"
|
213
|
-
}
|
214
|
-
})
|
188
|
+
@provider.should_receive(:run_noninteractive).with(
|
189
|
+
"dpkg -P --force-yes wget"
|
190
|
+
)
|
215
191
|
@new_resource.stub(:options).and_return("--force-yes")
|
216
192
|
|
217
193
|
@provider.purge_package("wget", "1.11.4-1ubuntu1")
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Vasiliy Tolstov <v.tolstov@selfip.ru>
|
3
|
+
# Copyright:: Copyright (c) 2014 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
require 'ostruct'
|
21
|
+
|
22
|
+
# based on the ips specs
|
23
|
+
|
24
|
+
describe Chef::Provider::Package::Paludis do
|
25
|
+
before(:each) do
|
26
|
+
@node = Chef::Node.new
|
27
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
28
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
29
|
+
@new_resource = Chef::Resource::Package.new("net/ntp")
|
30
|
+
@current_resource = Chef::Resource::Package.new("net/ntp")
|
31
|
+
Chef::Resource::Package.stub(:new).and_return(@current_resource)
|
32
|
+
@provider = Chef::Provider::Package::Paludis.new(@new_resource, @run_context)
|
33
|
+
|
34
|
+
@stdin = StringIO.new
|
35
|
+
@stderr = StringIO.new
|
36
|
+
@stdout =<<-PKG_STATUS
|
37
|
+
group/ntp 0 accounts
|
38
|
+
group/ntp 0 installed-accounts
|
39
|
+
net/ntp 4.2.6_p5-r2 arbor
|
40
|
+
user/ntp 0 accounts
|
41
|
+
user/ntp 0 installed-accounts
|
42
|
+
net/ntp 4.2.6_p5-r1 installed
|
43
|
+
PKG_STATUS
|
44
|
+
@pid = 12345
|
45
|
+
@shell_out = OpenStruct.new(:stdout => @stdout,:stdin => @stdin,:stderr => @stderr,:status => @status,:exitstatus => 0)
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when loading current resource" do
|
49
|
+
it "should create a current resource with the name of the new_resource" do
|
50
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
51
|
+
Chef::Resource::Package.should_receive(:new).and_return(@current_resource)
|
52
|
+
@provider.load_current_resource
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set the current resources package name to the new resources package name" do
|
56
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
57
|
+
@current_resource.should_receive(:package_name).with(@new_resource.package_name)
|
58
|
+
@provider.load_current_resource
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should run pkg info with the package name" do
|
62
|
+
@provider.should_receive(:shell_out!).with("cave -L warning print-ids -m \"*/#{@new_resource.package_name.split('/').last}\" -f \"%c/%p %v %r\n\"").and_return(@shell_out)
|
63
|
+
@provider.load_current_resource
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return new version if package is installed" do
|
67
|
+
@stdout.replace(<<-INSTALLED)
|
68
|
+
group/ntp 0 accounts
|
69
|
+
group/ntp 0 installed-accounts
|
70
|
+
net/ntp 4.2.6_p5-r2 arbor
|
71
|
+
user/ntp 0 accounts
|
72
|
+
user/ntp 0 installed-accounts
|
73
|
+
net/ntp 4.2.6_p5-r1 installed
|
74
|
+
INSTALLED
|
75
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
76
|
+
@provider.load_current_resource
|
77
|
+
@current_resource.version.should == "4.2.6_p5-r1"
|
78
|
+
@provider.candidate_version.should eql("4.2.6_p5-r2")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return the current resource" do
|
82
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
83
|
+
@provider.load_current_resource.should eql(@current_resource)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when installing a package" do
|
88
|
+
it "should run pkg install with the package name and version" do
|
89
|
+
@provider.should_receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"")
|
90
|
+
@provider.install_package("net/ntp", "4.2.6_p5-r2")
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
it "should run pkg install with the package name and version and options if specified" do
|
95
|
+
@provider.should_receive(:shell_out!).with("cave -L warning resolve -x --preserve-world \"=net/ntp-4.2.6_p5-r2\"")
|
96
|
+
@new_resource.stub(:options).and_return("--preserve-world")
|
97
|
+
@provider.install_package("net/ntp", "4.2.6_p5-r2")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not contain invalid characters for the version string" do
|
101
|
+
@stdout.replace(<<-PKG_STATUS)
|
102
|
+
sys-process/lsof 4.87 arbor
|
103
|
+
sys-process/lsof 4.87 x86_64
|
104
|
+
PKG_STATUS
|
105
|
+
@provider.should_receive(:shell_out!).with("cave -L warning resolve -x \"=sys-process/lsof-4.87\"")
|
106
|
+
@provider.install_package("sys-process/lsof", "4.87")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should not include the human-readable version in the candidate_version" do
|
110
|
+
@stdout.replace(<<-PKG_STATUS)
|
111
|
+
sys-process/lsof 4.87 arbor
|
112
|
+
sys-process/lsof 4.87 x86_64
|
113
|
+
PKG_STATUS
|
114
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
115
|
+
@provider.load_current_resource
|
116
|
+
@current_resource.version.should be_nil
|
117
|
+
@provider.candidate_version.should eql("4.87")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when upgrading a package" do
|
122
|
+
it "should run pkg install with the package name and version" do
|
123
|
+
@provider.should_receive(:shell_out!).with("cave -L warning resolve -x \"=net/ntp-4.2.6_p5-r2\"")
|
124
|
+
@provider.upgrade_package("net/ntp", "4.2.6_p5-r2")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when uninstalling a package" do
|
129
|
+
it "should run pkg uninstall with the package name and version" do
|
130
|
+
@provider.should_receive(:shell_out!).with("cave -L warning uninstall -x \"=net/ntp-4.2.6_p5-r2\"")
|
131
|
+
@provider.remove_package("net/ntp", "4.2.6_p5-r2")
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|