puppet 0.23.1 → 0.23.2
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 +31 -0
- data/bin/puppetd +2 -1
- data/conf/redhat/puppet.spec +9 -6
- data/conf/redhat/server.init +4 -5
- data/examples/code/mac_dscl.pp +28 -0
- data/examples/code/mac_dscl_revert.pp +26 -0
- data/examples/code/mac_netinfo.pp +5 -0
- data/examples/code/mac_pkgdmg.pp +7 -0
- data/ext/puppet-test +69 -2
- data/lib/puppet.rb +2 -2
- data/lib/puppet/configuration.rb +5 -1
- data/lib/puppet/network/server/mongrel.rb +3 -3
- data/lib/puppet/parser/ast.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +3 -3
- data/lib/puppet/parser/ast/node.rb +2 -2
- data/lib/puppet/parser/collector.rb +2 -2
- data/lib/puppet/parser/interpreter.rb +38 -215
- data/lib/puppet/parser/parser.rb +11 -228
- data/lib/puppet/parser/parser_support.rb +447 -0
- data/lib/puppet/parser/resource/param.rb +2 -2
- data/lib/puppet/provider.rb +5 -3
- data/lib/puppet/provider/cron/crontab.rb +22 -9
- data/lib/puppet/provider/group/directoryservice.rb +23 -0
- data/lib/puppet/provider/interface/redhat.rb +251 -0
- data/lib/puppet/provider/interface/sunos.rb +116 -0
- data/lib/puppet/provider/mount.rb +4 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +341 -0
- data/lib/puppet/provider/package/dpkg.rb +2 -2
- data/lib/puppet/provider/package/openbsd.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +2 -4
- data/lib/puppet/provider/package/sun.rb +2 -2
- data/lib/puppet/provider/parsedfile.rb +32 -29
- data/lib/puppet/provider/user/directoryservice.rb +116 -0
- data/lib/puppet/rails/host.rb +1 -1
- data/lib/puppet/reference/configuration.rb +7 -4
- data/lib/puppet/type/interface.rb +57 -0
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/util/config.rb +10 -3
- data/lib/puppet/util/fileparsing.rb +2 -2
- data/test/language/ast/hostclass.rb +1 -17
- data/test/language/interpreter.rb +18 -388
- data/test/language/node.rb +8 -8
- data/test/language/parser.rb +444 -45
- data/test/lib/puppettest/parsertesting.rb +2 -2
- data/test/lib/puppettest/support/collection.rb +2 -2
- data/test/network/server/mongrel_test.rb +24 -3
- data/test/rails/collection.rb +34 -1
- data/test/ral/providers/cron/crontab.rb +198 -40
- data/test/ral/providers/mount/parsed.rb +69 -46
- data/test/ral/providers/parsedfile.rb +20 -28
- data/test/ral/types/cron.rb +20 -24
- data/test/ral/types/interface.rb +40 -0
- data/test/ral/types/package.rb +6 -2
- data/test/util/config.rb +106 -30
- metadata +14 -2
@@ -46,7 +46,7 @@ module PuppetTest::ParserTesting
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def mkparser
|
49
|
-
Puppet::Parser::Parser.new(
|
49
|
+
Puppet::Parser::Parser.new()
|
50
50
|
end
|
51
51
|
|
52
52
|
def mkscope(hash = {})
|
@@ -389,4 +389,4 @@ module PuppetTest::ParserTesting
|
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
392
|
-
# $Id: parsertesting.rb
|
392
|
+
# $Id: parsertesting.rb 2742 2007-08-03 23:49:53Z luke $
|
@@ -18,7 +18,7 @@ module PuppetTest::Support::Collection
|
|
18
18
|
query = nil
|
19
19
|
|
20
20
|
assert_nothing_raised("Could not parse '#{str}'") do
|
21
|
-
query = parser.parse(code)[0].query
|
21
|
+
query = parser.parse(code).classes[""].code[0].query
|
22
22
|
end
|
23
23
|
|
24
24
|
yield str, res, query
|
@@ -27,4 +27,4 @@ module PuppetTest::Support::Collection
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
# $Id: collection.rb
|
30
|
+
# $Id: collection.rb 2742 2007-08-03 23:49:53Z luke $
|
@@ -3,6 +3,7 @@
|
|
3
3
|
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
|
4
4
|
|
5
5
|
require 'puppettest'
|
6
|
+
require 'mocha'
|
6
7
|
|
7
8
|
class TestMongrelServer < PuppetTest::TestCase
|
8
9
|
confine "Missing mongrel" => Puppet.features.mongrel?
|
@@ -25,14 +26,34 @@ class TestMongrelServer < PuppetTest::TestCase
|
|
25
26
|
|
26
27
|
ip = Facter.value(:ipaddress)
|
27
28
|
params["REMOTE_ADDR"] = ip
|
29
|
+
params[Puppet[:ssl_client_header]] = ""
|
30
|
+
params[Puppet[:ssl_client_verify_header]] = "failure"
|
31
|
+
info = nil
|
32
|
+
Resolv.expects(:getname).with(ip).returns("host.domain.com").times(3)
|
33
|
+
assert_nothing_raised("Could not call client_info") do
|
34
|
+
info = mongrel.send(:client_info, obj)
|
35
|
+
end
|
36
|
+
assert(! info.authenticated?, "Client info object was marked valid even though headers were missing")
|
37
|
+
assert_equal(ip, info.ip, "Did not copy over ip correctly")
|
38
|
+
|
39
|
+
assert_equal("host.domain.com", info.name, "Did not copy over hostname correctly")
|
40
|
+
|
41
|
+
# Now add a valid auth header.
|
28
42
|
params[Puppet[:ssl_client_header]] = "/CN=host.domain.com"
|
43
|
+
assert_nothing_raised("Could not call client_info") do
|
44
|
+
info = mongrel.send(:client_info, obj)
|
45
|
+
end
|
46
|
+
assert(! info.authenticated?, "Client info object was marked valid even though the verify header was fals")
|
47
|
+
assert_equal(ip, info.ip, "Did not copy over ip correctly")
|
48
|
+
assert_equal("host.domain.com", info.name, "Did not copy over hostname correctly")
|
29
49
|
|
30
|
-
|
50
|
+
# Now change the verify header to be true
|
51
|
+
params[Puppet[:ssl_client_verify_header]] = "SUCCESS"
|
31
52
|
assert_nothing_raised("Could not call client_info") do
|
32
53
|
info = mongrel.send(:client_info, obj)
|
33
54
|
end
|
34
55
|
|
35
|
-
assert(info.authenticated?, "Client info object was not marked valid even though
|
56
|
+
assert(info.authenticated?, "Client info object was not marked valid even though all headers were correct")
|
36
57
|
assert_equal(ip, info.ip, "Did not copy over ip correctly")
|
37
58
|
assert_equal("host.domain.com", info.name, "Did not copy over hostname correctly")
|
38
59
|
|
@@ -68,4 +89,4 @@ class TestMongrelServer < PuppetTest::TestCase
|
|
68
89
|
end
|
69
90
|
end
|
70
91
|
|
71
|
-
# $Id: mongrel_test.rb
|
92
|
+
# $Id: mongrel_test.rb 2752 2007-08-06 20:05:28Z luke $
|
data/test/rails/collection.rb
CHANGED
@@ -209,6 +209,39 @@ class TestRailsCollection < PuppetTest::TestCase
|
|
209
209
|
|
210
210
|
assert(ret.empty?, "Found exports from our own host")
|
211
211
|
end
|
212
|
+
|
213
|
+
# #731 -- we're collecting all resources, not just exported resources.
|
214
|
+
def test_only_collecting_exported_resources
|
215
|
+
railsinit
|
216
|
+
|
217
|
+
# Make our configuration
|
218
|
+
host = Puppet::Rails::Host.new(:name => "myhost")
|
219
|
+
|
220
|
+
host.resources.build(:title => "/tmp/exporttest1", :restype => "file",
|
221
|
+
:exported => true)
|
222
|
+
host.resources.build(:title => "/tmp/exporttest2", :restype => "file",
|
223
|
+
:exported => false)
|
224
|
+
|
225
|
+
host.save
|
226
|
+
|
227
|
+
@scope.host = "otherhost"
|
228
|
+
|
229
|
+
# Now make a collector
|
230
|
+
coll = nil
|
231
|
+
assert_nothing_raised do
|
232
|
+
coll = Puppet::Parser::Collector.new(@scope, "file", nil, nil, :exported)
|
233
|
+
end
|
234
|
+
|
235
|
+
# And make sure we get nada back
|
236
|
+
ret = nil
|
237
|
+
assert_nothing_raised do
|
238
|
+
ret = coll.collect_exported
|
239
|
+
end
|
240
|
+
|
241
|
+
names = ret.collect { |res| res.title }
|
242
|
+
|
243
|
+
assert_equal(%w{/tmp/exporttest1}, names, "Collected incorrect resource list")
|
244
|
+
end
|
212
245
|
end
|
213
246
|
|
214
|
-
# $Id: collection.rb
|
247
|
+
# $Id: collection.rb 2746 2007-08-05 17:57:31Z luke $
|
@@ -11,11 +11,41 @@ class TestCronParsedProvider < Test::Unit::TestCase
|
|
11
11
|
include PuppetTest
|
12
12
|
include PuppetTest::FileParsing
|
13
13
|
|
14
|
+
|
15
|
+
FIELDS = {
|
16
|
+
:crontab => %w{command minute hour month monthday weekday}.collect { |o| o.intern },
|
17
|
+
:freebsd_special => %w{special command}.collect { |o| o.intern },
|
18
|
+
:environment => [:line],
|
19
|
+
:blank => [:line],
|
20
|
+
:comment => [:line],
|
21
|
+
}
|
22
|
+
|
23
|
+
# These are potentially multi-line records; there's no one-to-one map, but they model
|
24
|
+
# a full cron job. These tests assume individual record types will always be correctly
|
25
|
+
# parsed, so all they
|
26
|
+
def sample_crons
|
27
|
+
unless defined? @sample_crons
|
28
|
+
@sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml")))
|
29
|
+
end
|
30
|
+
@sample_crons
|
31
|
+
end
|
32
|
+
|
33
|
+
# These are simple lines that can appear in the files; there is a one to one
|
34
|
+
# mapping between records and lines. We have plenty of redundancy here because
|
35
|
+
# we use these records to build up our complex, multi-line cron jobs below.
|
36
|
+
def sample_records
|
37
|
+
unless defined? @sample_records
|
38
|
+
@sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml")))
|
39
|
+
end
|
40
|
+
@sample_records
|
41
|
+
end
|
42
|
+
|
14
43
|
def setup
|
15
44
|
super
|
16
45
|
@type = Puppet::Type.type(:cron)
|
17
46
|
@provider = @type.provider(:crontab)
|
18
47
|
@provider.initvars
|
48
|
+
@crondir = datadir(File.join(%w{providers cron}))
|
19
49
|
|
20
50
|
@oldfiletype = @provider.filetype
|
21
51
|
end
|
@@ -27,31 +57,160 @@ class TestCronParsedProvider < Test::Unit::TestCase
|
|
27
57
|
super
|
28
58
|
end
|
29
59
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"
|
35
|
-
|
36
|
-
}.each do |
|
60
|
+
# Make sure a cron job matches up. Any non-passed fields are considered absent.
|
61
|
+
def assert_cron_equal(msg, cron, options)
|
62
|
+
assert_instance_of(@provider, cron, "not an instance of provider in %s" % msg)
|
63
|
+
options.each do |param, value|
|
64
|
+
assert_equal(value, cron.send(param), "%s was not equal in %s" % [param, msg])
|
65
|
+
end
|
66
|
+
%w{command environment minute hour month monthday weekday}.each do |var|
|
67
|
+
unless options.include?(var.intern)
|
68
|
+
assert_equal(:absent, cron.send(var), "%s was not parsed absent in %s" % [var, msg])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Make sure a cron record matches. This only works for crontab records.
|
74
|
+
def assert_record_equal(msg, record, options)
|
75
|
+
unless options.include?(:record_type)
|
76
|
+
raise ArgumentError, "You must pass the required record type"
|
77
|
+
end
|
78
|
+
assert_instance_of(Hash, record, "not an instance of a hash in %s" % msg)
|
79
|
+
options.each do |param, value|
|
80
|
+
assert_equal(value, record[param], "%s was not equal in %s" % [param, msg])
|
81
|
+
end
|
82
|
+
FIELDS[record[:record_type]].each do |var|
|
83
|
+
unless options.include?(var)
|
84
|
+
assert_equal(:absent, record[var], "%s was not parsed absent in %s" % [var, msg])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def assert_header(file)
|
90
|
+
header = []
|
91
|
+
file.gsub! /^(# HEADER: .+$)\n/ do
|
92
|
+
header << $1
|
93
|
+
''
|
94
|
+
end
|
95
|
+
assert_equal(4, header.length, "Did not get four header lines")
|
96
|
+
end
|
97
|
+
|
98
|
+
# This handles parsing every possible iteration of cron records. Note that this is only
|
99
|
+
# single-line stuff and doesn't include multi-line values (e.g., with names and/or envs).
|
100
|
+
# Those have separate tests.
|
101
|
+
def test_parse_line
|
102
|
+
# First just do each sample record one by one
|
103
|
+
sample_records.each do |name, options|
|
104
|
+
result = nil
|
105
|
+
assert_nothing_raised("Could not parse %s: '%s'" % [name, options[:text]]) do
|
106
|
+
result = @provider.parse_line(options[:text])
|
107
|
+
end
|
108
|
+
assert_record_equal("record for %s" % name, result, options[:record])
|
109
|
+
end
|
110
|
+
|
111
|
+
# Then do them all at once.
|
112
|
+
records = []
|
113
|
+
text = ""
|
114
|
+
sample_records.each do |name, options|
|
115
|
+
records << options[:record]
|
116
|
+
text += options[:text] + "\n"
|
117
|
+
end
|
118
|
+
|
119
|
+
result = nil
|
120
|
+
assert_nothing_raised("Could not match all records in one file") do
|
121
|
+
result = @provider.parse(text)
|
122
|
+
end
|
123
|
+
|
124
|
+
records.zip(result).each do |should, record|
|
125
|
+
assert_record_equal("record for %s in full match" % should.inspect, record, should)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Here we test that each record generates to the correct text.
|
130
|
+
def test_generate_line
|
131
|
+
# First just do each sample record one by one
|
132
|
+
sample_records.each do |name, options|
|
37
133
|
result = nil
|
38
|
-
assert_nothing_raised("Could not
|
39
|
-
result = @provider.
|
134
|
+
assert_nothing_raised("Could not generate %s: '%s'" % [name, options[:record]]) do
|
135
|
+
result = @provider.to_line(options[:record])
|
40
136
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
137
|
+
assert_equal(options[:text], result, "Did not generate correct text for %s" % name)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Then do them all at once.
|
141
|
+
records = []
|
142
|
+
text = ""
|
143
|
+
sample_records.each do |name, options|
|
144
|
+
records << options[:record]
|
145
|
+
text += options[:text] + "\n"
|
146
|
+
end
|
147
|
+
|
148
|
+
result = nil
|
149
|
+
assert_nothing_raised("Could not match all records in one file") do
|
150
|
+
result = @provider.to_file(records)
|
151
|
+
end
|
152
|
+
|
153
|
+
assert_header(result)
|
154
|
+
|
155
|
+
assert_equal(text, result, "Did not generate correct full crontab")
|
156
|
+
end
|
157
|
+
|
158
|
+
# Test cronjobs that are made up from multiple records.
|
159
|
+
def test_multi_line_cronjobs
|
160
|
+
fulltext = ""
|
161
|
+
all_records = []
|
162
|
+
sample_crons.each do |name, record_names|
|
163
|
+
records = record_names.collect do |record_name|
|
164
|
+
unless record = sample_records[record_name]
|
165
|
+
raise "Could not find sample record %s" % record_name
|
49
166
|
end
|
167
|
+
record
|
168
|
+
end
|
169
|
+
|
170
|
+
text = records.collect { |r| r[:text] }.join("\n") + "\n"
|
171
|
+
record_list = records.collect { |r| r[:record] }
|
172
|
+
|
173
|
+
# Add it to our full collection
|
174
|
+
all_records += record_list
|
175
|
+
fulltext += text
|
176
|
+
|
177
|
+
# First make sure we generate each one correctly
|
178
|
+
result = nil
|
179
|
+
assert_nothing_raised("Could not generate multi-line cronjob %s" % [name]) do
|
180
|
+
result = @provider.to_file(record_list)
|
181
|
+
end
|
182
|
+
assert_header(result)
|
183
|
+
assert_equal(text, result, "Did not generate correct text for multi-line cronjob %s" % name)
|
184
|
+
|
185
|
+
# Now make sure we parse each one correctly
|
186
|
+
assert_nothing_raised("Could not parse multi-line cronjob %s" % [name]) do
|
187
|
+
result = @provider.parse(text)
|
188
|
+
end
|
189
|
+
record_list.zip(result).each do |should, record|
|
190
|
+
assert_record_equal("multiline cronjob %s" % name, record, should)
|
50
191
|
end
|
51
192
|
end
|
193
|
+
|
194
|
+
# Make sure we can generate it all correctly
|
195
|
+
result = nil
|
196
|
+
assert_nothing_raised("Could not generate all multi-line cronjobs") do
|
197
|
+
result = @provider.to_file(all_records)
|
198
|
+
end
|
199
|
+
assert_header(result)
|
200
|
+
assert_equal(fulltext, result, "Did not generate correct text for all multi-line cronjobs")
|
201
|
+
|
202
|
+
# Now make sure we parse them all correctly
|
203
|
+
assert_nothing_raised("Could not parse multi-line cronjobs") do
|
204
|
+
result = @provider.parse(fulltext)
|
205
|
+
end
|
206
|
+
all_records.zip(result).each do |should, record|
|
207
|
+
assert_record_equal("multiline cronjob %s", record, should)
|
208
|
+
end
|
52
209
|
end
|
53
210
|
|
54
|
-
|
211
|
+
# Take our sample files, and make sure we can entirely parse them,
|
212
|
+
# then that we can generate them again and we get the same data.
|
213
|
+
def test_parse_and_generate_sample_files
|
55
214
|
@provider.filetype = :ram
|
56
215
|
crondir = datadir(File.join(%w{providers cron}))
|
57
216
|
files = Dir.glob("%s/crontab.*" % crondir)
|
@@ -408,39 +567,38 @@ class TestCronParsedProvider < Test::Unit::TestCase
|
|
408
567
|
target = @provider.target_object(@me)
|
409
568
|
|
410
569
|
# First with no env settings
|
411
|
-
|
570
|
+
resource = @type.create :command => "/bin/echo yay", :name => "test", :hour => 4
|
571
|
+
cron = resource.provider
|
412
572
|
|
413
|
-
|
573
|
+
cron.ensure = :present
|
574
|
+
cron.command = "/bin/echo yay"
|
575
|
+
cron.hour = %w{4}
|
576
|
+
cron.flush
|
414
577
|
|
415
|
-
|
578
|
+
result = target.read
|
579
|
+
assert_equal("# Puppet Name: test\n* 4 * * * /bin/echo yay\n", result, "Did not write cron out correctly")
|
416
580
|
|
417
581
|
# Now set the env
|
418
|
-
cron
|
419
|
-
|
582
|
+
cron.environment = "TEST=foo"
|
583
|
+
cron.flush
|
420
584
|
|
421
|
-
|
422
|
-
|
423
|
-
#assert_equal(["TEST=foo"], props[:environment], "Did not get environment setting")
|
585
|
+
result = target.read
|
586
|
+
assert_equal("# Puppet Name: test\nTEST=foo\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
|
424
587
|
|
425
588
|
# Modify it
|
426
|
-
cron
|
427
|
-
|
589
|
+
cron.environment = ["TEST=foo", "BLAH=yay"]
|
590
|
+
cron.flush
|
428
591
|
|
429
|
-
|
430
|
-
|
431
|
-
assert(target.read.include?("BLAH=yay"), "Did not get second environment setting")
|
432
|
-
#assert_equal(["TEST=foo", "BLAH=yay"], props[:environment], "Did not modify environment setting")
|
592
|
+
result = target.read
|
593
|
+
assert_equal("# Puppet Name: test\nTEST=foo\nBLAH=yay\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
|
433
594
|
|
434
595
|
# And remove it
|
435
|
-
cron
|
436
|
-
|
437
|
-
|
438
|
-
props = cron.retrieve.inject({}) { |hash, ary| hash[ary[0]] = ary[1]; hash }
|
439
|
-
assert(! target.read.include?("TEST=foo"), "Did not remove environment setting")
|
440
|
-
assert(! target.read.include?("BLAH=yay"), "Did not remove second environment setting")
|
441
|
-
#assert_nil(props[:environment], "Did not modify environment setting")
|
596
|
+
cron.environment = :absent
|
597
|
+
cron.flush
|
442
598
|
|
599
|
+
result = target.read
|
600
|
+
assert_equal("# Puppet Name: test\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
|
443
601
|
end
|
444
602
|
end
|
445
603
|
|
446
|
-
# $Id: crontab.rb
|
604
|
+
# $Id: crontab.rb 2750 2007-08-06 17:59:37Z luke $
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/
|
4
4
|
|
5
|
+
require 'mocha'
|
5
6
|
require 'puppettest'
|
6
7
|
require 'puppettest/fileparsing'
|
7
8
|
require 'facter'
|
8
9
|
|
9
|
-
|
10
|
+
module MountTesting
|
10
11
|
include PuppetTest
|
11
12
|
include PuppetTest::FileParsing
|
12
13
|
|
@@ -25,6 +26,20 @@ class TestParsedMounts < Test::Unit::TestCase
|
|
25
26
|
super
|
26
27
|
end
|
27
28
|
|
29
|
+
def fake_fstab
|
30
|
+
os = Facter['operatingsystem']
|
31
|
+
if os == "Solaris"
|
32
|
+
name = "solaris.fstab"
|
33
|
+
elsif os == "FreeBSD"
|
34
|
+
name = "freebsd.fstab"
|
35
|
+
else
|
36
|
+
# Catchall for other fstabs
|
37
|
+
name = "linux.fstab"
|
38
|
+
end
|
39
|
+
oldpath = @provider.default_target
|
40
|
+
return fakefile(File::join("data/types/mount", name))
|
41
|
+
end
|
42
|
+
|
28
43
|
def mkmountargs
|
29
44
|
mount = nil
|
30
45
|
|
@@ -67,6 +82,10 @@ class TestParsedMounts < Test::Unit::TestCase
|
|
67
82
|
def mkfaketype
|
68
83
|
@provider.filetype = Puppet::Util::FileType.filetype(:ram)
|
69
84
|
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class TestParsedMounts < Test::Unit::TestCase
|
88
|
+
include MountTesting
|
70
89
|
|
71
90
|
def test_default_target
|
72
91
|
should = case Facter.value(:operatingsystem)
|
@@ -113,45 +132,64 @@ class TestParsedMounts < Test::Unit::TestCase
|
|
113
132
|
assert_equal(5, mount.dump, "did not flush change to disk")
|
114
133
|
end
|
115
134
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
135
|
+
# #730 - Make sure 'flush' is called when a mount is moving from absent to mounted
|
136
|
+
def test_flush_when_mounting_absent_fs
|
137
|
+
@provider.filetype = :ram
|
138
|
+
mount = mkmount
|
139
|
+
|
140
|
+
mount.expects(:flush)
|
141
|
+
mount.expects(:mountcmd) # just so we don't actually try to mount anything
|
142
|
+
mount.mount
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class TestParsedMountsNonDarwin < PuppetTest::TestCase
|
147
|
+
confine "Mount type not tested on Darwin" => Facter["operatingsystem"].value != "Darwin"
|
148
|
+
include MountTesting
|
149
|
+
|
150
|
+
def test_mountsparse
|
151
|
+
tab = fake_fstab
|
152
|
+
fakedataparse(tab) do
|
153
|
+
# Now just make we've got some mounts we know will be there
|
154
|
+
hashes = @provider.target_records(tab).find_all { |i| i.is_a? Hash }
|
155
|
+
assert(hashes.length > 0, "Did not create any hashes")
|
156
|
+
root = hashes.find { |i| i[:name] == "/" }
|
157
|
+
assert(root, "Could not retrieve root mount")
|
158
|
+
|
159
|
+
assert_nothing_raised("Could not rewrite file") do
|
160
|
+
@provider.to_file(hashes)
|
129
161
|
end
|
130
162
|
end
|
163
|
+
end
|
131
164
|
|
132
|
-
|
133
|
-
|
134
|
-
|
165
|
+
def test_rootfs
|
166
|
+
fs = nil
|
167
|
+
type = @mount.create :name => "/"
|
135
168
|
|
136
|
-
|
169
|
+
provider = type.provider
|
137
170
|
|
138
|
-
|
139
|
-
|
171
|
+
assert(FileTest.exists?(@provider.default_target),
|
172
|
+
"FSTab %s does not exist" % @provider.default_target)
|
140
173
|
|
141
|
-
|
142
|
-
|
143
|
-
|
174
|
+
assert_nothing_raised do
|
175
|
+
@provider.prefetch("/" => type)
|
176
|
+
end
|
144
177
|
|
145
|
-
|
146
|
-
|
178
|
+
assert_equal(:present, type.provider.property_hash[:ensure],
|
179
|
+
"Could not find root fs with provider %s" % provider.class.name)
|
147
180
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
181
|
+
assert_nothing_raised {
|
182
|
+
assert(provider.mounted?, "Root is considered not mounted")
|
183
|
+
}
|
152
184
|
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class TestParsedMountsNonDarwinAsRoot < PuppetTest::TestCase
|
188
|
+
confine "Mount type not tested on Darwin" => Facter["operatingsystem"].value != "Darwin"
|
189
|
+
confine "Not running as root" => Puppet.features.root?
|
190
|
+
|
191
|
+
include MountTesting
|
153
192
|
|
154
|
-
if Puppet.features.root? and Facter.value(:operatingsystem) != "Darwin"
|
155
193
|
def test_mountfs
|
156
194
|
fs = nil
|
157
195
|
case Facter.value(:hostname)
|
@@ -208,21 +246,6 @@ class TestParsedMounts < Test::Unit::TestCase
|
|
208
246
|
obj.remount
|
209
247
|
end
|
210
248
|
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def fake_fstab
|
214
|
-
os = Facter['operatingsystem']
|
215
|
-
if os == "Solaris"
|
216
|
-
name = "solaris.fstab"
|
217
|
-
elsif os == "FreeBSD"
|
218
|
-
name = "freebsd.fstab"
|
219
|
-
else
|
220
|
-
# Catchall for other fstabs
|
221
|
-
name = "linux.fstab"
|
222
|
-
end
|
223
|
-
oldpath = @provider.default_target
|
224
|
-
return fakefile(File::join("data/types/mount", name))
|
225
|
-
end
|
226
249
|
end
|
227
250
|
|
228
|
-
# $Id: parsed.rb
|
251
|
+
# $Id: parsed.rb 2745 2007-08-05 17:49:23Z luke $
|