puppet 0.23.0 → 0.23.1
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.
- data/CHANGELOG +58 -0
- data/Rakefile +1 -1
- data/bin/filebucket +6 -6
- data/bin/puppetca +11 -1
- data/bin/puppetmasterd +7 -6
- data/conf/redhat/client.init +1 -0
- data/conf/redhat/{puppetd.conf → puppet.conf} +1 -1
- data/conf/redhat/puppet.spec +43 -31
- data/conf/redhat/server.init +1 -0
- data/lib/puppet.rb +3 -3
- data/lib/puppet/configuration.rb +16 -5
- data/lib/puppet/metatype/attributes.rb +12 -19
- data/lib/puppet/metatype/evaluation.rb +10 -1
- data/lib/puppet/metatype/instances.rb +39 -15
- data/lib/puppet/metatype/manager.rb +1 -28
- data/lib/puppet/metatype/metaparams.rb +20 -16
- data/lib/puppet/metatype/providers.rb +8 -2
- data/lib/puppet/metatype/schedules.rb +14 -19
- data/lib/puppet/{modules.rb → module.rb} +2 -0
- data/lib/puppet/network/authstore.rb +5 -1
- data/lib/puppet/network/client/dipper.rb +2 -2
- data/lib/puppet/network/client/master.rb +18 -9
- data/lib/puppet/network/handler/fileserver.rb +3 -6
- data/lib/puppet/network/handler/report.rb +2 -1
- data/lib/puppet/network/server/mongrel.rb +4 -2
- data/lib/puppet/network/xmlrpc/client.rb +10 -3
- data/lib/puppet/parameter.rb +11 -4
- data/lib/puppet/parser/ast/collexpr.rb +10 -10
- data/lib/puppet/parser/ast/hostclass.rb +2 -2
- data/lib/puppet/parser/ast/resourceparam.rb +4 -3
- data/lib/puppet/parser/ast/resourceref.rb +16 -2
- data/lib/puppet/parser/collector.rb +8 -4
- data/lib/puppet/parser/functions.rb +5 -2
- data/lib/puppet/parser/interpreter.rb +48 -9
- data/lib/puppet/parser/lexer.rb +2 -1
- data/lib/puppet/parser/parser.rb +669 -589
- data/lib/puppet/parser/resource.rb +20 -11
- data/lib/puppet/parser/resource/param.rb +21 -10
- data/lib/puppet/parser/resource/reference.rb +2 -2
- data/lib/puppet/parser/scope.rb +22 -10
- data/lib/puppet/{type/property.rb → property.rb} +48 -15
- data/lib/puppet/propertychange.rb +3 -3
- data/lib/puppet/provider/cron/crontab.rb +38 -36
- data/lib/puppet/provider/host/netinfo.rb +1 -2
- data/lib/puppet/provider/mailalias/aliases.rb +31 -0
- data/lib/puppet/provider/maillist/mailman.rb +113 -0
- data/lib/puppet/provider/mount.rb +5 -11
- data/lib/puppet/provider/mount/parsed.rb +2 -2
- data/lib/puppet/provider/package/appdmg.rb +1 -2
- data/lib/puppet/provider/package/apt.rb +3 -1
- data/lib/puppet/provider/package/aptrpm.rb +14 -4
- data/lib/puppet/provider/package/blastwave.rb +6 -4
- data/lib/puppet/provider/package/dpkg.rb +12 -4
- data/lib/puppet/provider/package/pkgdmg.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +11 -1
- data/lib/puppet/provider/package/rug.rb +1 -0
- data/lib/puppet/provider/package/urpmi.rb +11 -1
- data/lib/puppet/provider/package/yum.rb +12 -2
- data/lib/puppet/provider/parsedfile.rb +36 -6
- data/lib/puppet/rails.rb +9 -2
- data/lib/puppet/rails/param_name.rb +2 -3
- data/lib/puppet/rails/param_value.rb +20 -1
- data/lib/puppet/rails/resource.rb +8 -2
- data/lib/puppet/reference/configuration.rb +14 -16
- data/lib/puppet/reference/type.rb +4 -4
- data/lib/puppet/transaction.rb +4 -4
- data/lib/puppet/type.rb +19 -6
- data/lib/puppet/type/component.rb +9 -3
- data/lib/puppet/type/cron.rb +10 -4
- data/lib/puppet/type/exec.rb +9 -5
- data/lib/puppet/type/group.rb +2 -3
- data/lib/puppet/type/mailalias.rb +50 -0
- data/lib/puppet/type/maillist.rb +57 -0
- data/lib/puppet/type/mount.rb +25 -11
- data/lib/puppet/type/package.rb +6 -27
- data/lib/puppet/type/pfile.rb +5 -6
- data/lib/puppet/type/pfile/source.rb +8 -2
- data/lib/puppet/type/pfilebucket.rb +4 -3
- data/lib/puppet/type/resources.rb +1 -3
- data/lib/puppet/type/schedule.rb +16 -16
- data/lib/puppet/type/service.rb +4 -1
- data/lib/puppet/type/tidy.rb +1 -2
- data/lib/puppet/type/user.rb +2 -3
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/util.rb +29 -4
- data/lib/puppet/util/autoload.rb +45 -16
- data/lib/puppet/util/fileparsing.rb +23 -6
- data/lib/puppet/util/filetype.rb +12 -1
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/log_paths.rb +16 -0
- data/lib/puppet/util/reference.rb +2 -2
- data/test/language/ast/hostclass.rb +21 -4
- data/test/language/ast/resourceref.rb +95 -0
- data/test/language/functions.rb +5 -5
- data/test/language/interpreter.rb +129 -1
- data/test/language/node.rb +13 -2
- data/test/language/resource.rb +26 -1
- data/test/language/scope.rb +25 -5
- data/test/lib/puppettest/support/collection.rb +2 -2
- data/test/network/client/master.rb +28 -42
- data/test/network/server/mongrel_test.rb +7 -1
- data/test/other/propertychange.rb +2 -2
- data/test/other/transactions.rb +44 -5
- data/test/puppet/modules.rb +2 -1
- data/test/rails/ast.rb +7 -8
- data/test/rails/collection.rb +2 -2
- data/test/rails/railsresource.rb +21 -5
- data/test/ral/manager/attributes.rb +33 -1
- data/test/ral/manager/instances.rb +33 -6
- data/test/ral/manager/type.rb +29 -49
- data/test/ral/providers/cron/crontab.rb +61 -13
- data/test/ral/providers/mailalias/aliases.rb +57 -0
- data/test/ral/providers/mount/parsed.rb +4 -4
- data/test/ral/providers/package/apt.rb +13 -1
- data/test/ral/providers/parsedfile.rb +20 -7
- data/test/ral/types/cron.rb +17 -1
- data/test/ral/types/mailalias.rb +50 -0
- data/test/ral/types/mount.rb +35 -2
- data/test/ral/types/package.rb +10 -2
- data/test/ral/types/parameter.rb +4 -4
- data/test/ral/types/property.rb +39 -1
- data/test/util/autoload.rb +33 -18
- data/test/util/filetype.rb +49 -3
- metadata +13 -6
- data/lib/puppet/element.rb +0 -52
@@ -60,6 +60,12 @@ class TestMongrelServer < PuppetTest::TestCase
|
|
60
60
|
assert_equal(ip, info.ip, "Did not copy over ip correctly")
|
61
61
|
assert_equal(Resolv.getname(ip), info.name, "Did not look up hostname correctly")
|
62
62
|
end
|
63
|
+
|
64
|
+
def test_daemonize
|
65
|
+
mongrel = mkserver
|
66
|
+
|
67
|
+
assert(mongrel.respond_to?(:daemonize), "Mongrel server does not respond to daemonize")
|
68
|
+
end
|
63
69
|
end
|
64
70
|
|
65
|
-
# $Id: mongrel_test.rb
|
71
|
+
# $Id: mongrel_test.rb 2659 2007-07-08 23:02:06Z luke $
|
@@ -9,7 +9,7 @@ require 'puppettest'
|
|
9
9
|
|
10
10
|
class TestPropertyChange < Test::Unit::TestCase
|
11
11
|
include PuppetTest
|
12
|
-
class FakeProperty < Puppet::
|
12
|
+
class FakeProperty < Puppet::Property
|
13
13
|
attr_accessor :is, :should, :resource
|
14
14
|
attr_reader :noop
|
15
15
|
def change_to_s(currentvalue, newvalue)
|
@@ -138,4 +138,4 @@ class TestPropertyChange < Test::Unit::TestCase
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
# $Id: propertychange.rb
|
141
|
+
# $Id: propertychange.rb 2647 2007-07-04 22:25:23Z luke $
|
data/test/other/transactions.rb
CHANGED
@@ -7,15 +7,15 @@ require 'puppettest'
|
|
7
7
|
require 'mocha'
|
8
8
|
require 'puppettest/support/resources'
|
9
9
|
|
10
|
-
# $Id: transactions.rb
|
10
|
+
# $Id: transactions.rb 2678 2007-07-11 19:30:42Z luke $
|
11
11
|
|
12
12
|
class TestTransactions < Test::Unit::TestCase
|
13
13
|
include PuppetTest::FileTesting
|
14
14
|
include PuppetTest::Support::Resources
|
15
|
-
class Fakeprop <Puppet::
|
15
|
+
class Fakeprop <Puppet::Property
|
16
16
|
attr_accessor :path, :is, :should, :name
|
17
|
-
def should_to_s
|
18
|
-
|
17
|
+
def should_to_s(value)
|
18
|
+
value.to_s
|
19
19
|
end
|
20
20
|
def insync?(foo)
|
21
21
|
true
|
@@ -1148,6 +1148,45 @@ class TestTransactions < Test::Unit::TestCase
|
|
1148
1148
|
assert(FileTest.exists?(paths[1]), "Deleted required purging file")
|
1149
1149
|
assert(! FileTest.exists?(paths[2]), "Did not delete non-purged file")
|
1150
1150
|
end
|
1151
|
+
|
1152
|
+
def test_flush
|
1153
|
+
$state = "absent"
|
1154
|
+
$flushed = 0
|
1155
|
+
type = Puppet::Type.newtype(:flushtest) do
|
1156
|
+
newparam(:name)
|
1157
|
+
newproperty(:ensure) do
|
1158
|
+
def retrieve
|
1159
|
+
$state
|
1160
|
+
end
|
1161
|
+
def set(value)
|
1162
|
+
$state = value
|
1163
|
+
:thing_changed
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
def flush
|
1168
|
+
$flushed += 1
|
1169
|
+
end
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
cleanup { Puppet::Type.rmtype(:flushtest) }
|
1173
|
+
|
1174
|
+
obj = type.create(:name => "test", :ensure => "present")
|
1175
|
+
|
1176
|
+
# first make sure it runs through and flushes
|
1177
|
+
assert_apply(obj)
|
1178
|
+
|
1179
|
+
assert_equal("present", $state, "Object did not make a change")
|
1180
|
+
assert_equal(1, $flushed, "object was not flushed")
|
1181
|
+
|
1182
|
+
# Now run a noop and make sure we don't flush
|
1183
|
+
obj[:ensure] = "other"
|
1184
|
+
obj[:noop] = true
|
1185
|
+
|
1186
|
+
assert_apply(obj)
|
1187
|
+
assert_equal("present", $state, "Object made a change in noop")
|
1188
|
+
assert_equal(1, $flushed, "object was flushed in noop")
|
1189
|
+
end
|
1151
1190
|
end
|
1152
1191
|
|
1153
|
-
# $Id: transactions.rb
|
1192
|
+
# $Id: transactions.rb 2678 2007-07-11 19:30:42Z luke $
|
data/test/puppet/modules.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
|
4
4
|
|
5
|
-
require 'puppet'
|
6
5
|
require 'puppettest'
|
7
6
|
|
8
7
|
class TestModules < Test::Unit::TestCase
|
@@ -56,3 +55,5 @@ class TestModules < Test::Unit::TestCase
|
|
56
55
|
assert_equal(templ_path, mod.template(templ))
|
57
56
|
end
|
58
57
|
end
|
58
|
+
|
59
|
+
# $Id: modules.rb 2655 2007-07-06 22:22:10Z luke $
|
data/test/rails/ast.rb
CHANGED
@@ -30,15 +30,14 @@ class TestRailsAST < PuppetTest::TestCase
|
|
30
30
|
code = nil
|
31
31
|
str = nil
|
32
32
|
|
33
|
-
# We don't support
|
33
|
+
# We don't support more than one search criteria at the moment.
|
34
34
|
retval = nil
|
35
35
|
bad = false
|
36
36
|
# Figure out if the search is for anything rails will ignore
|
37
|
-
string
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
37
|
+
if string =~ /\band\b|\bor\b/
|
38
|
+
bad = true
|
39
|
+
else
|
40
|
+
bad = false
|
42
41
|
end
|
43
42
|
|
44
43
|
# And if it is, make sure we throw an error.
|
@@ -54,7 +53,7 @@ class TestRailsAST < PuppetTest::TestCase
|
|
54
53
|
end
|
55
54
|
assert_nothing_raised("Could not find resource") do
|
56
55
|
retval = Puppet::Rails::Resource.find(:all,
|
57
|
-
:include => :param_values,
|
56
|
+
:include => {:param_values => :param_name},
|
58
57
|
:conditions => str)
|
59
58
|
end
|
60
59
|
|
@@ -71,4 +70,4 @@ class TestRailsAST < PuppetTest::TestCase
|
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
# $Id: ast.rb
|
73
|
+
# $Id: ast.rb 2705 2007-07-18 17:32:46Z luke $
|
data/test/rails/collection.rb
CHANGED
@@ -188,7 +188,7 @@ class TestRailsCollection < PuppetTest::TestCase
|
|
188
188
|
# Make our configuration
|
189
189
|
host = Puppet::Rails::Host.new(:name => "myhost")
|
190
190
|
|
191
|
-
host.resources.build(:title => "/tmp/hosttest", :
|
191
|
+
host.resources.build(:title => "/tmp/hosttest", :restype => "file",
|
192
192
|
:exported => true)
|
193
193
|
|
194
194
|
host.save
|
@@ -211,4 +211,4 @@ class TestRailsCollection < PuppetTest::TestCase
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
# $Id: collection.rb
|
214
|
+
# $Id: collection.rb 2663 2007-07-09 06:00:42Z luke $
|
data/test/rails/railsresource.rb
CHANGED
@@ -184,6 +184,8 @@ class TestExportedResources < PuppetTest::TestCase
|
|
184
184
|
"%s was different %s" % [param.name, tail])
|
185
185
|
end
|
186
186
|
end
|
187
|
+
|
188
|
+
return obj
|
187
189
|
end
|
188
190
|
|
189
191
|
def test_to_rails
|
@@ -194,40 +196,54 @@ class TestExportedResources < PuppetTest::TestCase
|
|
194
196
|
res = mkresource :type => "file", :title => "/tmp/testing",
|
195
197
|
:source => @source, :scope => @scope,
|
196
198
|
:params => {:owner => "root", :source => ["/tmp/A", "/tmp/B"],
|
197
|
-
:mode => "755", :require => [ref1, ref2]}
|
199
|
+
:mode => "755", :require => [ref1, ref2], :subscribe => ref1}
|
198
200
|
|
199
201
|
res.line = 50
|
200
202
|
|
201
203
|
# We also need a Rails Host to store under
|
202
204
|
host = Puppet::Rails::Host.new(:name => Facter.hostname)
|
203
205
|
|
204
|
-
compare_resources(host, res, false, :params => %w{owner source mode})
|
206
|
+
railsres = compare_resources(host, res, false, :params => %w{owner source mode})
|
205
207
|
|
206
208
|
# Now make sure our parameters did not change
|
207
209
|
assert_instance_of(Array, res[:require], "Parameter array changed")
|
208
210
|
res[:require].each do |ref|
|
209
211
|
assert_instance_of(Reference, ref, "Resource reference changed")
|
210
212
|
end
|
213
|
+
assert_instance_of(Reference, res[:subscribe], "Resource reference changed")
|
214
|
+
|
215
|
+
# And make sure that the rails resource actually has resource references
|
216
|
+
params = railsres.parameters
|
217
|
+
[params["subscribe"], params["require"]].flatten.each do |ref|
|
218
|
+
assert_instance_of(Reference, ref, "Resource reference is no longer a reference")
|
219
|
+
end
|
211
220
|
|
212
221
|
# Now make some changes to our resource. We're removing the mode,
|
213
222
|
# changing the source, and adding 'check'.
|
214
223
|
res = mkresource :type => "file", :title => "/tmp/testing",
|
215
224
|
:source => @source, :scope => @scope,
|
216
225
|
:params => {:owner => "bin", :source => ["/tmp/A", "/tmp/C"],
|
217
|
-
:check => "checksum", :require => [ref1, ref2]}
|
226
|
+
:check => "checksum", :require => [ref1, ref2], :subscribe => ref2}
|
218
227
|
|
219
228
|
res.line = 75
|
220
229
|
res.exported = true
|
221
230
|
|
222
|
-
compare_resources(host, res, true, :params => %w{owner source mode check})
|
231
|
+
railsres = compare_resources(host, res, true, :params => %w{owner source mode check})
|
223
232
|
|
224
233
|
# Again make sure our parameters did not change
|
225
234
|
assert_instance_of(Array, res[:require], "Parameter array changed")
|
226
235
|
res[:require].each do |ref|
|
227
236
|
assert_instance_of(Reference, ref, "Resource reference changed")
|
228
237
|
end
|
238
|
+
|
239
|
+
# Again with the serialization checks
|
240
|
+
params = railsres.parameters
|
241
|
+
[params["subscribe"], params["require"]].flatten.each do |ref|
|
242
|
+
assert_instance_of(Reference, ref, "Resource reference is no longer a reference")
|
243
|
+
end
|
244
|
+
|
229
245
|
end
|
230
246
|
end
|
231
247
|
|
232
|
-
# $Id: railsresource.rb
|
248
|
+
# $Id: railsresource.rb 2706 2007-07-18 19:47:09Z luke $
|
233
249
|
|
@@ -6,6 +6,7 @@
|
|
6
6
|
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
|
7
7
|
|
8
8
|
require 'puppettest'
|
9
|
+
require 'mocha'
|
9
10
|
|
10
11
|
class TestTypeAttributes < Test::Unit::TestCase
|
11
12
|
include PuppetTest
|
@@ -315,6 +316,37 @@ class TestTypeAttributes < Test::Unit::TestCase
|
|
315
316
|
inst.value = :nosuchattr
|
316
317
|
end
|
317
318
|
end
|
319
|
+
|
320
|
+
def test_check_ignores_unsupported_params
|
321
|
+
type = Puppet::Type.newtype(:unsupported) do
|
322
|
+
feature :nosuchfeat, "testing"
|
323
|
+
newparam(:name) {}
|
324
|
+
newproperty(:yep) {}
|
325
|
+
newproperty(:nope, :required_features => :nosuchfeat) {}
|
326
|
+
end
|
327
|
+
$yep = :absent
|
328
|
+
type.provide(:only) do
|
329
|
+
def self.supports_parameter?(param)
|
330
|
+
if param.name == :nope
|
331
|
+
return false
|
332
|
+
else
|
333
|
+
return true
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def yep
|
338
|
+
$yep
|
339
|
+
end
|
340
|
+
def yep=(v)
|
341
|
+
$yep = v
|
342
|
+
end
|
343
|
+
end
|
344
|
+
cleanup { Puppet::Type.rmtype(:unsupported) }
|
345
|
+
|
346
|
+
obj = type.create(:name => "test", :check => :yep)
|
347
|
+
obj.expects(:newattr).with(:nope).never
|
348
|
+
obj[:check] = :all
|
349
|
+
end
|
318
350
|
end
|
319
351
|
|
320
|
-
# $Id: attributes.rb
|
352
|
+
# $Id: attributes.rb 2684 2007-07-12 16:39:47Z luke $
|
@@ -43,40 +43,67 @@ class TestTypeInstances < Test::Unit::TestCase
|
|
43
43
|
@instances
|
44
44
|
end
|
45
45
|
|
46
|
-
@names = [:one]
|
46
|
+
@names = [:one, :five, :six]
|
47
47
|
end
|
48
48
|
|
49
49
|
# A provider with the same source
|
50
50
|
@type.provide(:sub, :source => :default, :parent => :default) do
|
51
|
-
@names = [:two]
|
51
|
+
@names = [:two, :seven, :eight]
|
52
52
|
end
|
53
53
|
|
54
54
|
# An unsuitable provider
|
55
55
|
@type.provide(:nope, :parent => :default) do
|
56
56
|
confine :exists => "/no/such/file"
|
57
|
-
@names = [:three]
|
57
|
+
@names = [:three, :nine, :ten]
|
58
58
|
end
|
59
59
|
|
60
60
|
# Another suitable, non-default provider
|
61
61
|
@type.provide(:yep, :parent => :default) do
|
62
|
-
@names = [:four]
|
62
|
+
@names = [:four, :seven, :ten]
|
63
63
|
end
|
64
64
|
|
65
|
+
# Now make a couple of instances, so we know we correctly match instead of always
|
66
|
+
# trying to create new ones.
|
67
|
+
one = @type.create(:name => :one, :ensure => :present)
|
68
|
+
three = @type.create(:name => :three, :ensure => :present, :provider => :sub)
|
69
|
+
five = @type.create(:name => :five, :ensure => :present, :provider => :yep)
|
70
|
+
|
65
71
|
result = nil
|
66
72
|
assert_nothing_raised("Could not get instance list") do
|
67
73
|
result = @type.instances
|
68
74
|
end
|
69
75
|
|
76
|
+
result.each do |resource|
|
77
|
+
assert_instance_of(@type, resource, "Returned non-resource")
|
78
|
+
end
|
79
|
+
|
70
80
|
assert_equal(:one, result[0].name, "Did not get default instances first")
|
71
|
-
assert_equal(@type.provider(:default).instances[0], result[0].provider, "Provider instances were not maintained")
|
72
81
|
|
73
82
|
resources = result.inject({}) { |hash, res| hash[res.name] = res; hash }
|
74
83
|
assert(resources.include?(:four), "Did not get resources from other suitable providers")
|
75
84
|
assert(! resources.include?(:three), "Got resources from unsuitable providers")
|
76
85
|
|
86
|
+
# Now make sure we didn't change the provider type for :five
|
87
|
+
assert_equal(:yep, five.provider.class.name, "Changed provider type when listing resources")
|
88
|
+
|
77
89
|
# Now make sure the resources have an 'ensure' property to go with the value in the provider
|
78
90
|
assert(resources[:one].send(:instance_variable_get, "@parameters").include?(:ensure), "Did not create ensure property")
|
79
91
|
end
|
92
|
+
|
93
|
+
# Make sure resources are entirely deleted.
|
94
|
+
def test_delete
|
95
|
+
aliases = %w{one}
|
96
|
+
obj = @type.create(:name => "testing", :alias => "two")
|
97
|
+
aliases << "two"
|
98
|
+
|
99
|
+
@type.alias("two", obj)
|
100
|
+
|
101
|
+
obj.remove
|
102
|
+
assert_nil(@type["testing"], "Object was not removed from objects hash")
|
103
|
+
assert_nil(@type["one"], "Object's alias was not removed")
|
104
|
+
assert_nil(@type["two"], "Object's second alias was not removed")
|
105
|
+
|
106
|
+
end
|
80
107
|
end
|
81
108
|
|
82
|
-
# $Id: instances.rb
|
109
|
+
# $Id: instances.rb 2718 2007-07-19 22:12:51Z luke $
|
data/test/ral/manager/type.rb
CHANGED
@@ -316,54 +316,6 @@ class TestType < Test::Unit::TestCase
|
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
|
-
def test_loadplugins
|
320
|
-
names = %w{loadedplugin1 loadplugin2 loadplugin3}
|
321
|
-
dirs = []
|
322
|
-
3.times { dirs << tempfile() }
|
323
|
-
# Set plugindest to something random
|
324
|
-
Puppet[:plugindest] = tempfile()
|
325
|
-
|
326
|
-
Puppet[:pluginpath] = dirs.join(":")
|
327
|
-
|
328
|
-
names.each do |name|
|
329
|
-
dir = dirs.shift
|
330
|
-
Dir.mkdir(dir)
|
331
|
-
|
332
|
-
# Create an extra file for later
|
333
|
-
[name, name + "2ness"].each do |n|
|
334
|
-
file = File.join(dir, n + ".rb")
|
335
|
-
File.open(file, "w") do |f|
|
336
|
-
f.puts %{Puppet::Type.newtype('#{n}') do
|
337
|
-
newparam(:argument) do
|
338
|
-
isnamevar
|
339
|
-
end
|
340
|
-
end
|
341
|
-
}
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
assert(Puppet::Type.type(name),
|
346
|
-
"Did not get loaded plugin")
|
347
|
-
|
348
|
-
assert_nothing_raised {
|
349
|
-
Puppet::Type.type(name).create(
|
350
|
-
:name => "myname"
|
351
|
-
)
|
352
|
-
}
|
353
|
-
end
|
354
|
-
|
355
|
-
# Now make sure the plugindest got added to our pluginpath
|
356
|
-
assert(Puppet[:pluginpath].split(":").include?(Puppet[:plugindest]),
|
357
|
-
"Plugin dest did not get added to plugin path")
|
358
|
-
|
359
|
-
# Now make sure it works with just a single path, using the extra files
|
360
|
-
# created above.
|
361
|
-
Puppet[:pluginpath] = Puppet[:pluginpath].split(":")[0]
|
362
|
-
assert(Puppet::Type.type("loadedplugin12ness"),
|
363
|
-
"Did not get loaded plugin")
|
364
|
-
|
365
|
-
end
|
366
|
-
|
367
319
|
def test_newtype_methods
|
368
320
|
assert_nothing_raised {
|
369
321
|
Puppet::Type.newtype(:mytype) do
|
@@ -835,6 +787,34 @@ end
|
|
835
787
|
|
836
788
|
obj.evaluate
|
837
789
|
end
|
790
|
+
|
791
|
+
# Partially test #704, but also cover the rest of the schedule management bases.
|
792
|
+
def test_schedule
|
793
|
+
Puppet::Type.type(:schedule).create(:name => "maint")
|
794
|
+
|
795
|
+
{"maint" => true, nil => false, :fail => :fail}.each do |name, should|
|
796
|
+
args = {:name => tempfile, :ensure => :file}
|
797
|
+
if name
|
798
|
+
args[:schedule] = name
|
799
|
+
end
|
800
|
+
resource = Puppet::Type.type(:file).create(args)
|
801
|
+
|
802
|
+
if should == :fail
|
803
|
+
assert_raise(Puppet::Error, "Did not fail on missing schedule") do
|
804
|
+
resource.schedule
|
805
|
+
end
|
806
|
+
else
|
807
|
+
sched = nil
|
808
|
+
assert_nothing_raised("Failed when schedule was %s" % sched) do
|
809
|
+
sched = resource.schedule
|
810
|
+
end
|
811
|
+
|
812
|
+
if should
|
813
|
+
assert_equal(name, sched.name, "did not get correct schedule back")
|
814
|
+
end
|
815
|
+
end
|
816
|
+
end
|
817
|
+
end
|
838
818
|
end
|
839
819
|
|
840
|
-
# $Id: type.rb
|
820
|
+
# $Id: type.rb 2683 2007-07-12 16:04:34Z luke $
|
@@ -6,7 +6,6 @@ require 'puppettest'
|
|
6
6
|
require 'mocha'
|
7
7
|
require 'puppettest/fileparsing'
|
8
8
|
require 'puppet/type/cron'
|
9
|
-
require 'puppet/provider/cron/crontab'
|
10
9
|
|
11
10
|
class TestCronParsedProvider < Test::Unit::TestCase
|
12
11
|
include PuppetTest
|
@@ -254,27 +253,76 @@ class TestCronParsedProvider < Test::Unit::TestCase
|
|
254
253
|
# Test that a specified cron job will be matched against an existing job
|
255
254
|
# with no name, as long as all fields match
|
256
255
|
def test_matchcron
|
257
|
-
|
256
|
+
mecron = "0,30 * * * * date
|
257
|
+
|
258
|
+
* * * * * funtest
|
259
|
+
# a comment
|
260
|
+
0,30 * * 1 * date
|
261
|
+
"
|
262
|
+
|
263
|
+
youcron = "0,30 * * * * date
|
264
|
+
|
265
|
+
* * * * * yaytest
|
266
|
+
# a comment
|
267
|
+
0,30 * * 1 * fooness
|
268
|
+
"
|
258
269
|
setme
|
259
270
|
@provider.filetype = :ram
|
271
|
+
you = "you"
|
260
272
|
|
261
|
-
|
262
|
-
|
263
|
-
|
273
|
+
# Write the same tab to multiple targets
|
274
|
+
@provider.target_object(@me).write(mecron.gsub(/^\s+/, ''))
|
275
|
+
@provider.target_object(you).write(youcron.gsub(/^\s+/, ''))
|
276
|
+
|
277
|
+
# Now make some crons that should match
|
278
|
+
matchers = [
|
279
|
+
@type.create(
|
264
280
|
:name => "yaycron",
|
265
281
|
:minute => [0, 30],
|
266
282
|
:command => "date",
|
267
283
|
:user => @me
|
284
|
+
),
|
285
|
+
@type.create(
|
286
|
+
:name => "youtest",
|
287
|
+
:command => "yaytest",
|
288
|
+
:user => you
|
268
289
|
)
|
269
|
-
|
290
|
+
]
|
291
|
+
|
292
|
+
nonmatchers = [
|
293
|
+
@type.create(
|
294
|
+
:name => "footest",
|
295
|
+
:minute => [0, 30],
|
296
|
+
:hour => 1,
|
297
|
+
:command => "fooness",
|
298
|
+
:user => @me # wrong target
|
299
|
+
),
|
300
|
+
@type.create(
|
301
|
+
:name => "funtest2",
|
302
|
+
:command => "funtest",
|
303
|
+
:user => you # wrong target for this cron
|
304
|
+
)
|
305
|
+
]
|
306
|
+
|
307
|
+
# Create another cron so we prefetch two of them
|
308
|
+
@type.create(:name => "testing", :minute => 30, :command => "whatever", :user => "you")
|
309
|
+
|
310
|
+
assert_nothing_raised("Could not prefetch cron") do
|
311
|
+
@provider.prefetch([matchers, nonmatchers].flatten.inject({}) { |crons, cron| crons[cron.name] = cron; crons })
|
312
|
+
end
|
270
313
|
|
271
|
-
|
272
|
-
|
314
|
+
matchers.each do |cron|
|
315
|
+
assert_equal(:present, cron.provider.ensure, "Cron %s was not matched" % cron.name)
|
316
|
+
if value = cron.value(:minute) and value == "*"
|
317
|
+
value = :absent
|
318
|
+
end
|
319
|
+
assert_equal(value, cron.provider.minute, "Minutes were not retrieved, so cron was not matched")
|
320
|
+
assert_equal(cron.value(:target), cron.provider.target, "Cron %s was matched from the wrong target" % cron.name)
|
321
|
+
end
|
273
322
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
"Did not match cron job")
|
323
|
+
nonmatchers.each do |cron|
|
324
|
+
assert_equal(:absent, cron.provider.ensure, "Cron %s was incorrectly matched" % cron.name)
|
325
|
+
end
|
278
326
|
end
|
279
327
|
|
280
328
|
def test_data
|
@@ -395,4 +443,4 @@ class TestCronParsedProvider < Test::Unit::TestCase
|
|
395
443
|
end
|
396
444
|
end
|
397
445
|
|
398
|
-
# $Id: crontab.rb
|
446
|
+
# $Id: crontab.rb 2680 2007-07-12 04:27:04Z luke $
|