puppet 0.16.0 → 0.18.4
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 +98 -0
- data/Rakefile +5 -1
- data/bin/puppet +1 -1
- data/bin/puppetca +25 -11
- data/bin/puppetd +189 -66
- data/bin/puppetdoc +79 -62
- data/bin/puppetmasterd +93 -49
- data/bin/puppetrun +385 -0
- data/conf/redhat/client.init +5 -2
- data/conf/redhat/fileserver.conf +1 -1
- data/conf/redhat/lsb-config.patch +51 -0
- data/conf/redhat/puppet.spec +45 -18
- data/conf/redhat/puppetd.conf +32 -4
- data/conf/redhat/server.init +5 -2
- data/conf/solaris/pkginfo +7 -0
- data/conf/solaris/smf/puppetd.xml +77 -0
- data/conf/solaris/smf/puppetmasterd.xml +77 -0
- data/conf/solaris/smf/svc-puppetd +66 -0
- data/conf/solaris/smf/svc-puppetmasterd +62 -0
- data/examples/code/failers/noobjectrvalue +1 -0
- data/examples/code/snippets/deepclassheirarchy.pp +23 -0
- data/examples/code/snippets/defineoverrides.pp +17 -0
- data/examples/code/snippets/emptyexec.pp +3 -0
- data/examples/code/snippets/selectorvalues.pp +6 -1
- data/examples/code/snippets/tagged.pp +35 -0
- data/ext/ldap/puppet.schema +2 -2
- data/install.rb +4 -2
- data/lib/puppet.rb +206 -15
- data/lib/puppet/client.rb +30 -20
- data/lib/puppet/client/ca.rb +2 -2
- data/lib/puppet/client/dipper.rb +5 -9
- data/lib/puppet/client/master.rb +224 -44
- data/lib/puppet/client/pelement.rb +54 -9
- data/lib/puppet/client/proxy.rb +3 -2
- data/lib/puppet/client/reporter.rb +34 -0
- data/lib/puppet/client/runner.rb +17 -0
- data/lib/puppet/config.rb +136 -55
- data/lib/puppet/daemon.rb +59 -37
- data/lib/puppet/element.rb +2 -1
- data/lib/puppet/event.rb +14 -3
- data/lib/puppet/filetype.rb +28 -19
- data/lib/puppet/log.rb +297 -132
- data/lib/puppet/metric.rb +31 -131
- data/lib/puppet/networkclient.rb +73 -46
- data/lib/puppet/parameter.rb +49 -1
- data/lib/puppet/parsedfile.rb +32 -12
- data/lib/puppet/parser/ast.rb +6 -1
- data/lib/puppet/parser/ast/astarray.rb +32 -6
- data/lib/puppet/parser/ast/collection.rb +91 -0
- data/lib/puppet/parser/ast/compdef.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +24 -11
- data/lib/puppet/parser/ast/function.rb +50 -0
- data/lib/puppet/parser/ast/hostclass.rb +70 -22
- data/lib/puppet/parser/ast/node.rb +17 -8
- data/lib/puppet/parser/ast/nodedef.rb +1 -1
- data/lib/puppet/parser/ast/objectdef.rb +28 -10
- data/lib/puppet/parser/ast/selector.rb +4 -1
- data/lib/puppet/parser/functions.rb +145 -0
- data/lib/puppet/parser/interpreter.rb +243 -86
- data/lib/puppet/parser/lexer.rb +5 -4
- data/lib/puppet/parser/parser.rb +586 -505
- data/lib/puppet/parser/scope.rb +337 -187
- data/lib/puppet/rails.rb +115 -0
- data/lib/puppet/rails/database.rb +40 -0
- data/lib/puppet/rails/host.rb +83 -0
- data/lib/puppet/rails/rails_object.rb +42 -0
- data/lib/puppet/rails/rails_parameter.rb +5 -0
- data/lib/puppet/reports/rrdgraph.rb +20 -0
- data/lib/puppet/reports/tagmail.rb +94 -0
- data/lib/puppet/server.rb +20 -4
- data/lib/puppet/server/authconfig.rb +14 -3
- data/lib/puppet/server/authstore.rb +2 -2
- data/lib/puppet/server/ca.rb +23 -11
- data/lib/puppet/server/filebucket.rb +10 -10
- data/lib/puppet/server/fileserver.rb +4 -8
- data/lib/puppet/server/master.rb +19 -22
- data/lib/puppet/server/pelement.rb +28 -16
- data/lib/puppet/server/report.rb +184 -0
- data/lib/puppet/server/runner.rb +62 -0
- data/lib/puppet/server/servlet.rb +23 -9
- data/lib/puppet/sslcertificates/ca.rb +25 -1
- data/lib/puppet/statechange.rb +34 -53
- data/lib/puppet/storage.rb +1 -2
- data/lib/puppet/transaction.rb +305 -133
- data/lib/puppet/transaction/report.rb +42 -0
- data/lib/puppet/transportable.rb +57 -33
- data/lib/puppet/type.rb +260 -127
- data/lib/puppet/type/component.rb +9 -21
- data/lib/puppet/type/cron.rb +367 -116
- data/lib/puppet/type/exec.rb +15 -16
- data/lib/puppet/type/group.rb +9 -1
- data/lib/puppet/type/nameservice.rb +2 -5
- data/lib/puppet/type/nameservice/netinfo.rb +3 -0
- data/lib/puppet/type/nameservice/objectadd.rb +23 -10
- data/lib/puppet/type/nameservice/pw.rb +16 -3
- data/lib/puppet/type/package.rb +25 -75
- data/lib/puppet/type/package/apple.rb +15 -1
- data/lib/puppet/type/package/apt.rb +37 -2
- data/lib/puppet/type/package/blastwave.rb +136 -0
- data/lib/puppet/type/package/dpkg.rb +4 -4
- data/lib/puppet/type/package/gem.rb +119 -0
- data/lib/puppet/type/package/openbsd.rb +7 -6
- data/lib/puppet/type/package/ports.rb +7 -2
- data/lib/puppet/type/package/rpm.rb +1 -1
- data/lib/puppet/type/package/sun.rb +23 -9
- data/lib/puppet/type/package/sunfreeware.rb +7 -0
- data/lib/puppet/type/package/yum.rb +16 -9
- data/lib/puppet/type/parsedtype.rb +7 -5
- data/lib/puppet/type/parsedtype/mount.rb +55 -34
- data/lib/puppet/type/parsedtype/port.rb +7 -1
- data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
- data/lib/puppet/type/pfile.rb +115 -23
- data/lib/puppet/type/pfile/checksum.rb +18 -5
- data/lib/puppet/type/pfile/content.rb +2 -2
- data/lib/puppet/type/pfile/ensure.rb +3 -3
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/type/pfile/source.rb +28 -17
- data/lib/puppet/type/pfile/target.rb +25 -17
- data/lib/puppet/type/pfilebucket.rb +25 -6
- data/lib/puppet/type/schedule.rb +6 -6
- data/lib/puppet/type/service.rb +24 -14
- data/lib/puppet/type/service/debian.rb +1 -1
- data/lib/puppet/type/service/redhat.rb +13 -10
- data/lib/puppet/type/service/smf.rb +3 -3
- data/lib/puppet/type/state.rb +1 -2
- data/lib/puppet/type/symlink.rb +3 -4
- data/lib/puppet/type/user.rb +22 -10
- data/lib/puppet/type/yumrepo.rb +6 -1
- data/lib/puppet/type/zone.rb +595 -0
- data/lib/puppet/util.rb +58 -12
- data/test/client/client.rb +2 -2
- data/test/client/master.rb +92 -3
- data/test/client/pelement.rb +99 -0
- data/test/executables/puppetbin.rb +3 -4
- data/test/executables/puppetca.rb +3 -3
- data/test/executables/puppetd.rb +3 -3
- data/test/executables/puppetmasterd.rb +1 -5
- data/test/executables/puppetmodule.rb +2 -2
- data/test/language/ast.rb +200 -11
- data/test/language/functions.rb +245 -0
- data/test/language/interpreter.rb +155 -6
- data/test/language/lexer.rb +35 -2
- data/test/language/node.rb +48 -1
- data/test/language/parser.rb +250 -1
- data/test/language/rails.rb +105 -0
- data/test/language/scope.rb +304 -10
- data/test/language/snippets.rb +54 -5
- data/test/language/transportable.rb +60 -28
- data/test/other/config.rb +214 -1
- data/test/other/events.rb +67 -9
- data/test/other/log.rb +31 -5
- data/test/other/metrics.rb +23 -21
- data/test/other/parsedfile.rb +29 -2
- data/test/other/puppet.rb +79 -0
- data/test/other/report.rb +106 -0
- data/test/other/storage.rb +2 -2
- data/test/other/transactions.rb +128 -2
- data/test/puppet/utiltest.rb +10 -5
- data/test/puppettest.rb +193 -21
- data/test/server/authstore.rb +13 -4
- data/test/server/bucket.rb +33 -8
- data/test/server/ca.rb +44 -6
- data/test/server/master.rb +6 -7
- data/test/server/pelement.rb +15 -5
- data/test/server/report.rb +93 -0
- data/test/server/runner.rb +107 -0
- data/test/server/server.rb +28 -1
- data/test/types/cron.rb +339 -31
- data/test/types/file.rb +256 -24
- data/test/types/filebucket.rb +6 -2
- data/test/types/filesources.rb +41 -92
- data/test/types/group.rb +31 -1
- data/test/types/host.rb +2 -1
- data/test/types/mount.rb +18 -1
- data/test/types/package.rb +200 -18
- data/test/types/service.rb +5 -1
- data/test/types/sshkey.rb +2 -1
- data/test/types/symlink.rb +3 -2
- data/test/types/type.rb +180 -1
- data/test/types/user.rb +65 -27
- data/test/types/yumrepo.rb +15 -0
- data/test/types/zone.rb +437 -0
- metadata +43 -4
- data/bin/cf2puppet +0 -186
- data/conf/redhat/puppetmasterd.conf +0 -5
data/test/types/file.rb
CHANGED
@@ -489,36 +489,39 @@ class TestFile < Test::Unit::TestCase
|
|
489
489
|
FileUtils.mkdir_p(subdir)
|
490
490
|
|
491
491
|
dir = nil
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
assert_nothing_raised {
|
501
|
-
dir.evaluate
|
502
|
-
}
|
492
|
+
[true, "true", "inf", 50].each do |value|
|
493
|
+
assert_nothing_raised {
|
494
|
+
dir = Puppet.type(:file).create(
|
495
|
+
:path => basedir,
|
496
|
+
:recurse => value,
|
497
|
+
:check => %w{owner mode group}
|
498
|
+
)
|
499
|
+
}
|
503
500
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
}
|
501
|
+
assert_nothing_raised {
|
502
|
+
dir.evaluate
|
503
|
+
}
|
508
504
|
|
509
|
-
|
505
|
+
subobj = nil
|
506
|
+
assert_nothing_raised {
|
507
|
+
subobj = Puppet.type(:file)[subdir]
|
508
|
+
}
|
510
509
|
|
511
|
-
|
510
|
+
assert(subobj, "Could not retrieve %s object" % subdir)
|
512
511
|
|
513
|
-
|
512
|
+
File.open(tmpfile, "w") { |f| f.puts "yayness" }
|
514
513
|
|
515
|
-
|
516
|
-
assert_nothing_raised {
|
517
|
-
file = Puppet.type(:file)[tmpfile]
|
518
|
-
}
|
514
|
+
dir.evaluate
|
519
515
|
|
520
|
-
|
516
|
+
file = nil
|
517
|
+
assert_nothing_raised {
|
518
|
+
file = Puppet.type(:file)[tmpfile]
|
519
|
+
}
|
521
520
|
|
521
|
+
assert(file, "Could not retrieve %s object" % tmpfile)
|
522
|
+
#system("rm -rf %s" % basedir)
|
523
|
+
Puppet.type(:file).clear
|
524
|
+
end
|
522
525
|
end
|
523
526
|
|
524
527
|
=begin
|
@@ -1077,6 +1080,235 @@ class TestFile < Test::Unit::TestCase
|
|
1077
1080
|
assert(FileTest.symlink?(link), "Did not make link")
|
1078
1081
|
assert_equal(File.join(source, "file"), File.readlink(link))
|
1079
1082
|
end
|
1083
|
+
|
1084
|
+
def test_backupmodes
|
1085
|
+
file = tempfile()
|
1086
|
+
newfile = tempfile()
|
1087
|
+
|
1088
|
+
File.open(file, "w", 0411) { |f| f.puts "yayness" }
|
1089
|
+
|
1090
|
+
obj = nil
|
1091
|
+
assert_nothing_raised {
|
1092
|
+
obj = Puppet::Type.type(:file).create(
|
1093
|
+
:path => file, :content => "rahness\n"
|
1094
|
+
)
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
# user = group = nil
|
1098
|
+
# if Process.uid == 0
|
1099
|
+
# user = nonrootuser
|
1100
|
+
# group = nonrootgroup
|
1101
|
+
# obj[:owner] = user.name
|
1102
|
+
# obj[:group] = group.name
|
1103
|
+
# File.chown(user.uid, group.gid, file)
|
1104
|
+
# end
|
1105
|
+
|
1106
|
+
assert_apply(obj)
|
1107
|
+
|
1108
|
+
backupfile = file + obj[:backup]
|
1109
|
+
@@tmpfiles << backupfile
|
1110
|
+
assert(FileTest.exists?(backupfile),
|
1111
|
+
"Backup file %s does not exist" % backupfile)
|
1112
|
+
|
1113
|
+
assert_equal(0411, filemode(backupfile),
|
1114
|
+
"File mode is wrong for backupfile")
|
1115
|
+
|
1116
|
+
# if Process.uid == 0
|
1117
|
+
# assert_equal(user.uid, File.stat(backupfile).uid)
|
1118
|
+
# assert_equal(group.gid, File.stat(backupfile).gid)
|
1119
|
+
# end
|
1120
|
+
|
1121
|
+
bucket = "bucket"
|
1122
|
+
bpath = tempfile()
|
1123
|
+
Dir.mkdir(bpath)
|
1124
|
+
Puppet::Type.type(:filebucket).create(
|
1125
|
+
:name => bucket, :path => bpath
|
1126
|
+
)
|
1127
|
+
|
1128
|
+
obj[:backup] = bucket
|
1129
|
+
obj[:content] = "New content"
|
1130
|
+
assert_apply(obj)
|
1131
|
+
|
1132
|
+
bucketedpath = File.join(bpath, "18cc17fa3047fcc691fdf49c0a7f539a", "contents")
|
1133
|
+
|
1134
|
+
assert_equal(0440, filemode(bucketedpath))
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
def test_largefilechanges
|
1138
|
+
source = tempfile()
|
1139
|
+
dest = tempfile()
|
1140
|
+
|
1141
|
+
# Now make a large file
|
1142
|
+
File.open(source, "w") { |f|
|
1143
|
+
500.times { |i| f.puts "line %s" % i }
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
obj = Puppet::Type.type(:file).create(
|
1147
|
+
:name => dest, :source => source
|
1148
|
+
)
|
1149
|
+
|
1150
|
+
assert_events([:file_created], obj)
|
1151
|
+
|
1152
|
+
File.open(source, File::APPEND|File::WRONLY) { |f| f.puts "another line" }
|
1153
|
+
|
1154
|
+
assert_events([:file_changed], obj)
|
1155
|
+
|
1156
|
+
# Now modify the dest file
|
1157
|
+
File.open(dest, File::APPEND|File::WRONLY) { |f| f.puts "one more line" }
|
1158
|
+
|
1159
|
+
assert_events([:file_changed, :file_changed], obj)
|
1160
|
+
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
def test_replacefilewithlink
|
1164
|
+
path = tempfile()
|
1165
|
+
link = tempfile()
|
1166
|
+
|
1167
|
+
File.open(path, "w") { |f| f.puts "yay" }
|
1168
|
+
File.open(link, "w") { |f| f.puts "a file" }
|
1169
|
+
|
1170
|
+
file = nil
|
1171
|
+
assert_nothing_raised {
|
1172
|
+
file = Puppet.type(:file).create(
|
1173
|
+
:ensure => path,
|
1174
|
+
:path => link
|
1175
|
+
)
|
1176
|
+
}
|
1177
|
+
|
1178
|
+
assert_events([:link_created], file)
|
1179
|
+
|
1180
|
+
assert(FileTest.symlink?(link), "Link was not created")
|
1181
|
+
|
1182
|
+
assert_equal(path, File.readlink(link), "Link was created incorrectly")
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
def test_replacedirwithlink
|
1186
|
+
path = tempfile()
|
1187
|
+
link = tempfile()
|
1188
|
+
|
1189
|
+
File.open(path, "w") { |f| f.puts "yay" }
|
1190
|
+
Dir.mkdir(link)
|
1191
|
+
File.open(File.join(link, "yay"), "w") do |f| f.puts "boo" end
|
1192
|
+
|
1193
|
+
file = nil
|
1194
|
+
assert_nothing_raised {
|
1195
|
+
file = Puppet.type(:file).create(
|
1196
|
+
:ensure => path,
|
1197
|
+
:path => link
|
1198
|
+
)
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
assert_events([:link_created], file)
|
1202
|
+
|
1203
|
+
assert(FileTest.symlink?(link), "Link was not created")
|
1204
|
+
|
1205
|
+
assert_equal(path, File.readlink(link), "Link was created incorrectly")
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
def test_replace_links_with_files
|
1209
|
+
base = tempfile()
|
1210
|
+
|
1211
|
+
Dir.mkdir(base)
|
1212
|
+
|
1213
|
+
file = File.join(base, "file")
|
1214
|
+
link = File.join(base, "link")
|
1215
|
+
File.open(file, "w") { |f| f.puts "yayness" }
|
1216
|
+
File.symlink(file, link)
|
1217
|
+
|
1218
|
+
obj = Puppet::Type.type(:file).create(
|
1219
|
+
:path => link,
|
1220
|
+
:ensure => "file"
|
1221
|
+
)
|
1222
|
+
|
1223
|
+
assert_apply(obj)
|
1224
|
+
|
1225
|
+
assert_equal("yayness\n", File.read(file),
|
1226
|
+
"Original file got changed")
|
1227
|
+
assert_equal("file", File.lstat(link).ftype, "File is still a link")
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
def test_no_erase_linkedto_files
|
1231
|
+
base = tempfile()
|
1232
|
+
|
1233
|
+
Dir.mkdir(base)
|
1234
|
+
|
1235
|
+
dirs = {}
|
1236
|
+
%w{other source target}.each do |d|
|
1237
|
+
dirs[d] = File.join(base, d)
|
1238
|
+
Dir.mkdir(dirs[d])
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
file = File.join(dirs["other"], "file")
|
1242
|
+
sourcefile = File.join(dirs["source"], "sourcefile")
|
1243
|
+
link = File.join(dirs["target"], "link")
|
1244
|
+
|
1245
|
+
File.open(file, "w") { |f| f.puts "other" }
|
1246
|
+
File.open(sourcefile, "w") { |f| f.puts "source" }
|
1247
|
+
File.symlink(file, link)
|
1248
|
+
|
1249
|
+
obj = Puppet::Type.type(:file).create(
|
1250
|
+
:path => dirs["target"],
|
1251
|
+
:ensure => "file",
|
1252
|
+
:source => dirs["source"],
|
1253
|
+
:recurse => true
|
1254
|
+
)
|
1255
|
+
|
1256
|
+
|
1257
|
+
trans = assert_events([:file_created, :file_created], obj)
|
1258
|
+
|
1259
|
+
newfile = File.join(dirs["target"], "sourcefile")
|
1260
|
+
|
1261
|
+
assert(File.exists?(newfile), "File did not get copied")
|
1262
|
+
|
1263
|
+
assert_equal(File.read(sourcefile), File.read(newfile),
|
1264
|
+
"File did not get copied correctly.")
|
1265
|
+
|
1266
|
+
assert_equal("other\n", File.read(file),
|
1267
|
+
"Original file got changed")
|
1268
|
+
assert_equal("file", File.lstat(link).ftype, "File is still a link")
|
1269
|
+
end
|
1270
|
+
|
1271
|
+
def test_replace_links
|
1272
|
+
dest = tempfile()
|
1273
|
+
otherdest = tempfile()
|
1274
|
+
link = tempfile()
|
1275
|
+
|
1276
|
+
File.open(dest, "w") { |f| f.puts "boo" }
|
1277
|
+
File.open(otherdest, "w") { |f| f.puts "yay" }
|
1278
|
+
|
1279
|
+
obj = Puppet::Type.type(:file).create(
|
1280
|
+
:path => link,
|
1281
|
+
:ensure => otherdest
|
1282
|
+
)
|
1283
|
+
|
1284
|
+
|
1285
|
+
assert_apply(obj)
|
1286
|
+
|
1287
|
+
assert_equal(otherdest, File.readlink(link), "Link did not get created")
|
1288
|
+
|
1289
|
+
obj[:ensure] = dest
|
1290
|
+
|
1291
|
+
assert_apply(obj)
|
1292
|
+
|
1293
|
+
assert_equal(dest, File.readlink(link), "Link did not get changed")
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
def test_file_with_spaces
|
1297
|
+
dir = tempfile()
|
1298
|
+
Dir.mkdir(dir)
|
1299
|
+
source = File.join(dir, "file spaces")
|
1300
|
+
dest = File.join(dir, "another space")
|
1301
|
+
|
1302
|
+
File.open(source, "w") { |f| f.puts :yay }
|
1303
|
+
obj = Puppet::Type.type(:file).create(
|
1304
|
+
:path => dest,
|
1305
|
+
:source => source
|
1306
|
+
)
|
1307
|
+
|
1308
|
+
assert_apply(obj)
|
1309
|
+
|
1310
|
+
assert(FileTest.exists?(dest), "File did not get created")
|
1311
|
+
end
|
1080
1312
|
end
|
1081
1313
|
|
1082
|
-
# $Id: file.rb
|
1314
|
+
# $Id: file.rb 1307 2006-06-20 18:46:58Z luke $
|
data/test/types/filebucket.rb
CHANGED
@@ -9,7 +9,7 @@ require 'test/unit'
|
|
9
9
|
require 'fileutils'
|
10
10
|
require 'puppettest'
|
11
11
|
|
12
|
-
# $Id: filebucket.rb
|
12
|
+
# $Id: filebucket.rb 1143 2006-04-27 16:59:10Z luke $
|
13
13
|
|
14
14
|
class TestFileBucket < Test::Unit::TestCase
|
15
15
|
include FileTesting
|
@@ -68,7 +68,8 @@ class TestFileBucket < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
def test_simplebucket
|
70
70
|
name = "yayness"
|
71
|
-
|
71
|
+
bucketpath = tempfile()
|
72
|
+
mkbucket(name, bucketpath)
|
72
73
|
|
73
74
|
bucket = nil
|
74
75
|
assert_nothing_raised {
|
@@ -87,6 +88,9 @@ class TestFileBucket < Test::Unit::TestCase
|
|
87
88
|
|
88
89
|
assert(md5)
|
89
90
|
|
91
|
+
assert(FileTest.directory?(File.join(bucketpath, md5)),
|
92
|
+
"MD5 directory does not exist")
|
93
|
+
|
90
94
|
newmd5 = nil
|
91
95
|
|
92
96
|
# Just in case the file isn't writable
|
data/test/types/filesources.rb
CHANGED
@@ -85,7 +85,7 @@ class TestFileSources < Test::Unit::TestCase
|
|
85
85
|
|
86
86
|
assert_apply(tofile)
|
87
87
|
|
88
|
-
assert(FileTest.exists?(topath))
|
88
|
+
assert(FileTest.exists?(topath), "File #{topath} is missing")
|
89
89
|
from = File.open(frompath) { |o| o.read }
|
90
90
|
to = File.open(topath) { |o| o.read }
|
91
91
|
assert_equal(from,to)
|
@@ -195,7 +195,7 @@ class TestFileSources < Test::Unit::TestCase
|
|
195
195
|
fromtree = file_list(fromdir)
|
196
196
|
totree = file_list(todir)
|
197
197
|
|
198
|
-
assert(fromtree != totree)
|
198
|
+
assert(fromtree != totree, "Trees are incorrectly equal")
|
199
199
|
|
200
200
|
# then remove our new files
|
201
201
|
FileUtils.cd(todir) {
|
@@ -263,91 +263,6 @@ class TestFileSources < Test::Unit::TestCase
|
|
263
263
|
return file
|
264
264
|
end
|
265
265
|
|
266
|
-
# test raw xmlrpc calls
|
267
|
-
# this test is disabled because it requires way too much setup to get
|
268
|
-
# the certificates correct
|
269
|
-
def disabled_test_SimpleNetworkSources
|
270
|
-
server = nil
|
271
|
-
basedir = tempfile()
|
272
|
-
@@tmpfiles << basedir
|
273
|
-
|
274
|
-
mounts = {
|
275
|
-
"/" => "root"
|
276
|
-
}
|
277
|
-
|
278
|
-
fileserverconf = mkfileserverconf(mounts)
|
279
|
-
|
280
|
-
if File.exists?(basedir)
|
281
|
-
system("rm -rf %s" % basedir)
|
282
|
-
end
|
283
|
-
Dir.mkdir(basedir)
|
284
|
-
|
285
|
-
Puppet[:confdir] = basedir
|
286
|
-
Puppet[:vardir] = basedir
|
287
|
-
Puppet[:autosign] = true
|
288
|
-
|
289
|
-
tmpname = "yaytesting"
|
290
|
-
tmpfile = File.join(basedir, tmpname)
|
291
|
-
File.open(tmpfile, "w") { |f| f.print rand(100) }
|
292
|
-
|
293
|
-
port = 8765
|
294
|
-
serverpid = nil
|
295
|
-
assert_nothing_raised() {
|
296
|
-
server = Puppet::Server.new(
|
297
|
-
:Port => port,
|
298
|
-
:Handlers => {
|
299
|
-
:CA => {}, # so that certs autogenerate
|
300
|
-
:FileServer => {
|
301
|
-
:Config => fileserverconf
|
302
|
-
}
|
303
|
-
}
|
304
|
-
)
|
305
|
-
|
306
|
-
}
|
307
|
-
serverpid = fork {
|
308
|
-
assert_nothing_raised() {
|
309
|
-
#trap(:INT) { server.shutdown; Kernel.exit! }
|
310
|
-
trap(:INT) { server.shutdown }
|
311
|
-
server.start
|
312
|
-
}
|
313
|
-
}
|
314
|
-
@@tmppids << serverpid
|
315
|
-
|
316
|
-
client = nil
|
317
|
-
assert_nothing_raised() {
|
318
|
-
client = XMLRPC::Client.new("localhost", "/RPC2", port, nil, nil,
|
319
|
-
nil, nil, true, 3)
|
320
|
-
}
|
321
|
-
retval = nil
|
322
|
-
|
323
|
-
sleep(1)
|
324
|
-
|
325
|
-
list = nil
|
326
|
-
rpath = "/root%s" % tmpfile
|
327
|
-
assert_nothing_raised {
|
328
|
-
list = client.call("fileserver.list", rpath, :skip, false, false)
|
329
|
-
}
|
330
|
-
|
331
|
-
assert_equal("/\tfile", list)
|
332
|
-
|
333
|
-
assert_nothing_raised {
|
334
|
-
list = client.call("fileserver.describe", rpath, :skip)
|
335
|
-
}
|
336
|
-
|
337
|
-
assert_match(/^\d+\tfile\t\d+\t\d+\t.+$/, list)
|
338
|
-
|
339
|
-
assert_nothing_raised {
|
340
|
-
list = client.call("fileserver.retrieve", rpath, :skip)
|
341
|
-
}
|
342
|
-
|
343
|
-
contents = File.read(tmpfile)
|
344
|
-
assert_equal(contents, CGI.unescape(list))
|
345
|
-
|
346
|
-
assert_nothing_raised {
|
347
|
-
system("kill -INT %s" % serverpid)
|
348
|
-
}
|
349
|
-
end
|
350
|
-
|
351
266
|
def test_NetworkSources
|
352
267
|
server = nil
|
353
268
|
basedir = tempfile()
|
@@ -626,16 +541,50 @@ class TestFileSources < Test::Unit::TestCase
|
|
626
541
|
assert(FileTest.file?(dest), "Destination is not a file")
|
627
542
|
|
628
543
|
# Now copy the links
|
629
|
-
assert_raise(Puppet::FileServerError) {
|
544
|
+
#assert_raise(Puppet::FileServerError) {
|
545
|
+
trans = nil
|
546
|
+
assert_nothing_raised {
|
630
547
|
file[:links] = :manage
|
631
548
|
comp = newcomp(file)
|
632
549
|
trans = comp.evaluate
|
633
550
|
trans.evaluate
|
634
551
|
}
|
635
|
-
|
636
|
-
|
637
|
-
|
552
|
+
|
553
|
+
assert(trans.failed?(file), "Object did not fail to copy links")
|
554
|
+
end
|
555
|
+
|
556
|
+
def test_changes
|
557
|
+
source = tempfile()
|
558
|
+
dest = tempfile()
|
559
|
+
|
560
|
+
File.open(source, "w") { |f| f.puts "yay" }
|
561
|
+
|
562
|
+
obj = nil
|
563
|
+
assert_nothing_raised {
|
564
|
+
obj = Puppet.type(:file).create(
|
565
|
+
:name => dest,
|
566
|
+
:source => source
|
567
|
+
)
|
568
|
+
}
|
569
|
+
|
570
|
+
assert_events([:file_created], obj)
|
571
|
+
assert_equal(File.read(source), File.read(dest), "Files are not equal")
|
572
|
+
assert_events([], obj)
|
573
|
+
|
574
|
+
File.open(source, "w") { |f| f.puts "boo" }
|
575
|
+
|
576
|
+
assert_events([:file_changed], obj)
|
577
|
+
assert_equal(File.read(source), File.read(dest), "Files are not equal")
|
578
|
+
assert_events([], obj)
|
579
|
+
|
580
|
+
File.open(dest, "w") { |f| f.puts "kaboom" }
|
581
|
+
|
582
|
+
# There are two changes, because first the checksum is noticed, and
|
583
|
+
# then the source causes a change
|
584
|
+
assert_events([:file_changed, :file_changed], obj)
|
585
|
+
assert_equal(File.read(source), File.read(dest), "Files are not equal")
|
586
|
+
assert_events([], obj)
|
638
587
|
end
|
639
588
|
end
|
640
589
|
|
641
|
-
# $Id: filesources.rb
|
590
|
+
# $Id: filesources.rb 1330 2006-06-28 19:47:36Z luke $
|