puppet 3.4.2 → 3.4.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/redhat/puppet.spec.erb +8 -8
- data/lib/puppet/defaults.rb +5 -1
- data/lib/puppet/indirector/resource_type/parser.rb +58 -38
- data/lib/puppet/metatype/manager.rb +0 -1
- data/lib/puppet/network/http/connection.rb +8 -0
- data/lib/puppet/network/http/webrick.rb +4 -1
- data/lib/puppet/node/environment.rb +13 -32
- data/lib/puppet/parser/compiler.rb +1 -2
- data/lib/puppet/parser/functions/each.rb +4 -4
- data/lib/puppet/parser/type_loader.rb +20 -1
- data/lib/puppet/provider/package/dpkg.rb +13 -54
- data/lib/puppet/provider/package/rpm.rb +7 -11
- data/lib/puppet/transaction/resource_harness.rb +17 -17
- data/lib/puppet/type.rb +83 -117
- data/lib/puppet/type/exec.rb +42 -20
- data/lib/puppet/type/file.rb +4 -0
- data/lib/puppet/type/interface.rb +4 -0
- data/lib/puppet/type/mount.rb +4 -2
- data/lib/puppet/type/package.rb +4 -0
- data/lib/puppet/type/schedule.rb +14 -13
- data/lib/puppet/type/service.rb +9 -6
- data/lib/puppet/type/stage.rb +17 -9
- data/lib/puppet/type/user.rb +1 -1
- data/lib/puppet/util/monkey_patches.rb +16 -11
- data/lib/puppet/util/rdoc/code_objects.rb +4 -0
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/file.rb +36 -13
- data/lib/puppet/util/windows/process.rb +7 -4
- data/lib/puppet/util/windows/registry.rb +35 -1
- data/lib/puppet/util/windows/string.rb +14 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/integration/util_spec.rb +31 -0
- data/spec/unit/node/environment_spec.rb +5 -13
- data/spec/unit/provider/package/aptitude_spec.rb +13 -10
- data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
- data/spec/unit/provider/package/dpkg_spec.rb +93 -234
- data/spec/unit/provider/package/rpm_spec.rb +50 -74
- data/spec/unit/provider/package/yum_spec.rb +5 -6
- data/spec/unit/transaction/resource_harness_spec.rb +111 -3
- data/spec/unit/type/user_spec.rb +7 -5
- data/spec/unit/util/windows/registry_spec.rb +54 -0
- data/spec/unit/util/windows/string_spec.rb +54 -0
- data/tasks/benchmark.rake +110 -0
- data/tasks/ci.rake +1 -1
- metadata +11 -15
@@ -4,15 +4,14 @@ require 'spec_helper'
|
|
4
4
|
provider_class = Puppet::Type.type(:package).provider(:rpm)
|
5
5
|
|
6
6
|
describe provider_class do
|
7
|
-
subject { provider_class }
|
8
7
|
|
9
8
|
let (:packages) do
|
10
9
|
<<-RPM_OUTPUT
|
11
|
-
cracklib-dicts 0 2.8.9 3.3 x86_64
|
12
|
-
basesystem 0 8.0 5.1.1.el5.centos noarch
|
13
|
-
chkconfig 0 1.3.30.2 2.el5 x86_64
|
14
|
-
myresource 0 1.2.3.4 5.el4 noarch
|
15
|
-
mysummaryless 0 1.2.3.4 5.el4 noarch
|
10
|
+
cracklib-dicts 0 2.8.9 3.3 x86_64
|
11
|
+
basesystem 0 8.0 5.1.1.el5.centos noarch
|
12
|
+
chkconfig 0 1.3.30.2 2.el5 x86_64
|
13
|
+
myresource 0 1.2.3.4 5.el4 noarch
|
14
|
+
mysummaryless 0 1.2.3.4 5.el4 noarch
|
16
15
|
RPM_OUTPUT
|
17
16
|
end
|
18
17
|
|
@@ -31,7 +30,7 @@ describe provider_class do
|
|
31
30
|
provider
|
32
31
|
end
|
33
32
|
|
34
|
-
let(:nevra_format) { %Q{%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}
|
33
|
+
let(:nevra_format) { %Q{%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\\n} }
|
35
34
|
let(:execute_options) do
|
36
35
|
{:failonfail => true, :combine => true, :custom_environment => {}}
|
37
36
|
end
|
@@ -39,43 +38,43 @@ describe provider_class do
|
|
39
38
|
|
40
39
|
before(:each) do
|
41
40
|
Puppet::Util.stubs(:which).with("rpm").returns("/bin/rpm")
|
42
|
-
|
43
|
-
|
41
|
+
provider_class.stubs(:which).with("rpm").returns("/bin/rpm")
|
42
|
+
provider_class.instance_variable_set("@current_version", nil)
|
44
43
|
Puppet::Type::Package::ProviderRpm.expects(:execute).with(["/bin/rpm", "--version"]).returns(rpm_version).at_most_once
|
45
44
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "--version"], execute_options).returns(rpm_version).at_most_once
|
46
45
|
end
|
47
46
|
|
48
47
|
describe "self.instances" do
|
49
48
|
describe "with a modern version of RPM" do
|
50
|
-
it "
|
49
|
+
it "includes all the modern flags" do
|
51
50
|
Puppet::Util::Execution.expects(:execpipe).with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'").yields(packages)
|
52
51
|
|
53
|
-
installed_packages =
|
52
|
+
installed_packages = provider_class.instances
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
56
|
describe "with a version of RPM < 4.1" do
|
58
57
|
let(:rpm_version) { "RPM version 4.0.2\n" }
|
59
|
-
it "
|
58
|
+
it "excludes the --nosignature flag" do
|
60
59
|
Puppet::Util::Execution.expects(:execpipe).with("/bin/rpm -qa --nodigest --qf '#{nevra_format}'").yields(packages)
|
61
60
|
|
62
|
-
installed_packages =
|
61
|
+
installed_packages = provider_class.instances
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
describe "with a version of RPM < 4.0.2" do
|
67
66
|
let(:rpm_version) { "RPM version 3.0.5\n" }
|
68
|
-
it "
|
67
|
+
it "excludes the --nodigest flag" do
|
69
68
|
Puppet::Util::Execution.expects(:execpipe).with("/bin/rpm -qa --qf '#{nevra_format}'").yields(packages)
|
70
69
|
|
71
|
-
installed_packages =
|
70
|
+
installed_packages = provider_class.instances
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
74
|
it "returns an array of packages" do
|
76
75
|
Puppet::Util::Execution.expects(:execpipe).with("/bin/rpm -qa --nosignature --nodigest --qf '#{nevra_format}'").yields(packages)
|
77
76
|
|
78
|
-
installed_packages =
|
77
|
+
installed_packages = provider_class.instances
|
79
78
|
|
80
79
|
expect(installed_packages[0].properties).to eq(
|
81
80
|
{
|
@@ -86,7 +85,6 @@ describe provider_class do
|
|
86
85
|
:release => "3.3",
|
87
86
|
:arch => "x86_64",
|
88
87
|
:ensure => "2.8.9-3.3",
|
89
|
-
:description => "The standard CrackLib dictionaries",
|
90
88
|
}
|
91
89
|
)
|
92
90
|
expect(installed_packages[1].properties).to eq(
|
@@ -98,7 +96,6 @@ describe provider_class do
|
|
98
96
|
:release => "5.1.1.el5.centos",
|
99
97
|
:arch => "noarch",
|
100
98
|
:ensure => "8.0-5.1.1.el5.centos",
|
101
|
-
:description => "The skeleton package which defines a simple Red Hat Enterprise Linux system",
|
102
99
|
}
|
103
100
|
)
|
104
101
|
expect(installed_packages[2].properties).to eq(
|
@@ -110,7 +107,6 @@ describe provider_class do
|
|
110
107
|
:release => "2.el5",
|
111
108
|
:arch => "x86_64",
|
112
109
|
:ensure => "1.3.30.2-2.el5",
|
113
|
-
:description => "A system tool for maintaining the /etc/rc*.d hierarchy",
|
114
110
|
}
|
115
111
|
)
|
116
112
|
expect(installed_packages.last.properties).to eq(
|
@@ -122,7 +118,6 @@ describe provider_class do
|
|
122
118
|
:release => "5.el4",
|
123
119
|
:arch => "noarch",
|
124
120
|
:ensure => "1.2.3.4-5.el4",
|
125
|
-
:description => "",
|
126
121
|
}
|
127
122
|
)
|
128
123
|
end
|
@@ -138,7 +133,7 @@ describe provider_class do
|
|
138
133
|
end
|
139
134
|
|
140
135
|
describe "when not already installed" do
|
141
|
-
it "
|
136
|
+
it "only includes the '-i' flag" do
|
142
137
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", ["-i"], '/path/to/package'], execute_options)
|
143
138
|
provider.install
|
144
139
|
end
|
@@ -155,7 +150,7 @@ describe provider_class do
|
|
155
150
|
)
|
156
151
|
end
|
157
152
|
|
158
|
-
it "
|
153
|
+
it "includes the options" do
|
159
154
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", ["-i", "-D", "--test=value", "-Q"], '/path/to/package'], execute_options)
|
160
155
|
provider.install
|
161
156
|
end
|
@@ -168,7 +163,7 @@ describe provider_class do
|
|
168
163
|
provider.instance_variable_get('@property_hash')[:ensure] = '1.2.3.3'
|
169
164
|
end
|
170
165
|
|
171
|
-
it "
|
166
|
+
it "includes the '-U --oldpackage' flags" do
|
172
167
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", ["-U", "--oldpackage"], '/path/to/package'], execute_options)
|
173
168
|
provider.install
|
174
169
|
end
|
@@ -176,9 +171,9 @@ describe provider_class do
|
|
176
171
|
end
|
177
172
|
|
178
173
|
describe "#latest" do
|
179
|
-
it "
|
174
|
+
it "retrieves version string after querying rpm for version from source file" do
|
180
175
|
resource.expects(:[]).with(:source).returns('source-string')
|
181
|
-
Puppet::Util::Execution.expects(:execfail).with(["/bin/rpm", "-q", "--qf", nevra_format, "-p", "source-string"], Puppet::Error).returns("myresource 0 1.2.3.4 5.el4 noarch
|
176
|
+
Puppet::Util::Execution.expects(:execfail).with(["/bin/rpm", "-q", "--qf", nevra_format, "-p", "source-string"], Puppet::Error).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
|
182
177
|
expect(provider.latest).to eq("1.2.3.4-5.el4")
|
183
178
|
end
|
184
179
|
end
|
@@ -193,12 +188,12 @@ describe provider_class do
|
|
193
188
|
|
194
189
|
describe "on a modern RPM" do
|
195
190
|
before(:each) do
|
196
|
-
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", nevra_format], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch
|
191
|
+
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '--nosignature', '--nodigest', "--qf", nevra_format], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
|
197
192
|
end
|
198
193
|
|
199
194
|
let(:rpm_version) { "RPM version 4.10.0\n" }
|
200
195
|
|
201
|
-
it "
|
196
|
+
it "includes the architecture in the package name" do
|
202
197
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-e", 'myresource-1.2.3.4-5.el4.noarch'], execute_options).returns('').at_most_once
|
203
198
|
provider.uninstall
|
204
199
|
end
|
@@ -206,12 +201,12 @@ describe provider_class do
|
|
206
201
|
|
207
202
|
describe "on an ancient RPM" do
|
208
203
|
before(:each) do
|
209
|
-
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '', '', '--qf', nevra_format], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch
|
204
|
+
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", "myresource", '', '', '--qf', nevra_format], execute_options).returns("myresource 0 1.2.3.4 5.el4 noarch\n")
|
210
205
|
end
|
211
206
|
|
212
207
|
let(:rpm_version) { "RPM version 3.0.6\n" }
|
213
208
|
|
214
|
-
it "
|
209
|
+
it "excludes the architecture from the package name" do
|
215
210
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-e", 'myresource-1.2.3.4-5.el4'], execute_options).returns('').at_most_once
|
216
211
|
provider.uninstall
|
217
212
|
end
|
@@ -220,8 +215,8 @@ describe provider_class do
|
|
220
215
|
end
|
221
216
|
|
222
217
|
describe "parsing" do
|
223
|
-
def parser_test(rpm_output_string, gold_hash,
|
224
|
-
Puppet.expects(:
|
218
|
+
def parser_test(rpm_output_string, gold_hash, number_of_debug_logs = 0)
|
219
|
+
Puppet.expects(:debug).times(number_of_debug_logs)
|
225
220
|
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", nevra_format], execute_options).returns(rpm_output_string)
|
226
221
|
expect(provider.query).to eq(gold_hash)
|
227
222
|
end
|
@@ -235,16 +230,15 @@ describe provider_class do
|
|
235
230
|
:version => 'version',
|
236
231
|
:release => 'release',
|
237
232
|
:arch => 'arch',
|
238
|
-
:description => 'a description',
|
239
233
|
:provider => :rpm,
|
240
234
|
:ensure => 'version-release',
|
241
235
|
}
|
242
236
|
end
|
243
|
-
let(:line) { 'name epoch version release arch
|
237
|
+
let(:line) { 'name epoch version release arch' }
|
244
238
|
|
245
239
|
['name', 'epoch', 'version', 'release', 'arch'].each do |field|
|
246
240
|
|
247
|
-
it "
|
241
|
+
it "still parses if #{field} is replaced by delimiter" do
|
248
242
|
parser_test(
|
249
243
|
line.gsub(field, delimiter),
|
250
244
|
package_hash.merge(
|
@@ -256,58 +250,40 @@ describe provider_class do
|
|
256
250
|
|
257
251
|
end
|
258
252
|
|
259
|
-
it "
|
260
|
-
parser_test(
|
261
|
-
line.gsub(/#{delimiter} .+$/, delimiter),
|
262
|
-
package_hash.merge(:description => '')
|
263
|
-
)
|
264
|
-
end
|
265
|
-
|
266
|
-
it "should still parse if missing delimeter and description entirely" do
|
267
|
-
parser_test(
|
268
|
-
line.gsub(/ #{delimiter} .+$/, ''),
|
269
|
-
package_hash.merge(:description => nil)
|
270
|
-
)
|
271
|
-
end
|
272
|
-
|
273
|
-
it "should still parse if description contains a new line" do
|
274
|
-
parser_test(
|
275
|
-
line.gsub(/#{delimiter} .+$/, "#{delimiter} whoops\nnewline"),
|
276
|
-
package_hash.merge(:description => 'whoops')
|
277
|
-
)
|
278
|
-
end
|
279
|
-
|
280
|
-
it "should warn but not fail if line is unparseable" do
|
253
|
+
it "does not fail if line is unparseable, but issues a debug log" do
|
281
254
|
parser_test('bad data', {}, 1)
|
282
255
|
end
|
283
256
|
|
284
|
-
it "
|
285
|
-
|
257
|
+
it "does not log or fail if rpm returns package not found" do
|
258
|
+
Puppet.expects(:debug).never
|
259
|
+
Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "-q", resource_name, "--nosignature", "--nodigest", "--qf", nevra_format], execute_options).raises Puppet::ExecutionFailure.new('package not found')
|
260
|
+
|
261
|
+
expect(provider.query).to be_nil
|
286
262
|
end
|
287
263
|
end
|
288
264
|
|
289
265
|
describe "#install_options" do
|
290
|
-
it "
|
291
|
-
provider.install_options.
|
266
|
+
it "returns empty array by default" do
|
267
|
+
expect(provider.install_options).to eq([])
|
292
268
|
end
|
293
269
|
|
294
|
-
it "
|
270
|
+
it "returns install_options when set" do
|
295
271
|
provider.resource[:install_options] = ['-n']
|
296
|
-
provider.install_options.
|
272
|
+
expect(provider.install_options).to eq(['-n'])
|
297
273
|
end
|
298
274
|
|
299
|
-
it "
|
275
|
+
it "returns multiple install_options when set" do
|
300
276
|
provider.resource[:install_options] = ['-L', '/opt/puppet']
|
301
|
-
provider.install_options.
|
277
|
+
expect(provider.install_options).to eq(['-L', '/opt/puppet'])
|
302
278
|
end
|
303
279
|
|
304
|
-
it '
|
280
|
+
it 'returns install_options when set as hash' do
|
305
281
|
provider.resource[:install_options] = { '-Darch' => 'vax' }
|
306
|
-
provider.install_options.
|
282
|
+
expect(provider.install_options).to eq(['-Darch=vax'])
|
307
283
|
end
|
308
|
-
it '
|
284
|
+
it 'returns install_options when an array with hashes' do
|
309
285
|
provider.resource[:install_options] = [ '-L', { '-Darch' => 'vax' }]
|
310
|
-
provider.install_options.
|
286
|
+
expect(provider.install_options).to eq(['-L', '-Darch=vax'])
|
311
287
|
end
|
312
288
|
end
|
313
289
|
|
@@ -320,9 +296,9 @@ describe provider_class do
|
|
320
296
|
'5' => '--nodigest',
|
321
297
|
}.each do |version, expected|
|
322
298
|
describe "when current version is #{version}" do
|
323
|
-
it "
|
324
|
-
|
325
|
-
expect(
|
299
|
+
it "returns #{expected.inspect}" do
|
300
|
+
provider_class.stubs(:current_version).returns(version)
|
301
|
+
expect(provider_class.nodigest).to eq(expected)
|
326
302
|
end
|
327
303
|
end
|
328
304
|
end
|
@@ -336,9 +312,9 @@ describe provider_class do
|
|
336
312
|
'5' => '--nosignature',
|
337
313
|
}.each do |version, expected|
|
338
314
|
describe "when current version is #{version}" do
|
339
|
-
it "
|
340
|
-
|
341
|
-
expect(
|
315
|
+
it "returns #{expected.inspect}" do
|
316
|
+
provider_class.stubs(:current_version).returns(version)
|
317
|
+
expect(provider_class.nosignature).to eq(expected)
|
342
318
|
end
|
343
319
|
end
|
344
320
|
end
|
@@ -114,11 +114,11 @@ describe provider do
|
|
114
114
|
|
115
115
|
let(:packages) do
|
116
116
|
<<-RPM_OUTPUT
|
117
|
-
cracklib-dicts 0 2.8.9 3.3 x86_64
|
118
|
-
basesystem 0 8.0 5.1.1.el5.centos noarch
|
119
|
-
chkconfig 0 1.3.30.2 2.el5 x86_64
|
120
|
-
myresource 0 1.2.3.4 5.el4 noarch
|
121
|
-
mysummaryless 0 1.2.3.4 5.el4 noarch
|
117
|
+
cracklib-dicts 0 2.8.9 3.3 x86_64
|
118
|
+
basesystem 0 8.0 5.1.1.el5.centos noarch
|
119
|
+
chkconfig 0 1.3.30.2 2.el5 x86_64
|
120
|
+
myresource 0 1.2.3.4 5.el4 noarch
|
121
|
+
mysummaryless 0 1.2.3.4 5.el4 noarch
|
122
122
|
RPM_OUTPUT
|
123
123
|
end
|
124
124
|
|
@@ -187,7 +187,6 @@ _pkg mysummaryless 0 1.2.3.4 5.el4 noarch
|
|
187
187
|
:version=>"1.2.3.4",
|
188
188
|
:release=>"5.el4",
|
189
189
|
:arch=>"noarch",
|
190
|
-
:description=>nil,
|
191
190
|
:provider=>:yum,
|
192
191
|
:ensure=>"1.2.3.4-5.el4"
|
193
192
|
})
|
@@ -159,6 +159,115 @@ describe Puppet::Transaction::ResourceHarness do
|
|
159
159
|
stubProvider
|
160
160
|
end
|
161
161
|
|
162
|
+
|
163
|
+
context "interaction of ensure with other properties" do
|
164
|
+
def an_ensurable_resource_reacting_as(behaviors)
|
165
|
+
stub_type = Class.new(Puppet::Type)
|
166
|
+
stub_type.class_eval do
|
167
|
+
initvars
|
168
|
+
ensurable do
|
169
|
+
def sync
|
170
|
+
(@resource.behaviors[:on_ensure] || proc {}).call
|
171
|
+
end
|
172
|
+
|
173
|
+
def insync?(value)
|
174
|
+
@resource.behaviors[:ensure_insync?]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
newparam(:name) do
|
179
|
+
desc "The name var"
|
180
|
+
isnamevar
|
181
|
+
end
|
182
|
+
|
183
|
+
newproperty(:prop) do
|
184
|
+
newvalue("new") do
|
185
|
+
#noop
|
186
|
+
end
|
187
|
+
|
188
|
+
def retrieve
|
189
|
+
"old"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
attr_reader :behaviors
|
194
|
+
|
195
|
+
def initialize(options)
|
196
|
+
@behaviors = options.delete(:behaviors)
|
197
|
+
super
|
198
|
+
end
|
199
|
+
|
200
|
+
def exists?
|
201
|
+
@behaviors[:present?]
|
202
|
+
end
|
203
|
+
|
204
|
+
def present?(resource)
|
205
|
+
@behaviors[:present?]
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.name
|
209
|
+
"Testing"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
stub_type.new(:behaviors => behaviors,
|
213
|
+
:ensure => :present,
|
214
|
+
:name => "testing",
|
215
|
+
:prop => "new")
|
216
|
+
end
|
217
|
+
|
218
|
+
it "ensure errors means that the rest doesn't happen" do
|
219
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => false, :on_ensure => proc { raise StandardError }, :present? => true)
|
220
|
+
|
221
|
+
status = @harness.evaluate(resource)
|
222
|
+
|
223
|
+
expect(status.events.length).to eq(1)
|
224
|
+
expect(status.events[0].property).to eq('ensure')
|
225
|
+
expect(status.events[0].name.to_s).to eq('Testing_created')
|
226
|
+
expect(status.events[0].status).to eq('failure')
|
227
|
+
end
|
228
|
+
|
229
|
+
it "ensure fails completely means that the rest doesn't happen" do
|
230
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => false, :on_ensure => proc { raise Exception }, :present? => false)
|
231
|
+
|
232
|
+
expect do
|
233
|
+
@harness.evaluate(resource)
|
234
|
+
end.to raise_error(Exception)
|
235
|
+
|
236
|
+
@logs.first.message.should == "change from absent to present failed: Exception"
|
237
|
+
@logs.first.level.should == :err
|
238
|
+
end
|
239
|
+
|
240
|
+
it "ensure succeeds means that the rest doesn't happen" do
|
241
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => false, :on_ensure => proc { }, :present? => true)
|
242
|
+
|
243
|
+
status = @harness.evaluate(resource)
|
244
|
+
|
245
|
+
expect(status.events.length).to eq(1)
|
246
|
+
expect(status.events[0].property).to eq('ensure')
|
247
|
+
expect(status.events[0].name.to_s).to eq('Testing_created')
|
248
|
+
expect(status.events[0].status).to eq('success')
|
249
|
+
end
|
250
|
+
|
251
|
+
it "ensure is in sync means that the rest *does* happen" do
|
252
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => true, :present? => true)
|
253
|
+
|
254
|
+
status = @harness.evaluate(resource)
|
255
|
+
|
256
|
+
expect(status.events.length).to eq(1)
|
257
|
+
expect(status.events[0].property).to eq('prop')
|
258
|
+
expect(status.events[0].name.to_s).to eq('prop_changed')
|
259
|
+
expect(status.events[0].status).to eq('success')
|
260
|
+
end
|
261
|
+
|
262
|
+
it "ensure is in sync but resource not present, means that the rest doesn't happen" do
|
263
|
+
resource = an_ensurable_resource_reacting_as(:ensure_insync? => true, :present? => false)
|
264
|
+
|
265
|
+
status = @harness.evaluate(resource)
|
266
|
+
|
267
|
+
expect(status.events).to be_empty
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
162
271
|
describe "when a caught error occurs" do
|
163
272
|
before :each do
|
164
273
|
stub_provider = make_stub_provider
|
@@ -227,9 +336,8 @@ describe Puppet::Transaction::ResourceHarness do
|
|
227
336
|
resource = stub_provider.new :name => 'name', :audit => ['foo']
|
228
337
|
resource.property(:foo).expects(:insync?).never
|
229
338
|
status = @harness.evaluate(resource)
|
230
|
-
|
231
|
-
|
232
|
-
end
|
339
|
+
|
340
|
+
expect(status.events).to be_empty
|
233
341
|
end
|
234
342
|
|
235
343
|
it "should be able to audit a file's group" do # see bug #5710
|