puppet 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +61 -0
- data/ext/envpuppet +80 -0
- data/ext/puppet-load.rb +62 -26
- data/ext/puppetstoredconfigclean.rb +0 -2
- data/lib/puppet.rb +1 -1
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +10 -8
- data/lib/puppet/external/pson/pure/generator.rb +5 -12
- data/lib/puppet/indirector/catalog/compiler.rb +8 -4
- data/lib/puppet/network/handler/fileserver.rb +2 -0
- data/lib/puppet/network/server.rb +2 -2
- data/lib/puppet/node/environment.rb +4 -0
- data/lib/puppet/parser/ast/collection.rb +34 -51
- data/lib/puppet/parser/ast/leaf.rb +10 -2
- data/lib/puppet/parser/ast/resource.rb +4 -3
- data/lib/puppet/parser/compiler.rb +2 -2
- data/lib/puppet/parser/functions.rb +4 -2
- data/lib/puppet/parser/lexer.rb +2 -1
- data/lib/puppet/parser/parser_support.rb +3 -3
- data/lib/puppet/provider.rb +2 -2
- data/lib/puppet/provider/confine/exists.rb +1 -4
- data/lib/puppet/provider/mount.rb +1 -1
- data/lib/puppet/provider/nameservice.rb +3 -1
- data/lib/puppet/provider/package/openbsd.rb +6 -10
- data/lib/puppet/provider/service/freebsd.rb +4 -1
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +8 -6
- data/lib/puppet/provider/user/useradd.rb +7 -8
- data/lib/puppet/rails.rb +2 -6
- data/lib/puppet/rails/host.rb +0 -72
- data/lib/puppet/resource.rb +22 -0
- data/lib/puppet/resource/type.rb +18 -13
- data/lib/puppet/type/exec.rb +1 -7
- data/lib/puppet/type/schedule.rb +5 -5
- data/lib/puppet/util.rb +20 -18
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/file_locking.rb +6 -3
- data/lib/puppet/util/metric.rb +1 -1
- data/lib/puppet/util/rdoc.rb +5 -4
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +6 -0
- data/lib/puppet/util/reference.rb +1 -10
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/zaml.rb +4 -1
- data/spec/integration/indirector/bucket_file/rest_spec.rb +10 -2
- data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +10 -2
- data/spec/integration/parser/functions_spec.rb +21 -0
- data/spec/integration/parser/ruby_manifest_spec.rb +1 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +1 -3
- data/spec/integration/util/file_locking_spec.rb +31 -11
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/daemon_spec.rb +3 -9
- data/spec/unit/indirector/catalog/compiler_spec.rb +9 -8
- data/spec/unit/network/handler/fileserver_spec.rb +2 -4
- data/spec/unit/network/server_spec.rb +3 -10
- data/spec/unit/parser/ast/collection_spec.rb +4 -0
- data/spec/unit/parser/ast/leaf_spec.rb +43 -1
- data/spec/unit/parser/ast/resource_spec.rb +133 -88
- data/spec/unit/parser/compiler_spec.rb +8 -8
- data/spec/unit/parser/lexer_spec.rb +1 -0
- data/spec/unit/parser/parser_spec.rb +9 -2
- data/spec/unit/provider/confine/exists_spec.rb +6 -13
- data/spec/unit/provider/mount_spec.rb +8 -1
- data/spec/unit/provider/service/freebsd_spec.rb +50 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -2
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +42 -0
- data/spec/unit/rails_spec.rb +82 -22
- data/spec/unit/resource/type_spec.rb +13 -13
- data/spec/unit/type/schedule_spec.rb +21 -49
- data/spec/unit/util/command_line_spec.rb +2 -2
- data/spec/unit/util/file_locking_spec.rb +28 -24
- data/spec/unit/util/{json_spec.rb → pson_spec.rb} +17 -0
- data/spec/unit/util/rdoc_spec.rb +9 -1
- data/spec/unit/util/storage_spec.rb +2 -3
- data/test/other/provider.rb +1 -12
- data/test/other/report.rb +2 -5
- data/test/puppet/tc_suidmanager.rb +5 -14
- data/test/ral/manager/type.rb +1 -1
- data/test/ral/providers/provider.rb +3 -3
- data/test/util/metrics.rb +2 -2
- metadata +8 -6
- data/spec/integration/indirector/rest_spec.rb +0 -525
|
@@ -580,29 +580,29 @@ describe Puppet::Resource::Type do
|
|
|
580
580
|
end
|
|
581
581
|
|
|
582
582
|
it "should create a resource instance" do
|
|
583
|
-
@top.
|
|
583
|
+
@top.ensure_in_catalog(@scope).should be_instance_of(Puppet::Parser::Resource)
|
|
584
584
|
end
|
|
585
585
|
|
|
586
586
|
it "should set its resource type to 'class' when it is a hostclass" do
|
|
587
|
-
Puppet::Resource::Type.new(:hostclass, "top").
|
|
587
|
+
Puppet::Resource::Type.new(:hostclass, "top").ensure_in_catalog(@scope).type.should == "Class"
|
|
588
588
|
end
|
|
589
589
|
|
|
590
590
|
it "should set its resource type to 'node' when it is a node" do
|
|
591
|
-
Puppet::Resource::Type.new(:node, "top").
|
|
591
|
+
Puppet::Resource::Type.new(:node, "top").ensure_in_catalog(@scope).type.should == "Node"
|
|
592
592
|
end
|
|
593
593
|
|
|
594
594
|
it "should fail when it is a definition" do
|
|
595
|
-
lambda { Puppet::Resource::Type.new(:definition, "top").
|
|
595
|
+
lambda { Puppet::Resource::Type.new(:definition, "top").ensure_in_catalog(@scope) }.should raise_error(ArgumentError)
|
|
596
596
|
end
|
|
597
597
|
|
|
598
598
|
it "should add the created resource to the scope's catalog" do
|
|
599
|
-
@top.
|
|
599
|
+
@top.ensure_in_catalog(@scope)
|
|
600
600
|
|
|
601
601
|
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
|
602
602
|
end
|
|
603
603
|
|
|
604
604
|
it "should evaluate the parent class if one exists" do
|
|
605
|
-
@middle.
|
|
605
|
+
@middle.ensure_in_catalog(@scope)
|
|
606
606
|
|
|
607
607
|
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
|
|
608
608
|
end
|
|
@@ -610,40 +610,40 @@ describe Puppet::Resource::Type do
|
|
|
610
610
|
it "should fail to evaluate if a parent class is defined but cannot be found" do
|
|
611
611
|
othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay"
|
|
612
612
|
@code.add othertop
|
|
613
|
-
lambda { othertop.
|
|
613
|
+
lambda { othertop.ensure_in_catalog(@scope) }.should raise_error(Puppet::ParseError)
|
|
614
614
|
end
|
|
615
615
|
|
|
616
616
|
it "should not create a new resource if one already exists" do
|
|
617
617
|
@compiler.catalog.expects(:resource).with(:class, "top").returns("something")
|
|
618
618
|
@compiler.catalog.expects(:add_resource).never
|
|
619
|
-
@top.
|
|
619
|
+
@top.ensure_in_catalog(@scope)
|
|
620
620
|
end
|
|
621
621
|
|
|
622
622
|
it "should return the existing resource when not creating a new one" do
|
|
623
623
|
@compiler.catalog.expects(:resource).with(:class, "top").returns("something")
|
|
624
624
|
@compiler.catalog.expects(:add_resource).never
|
|
625
|
-
@top.
|
|
625
|
+
@top.ensure_in_catalog(@scope).should == "something"
|
|
626
626
|
end
|
|
627
627
|
|
|
628
628
|
it "should not create a new parent resource if one already exists and it has a parent class" do
|
|
629
|
-
@top.
|
|
629
|
+
@top.ensure_in_catalog(@scope)
|
|
630
630
|
|
|
631
631
|
top_resource = @compiler.catalog.resource(:class, "top")
|
|
632
632
|
|
|
633
|
-
@middle.
|
|
633
|
+
@middle.ensure_in_catalog(@scope)
|
|
634
634
|
|
|
635
635
|
@compiler.catalog.resource(:class, "top").should equal(top_resource)
|
|
636
636
|
end
|
|
637
637
|
|
|
638
638
|
# #795 - tag before evaluation.
|
|
639
639
|
it "should tag the catalog with the resource tags when it is evaluated" do
|
|
640
|
-
@middle.
|
|
640
|
+
@middle.ensure_in_catalog(@scope)
|
|
641
641
|
|
|
642
642
|
@compiler.catalog.should be_tagged("middle")
|
|
643
643
|
end
|
|
644
644
|
|
|
645
645
|
it "should tag the catalog with the parent class tags when it is evaluated" do
|
|
646
|
-
@middle.
|
|
646
|
+
@middle.ensure_in_catalog(@scope)
|
|
647
647
|
|
|
648
648
|
@compiler.catalog.should be_tagged("top")
|
|
649
649
|
end
|
|
@@ -13,14 +13,6 @@ module ScheduleTesting
|
|
|
13
13
|
Time.at(diff)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def month(method, count)
|
|
17
|
-
diff(:hour, 3600 * 24 * 30, method, count)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def week(method, count)
|
|
21
|
-
diff(:hour, 3600 * 24 * 7, method, count)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
16
|
def day(method, count)
|
|
25
17
|
diff(:hour, 3600 * 24, method, count)
|
|
26
18
|
end
|
|
@@ -33,10 +25,6 @@ module ScheduleTesting
|
|
|
33
25
|
diff(:min, 60, method, count)
|
|
34
26
|
end
|
|
35
27
|
|
|
36
|
-
def sec(method, count)
|
|
37
|
-
diff(:sec, 1, method, count)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
28
|
end
|
|
41
29
|
|
|
42
30
|
describe Puppet::Type.type(:schedule) do
|
|
@@ -194,26 +182,18 @@ describe Puppet::Type.type(:schedule) do
|
|
|
194
182
|
end
|
|
195
183
|
|
|
196
184
|
it "should match if the times are one minute apart and the current minute is 0" do
|
|
197
|
-
current = Time.
|
|
185
|
+
current = Time.utc(2008, 1, 1, 0, 0, 0)
|
|
186
|
+
previous = Time.utc(2007, 12, 31, 23, 59, 0)
|
|
198
187
|
|
|
199
|
-
|
|
200
|
-
previous = (current - 3600 - (current.min * 60) + (59 * 60))
|
|
201
|
-
|
|
202
|
-
# Now set the "current" time to the zero minute of the current hour.
|
|
203
|
-
now = (current - (current.min * 60))
|
|
204
|
-
Time.stubs(:now).returns(now)
|
|
188
|
+
Time.stubs(:now).returns(current)
|
|
205
189
|
@schedule.match?(previous).should be_true
|
|
206
190
|
end
|
|
207
191
|
|
|
208
|
-
it "should not match if the times are
|
|
209
|
-
current = Time.
|
|
192
|
+
it "should not match if the times are 59 minutes apart and the current minute is 59" do
|
|
193
|
+
current = Time.utc(2009, 2, 1, 12, 59, 0)
|
|
194
|
+
previous = Time.utc(2009, 2, 1, 12, 0, 0)
|
|
210
195
|
|
|
211
|
-
|
|
212
|
-
previous = current - (current.min * 60)
|
|
213
|
-
|
|
214
|
-
# Now set the "current" time to the 59th minute of the current hour.
|
|
215
|
-
now = (current - (current.min * 60) + (59 * 60))
|
|
216
|
-
Time.stubs(:now).returns(now)
|
|
196
|
+
Time.stubs(:now).returns(current)
|
|
217
197
|
@schedule.match?(previous).should be_false
|
|
218
198
|
end
|
|
219
199
|
end
|
|
@@ -227,10 +207,7 @@ describe Puppet::Type.type(:schedule) do
|
|
|
227
207
|
end
|
|
228
208
|
|
|
229
209
|
it "should match if the times are one minute apart and the current minute and hour are 0" do
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
# Reset the current time to X:00:00
|
|
233
|
-
current = zero - (zero.hour * 3600) - (zero.min * 60) - zero.sec
|
|
210
|
+
current = Time.utc(2010, "nov", 7, 0, 0, 0)
|
|
234
211
|
|
|
235
212
|
# Now set the previous time to one minute before that
|
|
236
213
|
previous = current - 60
|
|
@@ -240,10 +217,9 @@ describe Puppet::Type.type(:schedule) do
|
|
|
240
217
|
end
|
|
241
218
|
|
|
242
219
|
it "should not match if the times are 23 hours and 58 minutes apart and the current hour is 23 and the current minute is 59" do
|
|
243
|
-
zero = Time.now
|
|
244
220
|
|
|
245
221
|
# Reset the previous time to 00:00:00
|
|
246
|
-
previous =
|
|
222
|
+
previous = Time.utc(2010, "nov", 7, 0, 0, 0)
|
|
247
223
|
|
|
248
224
|
# Set the current time to 23:59
|
|
249
225
|
now = previous + (23 * 3600) + (59 * 60)
|
|
@@ -262,19 +238,17 @@ describe Puppet::Type.type(:schedule) do
|
|
|
262
238
|
end
|
|
263
239
|
|
|
264
240
|
it "should match if the previous time is prior to the most recent Sunday" do
|
|
265
|
-
now = Time.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
previous = now - (3600 * 24 * (now.wday + 1))
|
|
241
|
+
now = Time.utc(2010, "nov", 11, 0, 0, 0) # Thursday
|
|
242
|
+
Time.stubs(:now).returns(now)
|
|
243
|
+
previous = Time.utc(2010, "nov", 6, 23, 59, 59) # Sat
|
|
269
244
|
|
|
270
245
|
@schedule.match?(previous).should be_true
|
|
271
246
|
end
|
|
272
247
|
|
|
273
248
|
it "should not match if the previous time is after the most recent Saturday" do
|
|
274
|
-
now = Time.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
previous = now - (3600 * 24 * now.wday)
|
|
249
|
+
now = Time.utc(2010, "nov", 11, 0, 0, 0) # Thursday
|
|
250
|
+
Time.stubs(:now).returns(now)
|
|
251
|
+
previous = Time.utc(2010, "nov", 7, 0, 0, 0) # Sunday
|
|
278
252
|
|
|
279
253
|
@schedule.match?(previous).should be_false
|
|
280
254
|
end
|
|
@@ -289,19 +263,17 @@ describe Puppet::Type.type(:schedule) do
|
|
|
289
263
|
end
|
|
290
264
|
|
|
291
265
|
it "should match when the previous time is prior to the first day of this month" do
|
|
292
|
-
now = Time.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
previous = now - (3600 * 24 * now.day)
|
|
266
|
+
now = Time.utc(2010, "nov", 8, 00, 59, 59)
|
|
267
|
+
Time.stubs(:now).returns(now)
|
|
268
|
+
previous = Time.utc(2010, "oct", 31, 23, 59, 59)
|
|
296
269
|
|
|
297
270
|
@schedule.match?(previous).should be_true
|
|
298
271
|
end
|
|
299
272
|
|
|
300
273
|
it "should not match when the previous time is after the last day of last month" do
|
|
301
|
-
now = Time.
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
previous = now - (3600 * 24 * (now.day - 1))
|
|
274
|
+
now = Time.utc(2010, "nov", 8, 00, 59, 59)
|
|
275
|
+
Time.stubs(:now).returns(now)
|
|
276
|
+
previous = Time.utc(2010, "nov", 1, 0, 0, 0)
|
|
305
277
|
|
|
306
278
|
@schedule.match?(previous).should be_false
|
|
307
279
|
end
|
|
@@ -86,7 +86,7 @@ describe Puppet::Util::CommandLine do
|
|
|
86
86
|
describe "when the subcommand is not implemented" do
|
|
87
87
|
it "should find and invoke an executable with a hyphenated name" do
|
|
88
88
|
commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty)
|
|
89
|
-
Puppet::Util.expects(:
|
|
89
|
+
Puppet::Util.expects(:which).with('puppet-whatever').returns('/dev/null/puppet-whatever')
|
|
90
90
|
commandline.expects(:system).with('/dev/null/puppet-whatever', 'argument')
|
|
91
91
|
|
|
92
92
|
commandline.execute
|
|
@@ -95,7 +95,7 @@ describe Puppet::Util::CommandLine do
|
|
|
95
95
|
describe "and an external implementation cannot be found" do
|
|
96
96
|
it "should abort and show the usage message" do
|
|
97
97
|
commandline = Puppet::Util::CommandLine.new("puppet", ['whatever', 'argument'], @tty)
|
|
98
|
-
Puppet::Util.expects(:
|
|
98
|
+
Puppet::Util.expects(:which).with('puppet-whatever').returns(nil)
|
|
99
99
|
commandline.expects(:system).never
|
|
100
100
|
|
|
101
101
|
commandline.expects(:usage_message).returns("the usage message")
|
|
@@ -32,17 +32,12 @@ describe Puppet::Util::FileLocking do
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should use a global shared mutex" do
|
|
35
|
-
|
|
36
|
-
@sync.expects(:synchronize).with(Sync::SH).once
|
|
37
|
-
Puppet::Util.expects(:sync).with('/file').returns @sync
|
|
38
|
-
|
|
35
|
+
Puppet::Util.expects(:synchronize_on).with('/file',Sync::SH).once
|
|
39
36
|
Puppet::Util::FileLocking.readlock '/file'
|
|
40
37
|
end
|
|
41
38
|
|
|
42
39
|
it "should use a shared lock on the file" do
|
|
43
|
-
|
|
44
|
-
@sync.stubs(:synchronize).yields
|
|
45
|
-
Puppet::Util.expects(:sync).with('/file').returns @sync
|
|
40
|
+
Puppet::Util.expects(:synchronize_on).with('/file',Sync::SH).yields
|
|
46
41
|
|
|
47
42
|
fh = mock 'filehandle'
|
|
48
43
|
File.expects(:open).with("/file").yields fh
|
|
@@ -59,9 +54,7 @@ describe Puppet::Util::FileLocking do
|
|
|
59
54
|
end
|
|
60
55
|
|
|
61
56
|
it "should create missing files" do
|
|
62
|
-
|
|
63
|
-
@sync.stubs(:synchronize).yields
|
|
64
|
-
Puppet::Util.expects(:sync).with('/file').returns @sync
|
|
57
|
+
Puppet::Util.expects(:synchronize_on).with('/file',Sync::SH).yields
|
|
65
58
|
|
|
66
59
|
File.expects(:exists?).with('/file').returns false
|
|
67
60
|
File.expects(:open).with('/file').once
|
|
@@ -72,9 +65,7 @@ describe Puppet::Util::FileLocking do
|
|
|
72
65
|
|
|
73
66
|
describe "when acquiring a write lock" do
|
|
74
67
|
before do
|
|
75
|
-
|
|
76
|
-
Puppet::Util.stubs(:sync).returns @sync
|
|
77
|
-
@sync.stubs(:synchronize).yields
|
|
68
|
+
Puppet::Util.stubs(:synchronize_on).yields
|
|
78
69
|
File.stubs(:file?).with('/file').returns true
|
|
79
70
|
File.stubs(:exists?).with('/file').returns true
|
|
80
71
|
end
|
|
@@ -88,29 +79,26 @@ describe Puppet::Util::FileLocking do
|
|
|
88
79
|
end
|
|
89
80
|
|
|
90
81
|
it "should use a global exclusive mutex" do
|
|
91
|
-
|
|
92
|
-
sync.expects(:synchronize).with(Sync::EX)
|
|
93
|
-
Puppet::Util.expects(:sync).with("/file").returns sync
|
|
94
|
-
|
|
82
|
+
Puppet::Util.expects(:synchronize_on).with("/file",Sync::EX)
|
|
95
83
|
Puppet::Util::FileLocking.writelock '/file'
|
|
96
84
|
end
|
|
97
85
|
|
|
98
86
|
it "should use any specified mode when opening the file" do
|
|
99
|
-
File.expects(:open).with("/file",
|
|
87
|
+
File.expects(:open).with("/file", File::Constants::CREAT | File::Constants::WRONLY , :mymode)
|
|
100
88
|
|
|
101
89
|
Puppet::Util::FileLocking.writelock('/file', :mymode)
|
|
102
90
|
end
|
|
103
91
|
|
|
104
92
|
it "should use the mode of the existing file if no mode is specified" do
|
|
105
93
|
File.expects(:stat).with("/file").returns(mock("stat", :mode => 0755))
|
|
106
|
-
File.expects(:open).with("/file",
|
|
94
|
+
File.expects(:open).with("/file", File::Constants::CREAT | File::Constants::WRONLY, 0755)
|
|
107
95
|
|
|
108
96
|
Puppet::Util::FileLocking.writelock('/file')
|
|
109
97
|
end
|
|
110
98
|
|
|
111
99
|
it "should use 0600 as the mode if no mode is specified and the file does not exist" do
|
|
112
100
|
File.expects(:stat).raises(Errno::ENOENT)
|
|
113
|
-
File.expects(:open).with("/file",
|
|
101
|
+
File.expects(:open).with("/file", File::Constants::CREAT | File::Constants::WRONLY, 0600)
|
|
114
102
|
|
|
115
103
|
Puppet::Util::FileLocking.writelock('/file')
|
|
116
104
|
end
|
|
@@ -130,6 +118,8 @@ describe Puppet::Util::FileLocking do
|
|
|
130
118
|
lfh = mock 'locked_filehandle'
|
|
131
119
|
fh.expects(:lock_exclusive).yields(lfh)
|
|
132
120
|
|
|
121
|
+
lfh.stubs(:seek)
|
|
122
|
+
lfh.stubs(:truncate)
|
|
133
123
|
lfh.expects(:print).with "foo"
|
|
134
124
|
|
|
135
125
|
Puppet::Util::FileLocking.writelock('/file') do |f|
|
|
@@ -137,18 +127,32 @@ describe Puppet::Util::FileLocking do
|
|
|
137
127
|
end
|
|
138
128
|
end
|
|
139
129
|
|
|
130
|
+
it "should truncate the file under an exclusive lock" do
|
|
131
|
+
fh = mock 'fh'
|
|
132
|
+
File.expects(:open).yields fh
|
|
133
|
+
|
|
134
|
+
lfh = mock 'locked_filehandle'
|
|
135
|
+
fh.expects(:lock_exclusive).yields(lfh)
|
|
136
|
+
|
|
137
|
+
lfh.expects(:seek).with(0, IO::SEEK_SET)
|
|
138
|
+
lfh.expects(:truncate).with(0)
|
|
139
|
+
lfh.stubs(:print)
|
|
140
|
+
|
|
141
|
+
Puppet::Util::FileLocking.writelock('/file') do |f|
|
|
142
|
+
f.print "foo"
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
140
146
|
it "should only work on regular files" do
|
|
141
147
|
File.expects(:file?).with('/file').returns false
|
|
142
148
|
proc { Puppet::Util::FileLocking.writelock('/file') }.should raise_error(ArgumentError)
|
|
143
149
|
end
|
|
144
150
|
|
|
145
151
|
it "should create missing files" do
|
|
146
|
-
|
|
147
|
-
@sync.stubs(:synchronize).yields
|
|
148
|
-
Puppet::Util.expects(:sync).with('/file').returns @sync
|
|
152
|
+
Puppet::Util.expects(:synchronize_on).with('/file',Sync::EX).yields
|
|
149
153
|
|
|
150
154
|
File.expects(:exists?).with('/file').returns false
|
|
151
|
-
File.expects(:open).with('/file',
|
|
155
|
+
File.expects(:open).with('/file', File::Constants::CREAT | File::Constants::WRONLY, 0600).once
|
|
152
156
|
|
|
153
157
|
Puppet::Util::FileLocking.writelock('/file')
|
|
154
158
|
end
|
|
@@ -18,4 +18,21 @@ describe Puppet::Util::Pson do
|
|
|
18
18
|
pson.expects(:from_pson).with("mydata")
|
|
19
19
|
pson.pson_create("type" => "foo", "data" => "mydata")
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
'foo' => '"foo"',
|
|
25
|
+
1 => '1',
|
|
26
|
+
"\x80" => "\"\x80\"",
|
|
27
|
+
[] => '[]'
|
|
28
|
+
}.each { |str,pson|
|
|
29
|
+
it "should be able to encode #{str.inspect}" do
|
|
30
|
+
str.to_pson.should == pson
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
it "should be able to handle arbitrary binary data" do
|
|
35
|
+
bin_string = (1..20000).collect { |i| ((17*i+13*i*i) % 255).chr }.join
|
|
36
|
+
PSON.parse(%Q{{ "type": "foo", "data": #{bin_string.to_pson} }})["data"].should == bin_string
|
|
37
|
+
end
|
|
21
38
|
end
|
data/spec/unit/util/rdoc_spec.rb
CHANGED
|
@@ -43,12 +43,20 @@ describe Puppet::Util::RDoc do
|
|
|
43
43
|
Puppet::Util::RDoc.rdoc("output", [], "utf-8")
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
it "should tell RDoc to force updates of indices" do
|
|
46
|
+
it "should tell RDoc to force updates of indices when RDoc supports it" do
|
|
47
|
+
Options::OptionList.stubs(:options).returns([["--force-update", "-U", 0 ]])
|
|
47
48
|
@rdoc.expects(:document).with { |args| args.include?("--force-update") }
|
|
48
49
|
|
|
49
50
|
Puppet::Util::RDoc.rdoc("output", [])
|
|
50
51
|
end
|
|
51
52
|
|
|
53
|
+
it "should not tell RDoc to force updates of indices when RDoc doesn't support it" do
|
|
54
|
+
Options::OptionList.stubs(:options).returns([])
|
|
55
|
+
@rdoc.expects(:document).never.with { |args| args.include?("--force-update") }
|
|
56
|
+
|
|
57
|
+
Puppet::Util::RDoc.rdoc("output", [])
|
|
58
|
+
end
|
|
59
|
+
|
|
52
60
|
it "should tell RDoc to use the given outputdir" do
|
|
53
61
|
@rdoc.expects(:document).with { |args| args.include?("--op") and args.include?("myoutputdir") }
|
|
54
62
|
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
4
4
|
|
|
5
5
|
require 'yaml'
|
|
6
|
-
require 'tempfile'
|
|
7
|
-
|
|
8
6
|
require 'puppet/util/storage'
|
|
9
7
|
|
|
10
8
|
describe Puppet::Util::Storage do
|
|
9
|
+
include PuppetSpec::Files
|
|
11
10
|
|
|
12
11
|
before(:all) do
|
|
13
12
|
@basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
|
|
14
|
-
Puppet[:statedir] =
|
|
13
|
+
Puppet[:statedir] = tmpdir("statedir")
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
after(:all) do
|
data/test/other/provider.rb
CHANGED
|
@@ -70,24 +70,13 @@ class TestImpl < Test::Unit::TestCase
|
|
|
70
70
|
child = @type.provide("child", :parent => parent.name) {}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
assert_nothing_raised {
|
|
74
|
-
child.commands :which => "which"
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
assert(child.command(:which), "Did not find 'which' command")
|
|
78
|
-
|
|
79
|
-
assert(child.command(:which) =~ /^\//,
|
|
80
|
-
"Command did not become fully qualified")
|
|
81
|
-
assert(FileTest.exists?(child.command(:which)),
|
|
82
|
-
"Did not find actual 'which' binary")
|
|
83
|
-
|
|
84
73
|
assert_raise(Puppet::DevError) do
|
|
85
74
|
child.command(:nosuchcommand)
|
|
86
75
|
end
|
|
87
76
|
|
|
88
77
|
# Now create a parent command
|
|
89
78
|
assert_nothing_raised {
|
|
90
|
-
parent.commands :sh => Puppet::Util.
|
|
79
|
+
parent.commands :sh => Puppet::Util.which('sh')
|
|
91
80
|
}
|
|
92
81
|
|
|
93
82
|
assert(parent.command(:sh), "Did not find 'sh' command")
|
data/test/other/report.rb
CHANGED
|
@@ -35,10 +35,7 @@ class TestReports < Test::Unit::TestCase
|
|
|
35
35
|
config.retrieval_duration = 0.001
|
|
36
36
|
trans = config.apply
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
trans.add_metrics_to_report(report)
|
|
40
|
-
|
|
41
|
-
report
|
|
38
|
+
trans.generate_report
|
|
42
39
|
end
|
|
43
40
|
|
|
44
41
|
# Make sure we can use reports as log destinations.
|
|
@@ -95,7 +92,7 @@ class TestReports < Test::Unit::TestCase
|
|
|
95
92
|
assert_equal(yaml, File.read(file), "File did not get written")
|
|
96
93
|
end
|
|
97
94
|
|
|
98
|
-
if Puppet.features.rrd?
|
|
95
|
+
if Puppet.features.rrd? || Puppet.features.rrd_legacy?
|
|
99
96
|
def test_rrdgraph_report
|
|
100
97
|
Puppet.settings.use(:main, :metrics)
|
|
101
98
|
report = mkreport
|