puppet 0.24.4 → 0.24.5

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.

Files changed (316) hide show
  1. data/CHANGELOG +170 -0
  2. data/Rakefile +6 -4
  3. data/bin/filebucket +3 -2
  4. data/bin/puppet +7 -4
  5. data/bin/puppetca +32 -14
  6. data/bin/puppetd +12 -34
  7. data/bin/puppetmasterd +3 -2
  8. data/bin/puppetrun +5 -43
  9. data/bin/ralsh +2 -2
  10. data/conf/debian/README.source +2 -0
  11. data/conf/debian/TODO.Debian +1 -0
  12. data/conf/debian/changelog +257 -0
  13. data/conf/debian/compat +1 -0
  14. data/conf/debian/control +45 -0
  15. data/conf/debian/copyright +17 -0
  16. data/conf/debian/docs +1 -0
  17. data/conf/debian/fileserver.conf +12 -0
  18. data/conf/debian/puppet.NEWS +63 -0
  19. data/conf/debian/puppet.conf +8 -0
  20. data/conf/debian/puppet.dirs +7 -0
  21. data/conf/debian/puppet.files +6 -0
  22. data/conf/debian/puppet.init +64 -0
  23. data/conf/debian/puppet.logrotate +11 -0
  24. data/conf/debian/puppet.postinst +9 -0
  25. data/conf/debian/puppet.postrm +21 -0
  26. data/conf/debian/puppet.preinst +25 -0
  27. data/conf/debian/puppetmaster.files +4 -0
  28. data/conf/debian/puppetmaster.init +58 -0
  29. data/conf/debian/rules +115 -0
  30. data/conf/debian/watch +2 -0
  31. data/conf/gentoo/init.d/puppet +1 -1
  32. data/conf/gentoo/init.d/puppetmaster +32 -31
  33. data/conf/redhat/client.init +10 -2
  34. data/conf/redhat/puppet.spec +4 -1
  35. data/conf/redhat/server.init +9 -1
  36. data/examples/{code/allatonce → allatonce} +0 -0
  37. data/examples/{code/assignments → assignments} +0 -0
  38. data/examples/{code/components → components} +0 -0
  39. data/examples/{root/etc → etc}/init.d/sleeper +0 -0
  40. data/examples/{root/etc → etc}/otherfile +0 -0
  41. data/examples/{root/etc → etc}/puppet/fileserver.conf +0 -0
  42. data/examples/{root/etc → etc}/puppet/namespaceauth.conf +0 -0
  43. data/examples/{root/etc → etc}/puppet/puppet.conf +0 -0
  44. data/examples/{root/etc → etc}/puppet/tagmail.conf +0 -0
  45. data/examples/{code/execs → execs} +0 -0
  46. data/examples/{code/file.bl → file.bl} +0 -0
  47. data/examples/{code/filedefaults → filedefaults} +0 -0
  48. data/examples/{code/fileparsing → fileparsing} +0 -0
  49. data/examples/{code/filerecursion → filerecursion} +0 -0
  50. data/examples/{code/functions → functions} +0 -0
  51. data/examples/{code/groups → groups} +0 -0
  52. data/examples/{code/head → head} +0 -0
  53. data/examples/{code/importing → importing} +0 -0
  54. data/examples/{code/mac_automount.pp → mac_automount.pp} +0 -0
  55. data/examples/{code/mac_dscl.pp → mac_dscl.pp} +0 -0
  56. data/examples/{code/mac_dscl_revert.pp → mac_dscl_revert.pp} +0 -0
  57. data/examples/{code/mac_netinfo.pp → mac_netinfo.pp} +0 -0
  58. data/examples/{code/mac_pkgdmg.pp → mac_pkgdmg.pp} +0 -0
  59. data/examples/{code/modules → modules}/sample-module.pp +0 -0
  60. data/examples/{code/modules → modules}/sample-module/README.txt +0 -0
  61. data/examples/{code/modules → modules}/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -0
  62. data/examples/{code/modules → modules}/sample-module/manifests/init.pp +0 -0
  63. data/examples/{code/modules → modules}/sample-module/templates/sample.erb +0 -0
  64. data/examples/{code/nodes → nodes} +0 -0
  65. data/examples/{code/one → one} +0 -0
  66. data/examples/{code/relationships → relationships} +0 -0
  67. data/examples/{code/selectors → selectors} +0 -0
  68. data/examples/{code/simpletests → simpletests} +0 -0
  69. data/examples/{code/svncommit → svncommit} +0 -0
  70. data/ext/autotest/Rakefile +8 -0
  71. data/ext/autotest/config +43 -0
  72. data/ext/autotest/readme.rst +16 -0
  73. data/{examples/root → ext}/bin/sleeper +1 -1
  74. data/ext/emacs/puppet-mode.el +246 -184
  75. data/ext/ldap/puppet.schema +7 -2
  76. data/ext/module_puppet +4 -3
  77. data/ext/nagios/check_puppet.rb +117 -0
  78. data/ext/puppetlast +40 -0
  79. data/install.rb +12 -3
  80. data/lib/puppet.rb +1 -44
  81. data/lib/puppet/defaults.rb +23 -10
  82. data/lib/puppet/dsl.rb +2 -2
  83. data/lib/puppet/executables/client/certhandler.rb +77 -0
  84. data/lib/puppet/external/nagios.rb +1 -1
  85. data/lib/puppet/external/nagios/base.rb +60 -46
  86. data/lib/puppet/file_serving/indirection_hooks.rb +4 -2
  87. data/lib/puppet/file_serving/metadata.rb +0 -9
  88. data/lib/puppet/file_serving/terminus_helper.rb +4 -4
  89. data/lib/puppet/indirector.rb +26 -28
  90. data/lib/puppet/indirector/catalog/compiler.rb +6 -28
  91. data/lib/puppet/indirector/checksum/file.rb +2 -2
  92. data/lib/puppet/indirector/direct_file_server.rb +7 -7
  93. data/lib/puppet/indirector/envelope.rb +13 -0
  94. data/lib/puppet/indirector/exec.rb +2 -2
  95. data/lib/puppet/indirector/facts/facter.rb +2 -2
  96. data/lib/puppet/indirector/file.rb +17 -14
  97. data/lib/puppet/indirector/file_metadata/file.rb +2 -2
  98. data/lib/puppet/indirector/file_server.rb +14 -14
  99. data/lib/puppet/indirector/indirection.rb +113 -48
  100. data/lib/puppet/indirector/ldap.rb +13 -25
  101. data/lib/puppet/indirector/memory.rb +7 -7
  102. data/lib/puppet/indirector/module_files.rb +14 -14
  103. data/lib/puppet/indirector/node/exec.rb +3 -10
  104. data/lib/puppet/indirector/node/ldap.rb +138 -41
  105. data/lib/puppet/indirector/node/plain.rb +1 -8
  106. data/lib/puppet/indirector/node/rest.rb +1 -1
  107. data/lib/puppet/indirector/plain.rb +2 -2
  108. data/lib/puppet/indirector/report/processor.rb +2 -2
  109. data/lib/puppet/indirector/request.rb +42 -0
  110. data/lib/puppet/indirector/rest.rb +51 -3
  111. data/lib/puppet/indirector/terminus.rb +0 -27
  112. data/lib/puppet/indirector/yaml.rb +12 -17
  113. data/lib/puppet/metatype/attributes.rb +3 -7
  114. data/lib/puppet/metatype/evaluation.rb +2 -2
  115. data/lib/puppet/module.rb +6 -2
  116. data/lib/puppet/network/client/master.rb +29 -81
  117. data/lib/puppet/network/handler/master.rb +12 -43
  118. data/lib/puppet/network/http.rb +8 -6
  119. data/lib/puppet/network/http/handler.rb +42 -32
  120. data/lib/puppet/network/http/mongrel.rb +8 -9
  121. data/lib/puppet/network/http/mongrel/rest.rb +42 -15
  122. data/lib/puppet/network/http/webrick.rb +27 -16
  123. data/lib/puppet/network/http/webrick/rest.rb +38 -14
  124. data/lib/puppet/network/http_pool.rb +3 -2
  125. data/lib/puppet/network/server.rb +24 -22
  126. data/lib/puppet/network/xmlrpc/client.rb +6 -1
  127. data/lib/puppet/node.rb +38 -79
  128. data/lib/puppet/node/catalog.rb +9 -0
  129. data/lib/puppet/node/facts.rb +9 -1
  130. data/lib/puppet/parser/ast/function.rb +1 -1
  131. data/lib/puppet/parser/collector.rb +6 -0
  132. data/lib/puppet/parser/compiler.rb +1 -1
  133. data/lib/puppet/parser/functions.rb +25 -1
  134. data/lib/puppet/parser/interpreter.rb +2 -17
  135. data/lib/puppet/parser/parser.rb +4 -4
  136. data/lib/puppet/parser/parser_support.rb +6 -2
  137. data/lib/puppet/parser/resource.rb +6 -0
  138. data/lib/puppet/parser/templatewrapper.rb +9 -0
  139. data/lib/puppet/pgraph.rb +1 -1
  140. data/lib/puppet/property.rb +0 -1
  141. data/lib/puppet/provider.rb +9 -95
  142. data/lib/puppet/provider/confine.rb +77 -0
  143. data/lib/puppet/provider/confine/exists.rb +22 -0
  144. data/lib/puppet/provider/confine/false.rb +19 -0
  145. data/lib/puppet/provider/confine/feature.rb +17 -0
  146. data/lib/puppet/provider/confine/true.rb +20 -0
  147. data/lib/puppet/provider/confine/variable.rb +42 -0
  148. data/lib/puppet/provider/confine_collection.rb +47 -0
  149. data/lib/puppet/provider/confiner.rb +20 -0
  150. data/lib/puppet/provider/cron/crontab.rb +6 -2
  151. data/lib/puppet/provider/group/groupadd.rb +1 -1
  152. data/lib/puppet/provider/group/ldap.rb +48 -0
  153. data/lib/puppet/provider/ldap.rb +137 -0
  154. data/lib/puppet/provider/nameservice.rb +1 -2
  155. data/lib/puppet/provider/nameservice/objectadd.rb +2 -5
  156. data/lib/puppet/provider/package/dpkg.rb +16 -1
  157. data/lib/puppet/provider/package/freebsd.rb +15 -4
  158. data/lib/puppet/provider/package/gem.rb +33 -12
  159. data/lib/puppet/provider/package/pkgdmg.rb +1 -60
  160. data/lib/puppet/provider/package/ports.rb +6 -1
  161. data/lib/puppet/provider/package/rpm.rb +14 -13
  162. data/lib/puppet/provider/package/urpmi.rb +3 -3
  163. data/lib/puppet/provider/service/base.rb +4 -4
  164. data/lib/puppet/provider/service/debian.rb +1 -1
  165. data/lib/puppet/provider/service/init.rb +5 -3
  166. data/lib/puppet/provider/service/redhat.rb +35 -7
  167. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +69 -0
  168. data/lib/puppet/provider/user/ldap.rb +133 -0
  169. data/lib/puppet/provider/user/useradd.rb +1 -1
  170. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +14 -14
  171. data/lib/puppet/rails/database/schema.rb +9 -0
  172. data/lib/puppet/rails/resource.rb +1 -0
  173. data/lib/puppet/reference/providers.rb +8 -2
  174. data/lib/puppet/reference/report.rb +23 -0
  175. data/lib/puppet/reports/rrdgraph.rb +4 -2
  176. data/lib/puppet/sslcertificates/ca.rb +9 -4
  177. data/lib/puppet/sslcertificates/support.rb +26 -2
  178. data/lib/puppet/transaction.rb +11 -16
  179. data/lib/puppet/transaction/change.rb +94 -0
  180. data/lib/puppet/transaction/event.rb +21 -0
  181. data/lib/puppet/transaction/report.rb +4 -0
  182. data/lib/puppet/type.rb +0 -2
  183. data/lib/puppet/type/file/ensure.rb +0 -5
  184. data/lib/puppet/type/file/group.rb +13 -7
  185. data/lib/puppet/type/file/source.rb +8 -15
  186. data/lib/puppet/type/file/target.rb +2 -0
  187. data/lib/puppet/type/group.rb +1 -1
  188. data/lib/puppet/type/mount.rb +4 -2
  189. data/lib/puppet/type/nagios_hostescalation.rb +3 -0
  190. data/lib/puppet/type/nagios_servicegroup.rb +3 -0
  191. data/lib/puppet/type/ssh_authorized_key.rb +56 -0
  192. data/lib/puppet/type/user.rb +3 -0
  193. data/lib/puppet/type/yumrepo.rb +0 -1
  194. data/lib/puppet/util.rb +1 -1
  195. data/lib/puppet/util/ldap.rb +5 -0
  196. data/lib/puppet/util/ldap/connection.rb +69 -0
  197. data/lib/puppet/util/ldap/generator.rb +45 -0
  198. data/lib/puppet/util/ldap/manager.rb +281 -0
  199. data/lib/puppet/util/posix.rb +2 -2
  200. data/lib/puppet/util/resource_template.rb +61 -0
  201. data/lib/puppet/util/settings.rb +63 -3
  202. data/lib/puppet/util/storage.rb +4 -0
  203. data/lib/puppet/util/warnings.rb +7 -0
  204. data/man/man8/filebucket.8 +116 -0
  205. data/man/man8/pi.8 +34 -0
  206. data/man/man8/puppet.8 +78 -0
  207. data/man/man8/puppet.conf.8 +1747 -0
  208. data/man/man8/puppetca.8 +118 -0
  209. data/man/man8/puppetd.8 +184 -0
  210. data/man/man8/puppetdoc.8 +62 -0
  211. data/man/man8/puppetmasterd.8 +87 -0
  212. data/man/man8/puppetrun.8 +151 -0
  213. data/man/man8/ralsh.8 +135 -0
  214. data/test/README +24 -0
  215. data/test/certmgr/support.rb +28 -1
  216. data/test/data/failers/badclassnoparam +10 -0
  217. data/test/data/failers/badclassparam +10 -0
  218. data/test/data/failers/badcompnoparam +9 -0
  219. data/test/data/failers/badcompparam +9 -0
  220. data/test/data/failers/badtypeparam +3 -0
  221. data/test/data/failers/noobjectrvalue +1 -0
  222. data/test/data/providers/cron/crontab.allthree +17 -0
  223. data/test/data/providers/cron/crontab.envNcomment +12 -0
  224. data/test/data/providers/cron/crontab.envNname +11 -0
  225. data/test/data/providers/cron/crontab.multirecords +12 -0
  226. data/test/data/providers/cron/crontab_collections.yaml +44 -0
  227. data/test/data/providers/cron/crontab_multiple_with_env.yaml +54 -0
  228. data/test/data/providers/cron/crontab_sample_records.yaml +272 -0
  229. data/test/data/providers/cron/examples/freebsd +2 -0
  230. data/test/data/providers/cron/examples/one +14 -0
  231. data/test/data/providers/cron/examples/openbsd +20 -0
  232. data/test/data/providers/package/testpackages.yaml +65 -0
  233. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +5 -0
  234. data/test/data/reports/1.yaml +108 -0
  235. data/test/data/reports/2.yaml +108 -0
  236. data/test/data/reports/tagmail_failers.conf +3 -0
  237. data/test/data/reports/tagmail_passers.conf +30 -0
  238. data/test/data/snippets/aliastest.pp +16 -0
  239. data/test/data/snippets/argumentdefaults +14 -0
  240. data/test/data/snippets/casestatement.pp +58 -0
  241. data/test/data/snippets/classheirarchy.pp +15 -0
  242. data/test/data/snippets/classincludes.pp +17 -0
  243. data/test/data/snippets/classpathtest +11 -0
  244. data/test/data/snippets/collection.pp +10 -0
  245. data/test/data/snippets/collection_within_virtual_definitions.pp +20 -0
  246. data/test/data/snippets/componentmetaparams.pp +11 -0
  247. data/test/data/snippets/componentrequire.pp +8 -0
  248. data/test/data/snippets/deepclassheirarchy.pp +23 -0
  249. data/test/data/snippets/defineoverrides.pp +17 -0
  250. data/test/data/snippets/emptyclass.pp +9 -0
  251. data/test/data/snippets/emptyexec.pp +3 -0
  252. data/test/data/snippets/falsevalues.pp +3 -0
  253. data/test/data/snippets/filecreate +11 -0
  254. data/test/data/snippets/fqdefinition.pp +5 -0
  255. data/test/data/snippets/fqparents.pp +11 -0
  256. data/test/data/snippets/implicititeration +15 -0
  257. data/test/data/snippets/multipleinstances +7 -0
  258. data/test/data/snippets/multisubs.pp +13 -0
  259. data/test/data/snippets/namevartest +9 -0
  260. data/test/data/snippets/scopetest +13 -0
  261. data/test/data/snippets/selectorvalues.pp +42 -0
  262. data/test/data/snippets/simpledefaults +5 -0
  263. data/test/data/snippets/simpleselector +38 -0
  264. data/test/data/snippets/singleary.pp +19 -0
  265. data/test/data/snippets/singlequote.pp +11 -0
  266. data/test/data/snippets/singleselector.pp +22 -0
  267. data/test/data/snippets/subclass_name_duplication.pp +11 -0
  268. data/test/data/snippets/tag.pp +9 -0
  269. data/test/data/snippets/tagged.pp +35 -0
  270. data/test/data/snippets/virtualresources.pp +14 -0
  271. data/test/data/types/hosts/1 +3 -0
  272. data/test/data/types/hosts/2 +13 -0
  273. data/test/data/types/hosts/solaris +5 -0
  274. data/test/data/types/mailalias/file1 +183 -0
  275. data/test/data/types/mount/freebsd.fstab +7 -0
  276. data/test/data/types/mount/linux.fstab +11 -0
  277. data/test/data/types/mount/solaris.fstab +11 -0
  278. data/test/data/types/port/1 +533 -0
  279. data/test/data/types/port/darwin +11866 -0
  280. data/test/data/types/ssh_authorized_key/1 +2 -0
  281. data/test/data/types/sshkey/1 +21 -0
  282. data/test/data/types/yumrepos/fedora-devel.repo +26 -0
  283. data/test/data/types/yumrepos/fedora.repo +9 -0
  284. data/test/language/parser.rb +8 -1
  285. data/test/lib/puppettest/runnable_test.rb +3 -0
  286. data/test/lib/puppettest/support/utils.rb +1 -1
  287. data/test/lib/rake/puppet_testtask.rb +3 -0
  288. data/test/lib/stubba.rb +1 -1
  289. data/test/network/client/ca.rb +1 -0
  290. data/test/network/client/master.rb +13 -127
  291. data/test/network/handler/master.rb +61 -80
  292. data/test/other/provider.rb +0 -45
  293. data/test/other/transactions.rb +53 -15
  294. data/test/rails/host.rb +0 -37
  295. data/test/ral/providers/cron/crontab.rb +32 -3
  296. data/test/ral/providers/provider.rb +28 -7
  297. data/test/ral/type/filesources.rb +2 -18
  298. data/test/ral/type/sshkey.rb +0 -1
  299. data/test/ral/type/user.rb +6 -0
  300. data/test/test +241 -0
  301. metadata +289 -113
  302. data/examples/root/etc/configfile +0 -0
  303. data/examples/root/etc/debian-passwd +0 -29
  304. data/examples/root/etc/debian-syslog.conf +0 -71
  305. data/lib/puppet/event.rb +0 -28
  306. data/lib/puppet/network/handler/configuration.rb +0 -184
  307. data/lib/puppet/network/http/mongrel/xmlrpc.rb +0 -4
  308. data/lib/puppet/network/http/webrick/xmlrpc.rb +0 -4
  309. data/lib/puppet/propertychange.rb +0 -141
  310. data/lib/puppet/provider/interface/redhat.rb +0 -250
  311. data/lib/puppet/provider/interface/sunos.rb +0 -133
  312. data/lib/puppet/type/interface.rb +0 -60
  313. data/lib/puppet/util/variables.rb +0 -38
  314. data/test/network/handler/configuration.rb +0 -160
  315. data/test/other/propertychange.rb +0 -140
  316. data/test/util/loadedfile.rb +0 -121
@@ -48,51 +48,6 @@ class TestImpl < Test::Unit::TestCase
48
48
 
49
49
  end
50
50
 
51
- def test_provider_false_confine
52
- assert_nothing_raised do
53
- @provider.confine :false => false
54
- end
55
-
56
- assert(@provider.suitable?, "False did not check correctly")
57
- end
58
-
59
- def test_provider_true_confine
60
- assert_nothing_raised do
61
- @provider.confine :true => true
62
- end
63
-
64
- assert(@provider.suitable?, "True did not check correctly")
65
-
66
- # Now check whether we multiple true things work
67
- assert_nothing_raised do
68
- @provider.confine :true => false
69
- @provider.confine :true => true
70
- end
71
- assert(! @provider.suitable?, "One truth overrode another")
72
- end
73
-
74
- def test_provider_exists_confine
75
- file = tempfile()
76
-
77
- assert_nothing_raised do
78
- @provider.confine :exists => file
79
- end
80
-
81
- assert(! @provider.suitable?, "Exists did not check correctly")
82
- File.open(file, "w") { |f| f.puts "" }
83
- assert(@provider.suitable?, "Exists did not find file correctly")
84
- end
85
-
86
- def test_provider_facts_confine
87
- # Now check for multiple platforms
88
- assert_nothing_raised do
89
- @provider.confine :operatingsystem => [Facter["operatingsystem"].value, :yayos]
90
- @provider.confine :operatingsystem => [:fakeos, :otheros]
91
- end
92
-
93
- assert(@provider.suitable?, "Implementation not considered suitable")
94
- end
95
-
96
51
  def test_provider_default
97
52
  nondef = nil
98
53
  assert_nothing_raised {
@@ -72,11 +72,11 @@ class TestTransactions < Test::Unit::TestCase
72
72
  path1 = tempfile()
73
73
  path2 = tempfile()
74
74
  objects = []
75
- objects << Puppet::Type.newfile(
75
+ objects << Puppet::Type.type(:file).create(
76
76
  :path => path1,
77
77
  :content => "yayness"
78
78
  )
79
- objects << Puppet::Type.newfile(
79
+ objects << Puppet::Type.type(:file).create(
80
80
  :path => path2,
81
81
  :content => "booness"
82
82
  )
@@ -155,7 +155,7 @@ class TestTransactions < Test::Unit::TestCase
155
155
  path = tempfile()
156
156
  firstpath = tempfile()
157
157
  secondpath = tempfile()
158
- file = Puppet::Type.newfile(:title => "file", :path => path, :content => "yayness")
158
+ file = Puppet::Type.type(:file).create(:title => "file", :path => path, :content => "yayness")
159
159
  first = Puppet::Type.newexec(:title => "first",
160
160
  :command => "/bin/echo first > #{firstpath}",
161
161
  :subscribe => [:file, path],
@@ -716,6 +716,45 @@ class TestTransactions < Test::Unit::TestCase
716
716
  "Not all resources were evaluated or not in the right order")
717
717
  end
718
718
 
719
+ # We need to generate resources before we prefetch them, else generated
720
+ # resources that require prefetching don't work.
721
+ def test_generate_before_prefetch
722
+ config = mk_catalog()
723
+ trans = Puppet::Transaction.new(config)
724
+
725
+ generate = nil
726
+ prefetch = nil
727
+ trans.expects(:generate).with { |*args| generate = Time.now; true }
728
+ trans.expects(:prefetch).with { |*args| ! generate.nil? }
729
+ trans.prepare
730
+ return
731
+
732
+ resource = Puppet::Type.type(:file).create :ensure => :present, :path => tempfile()
733
+ other_resource = mock 'generated'
734
+ def resource.generate
735
+ [other_resource]
736
+ end
737
+
738
+
739
+ config = mk_catalog(yay, rah)
740
+ trans = Puppet::Transaction.new(config)
741
+
742
+ assert_nothing_raised do
743
+ trans.generate
744
+ end
745
+
746
+ %w{ya ra y r}.each do |name|
747
+ assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
748
+ "Generated %s was not a vertex" % name)
749
+ assert($finished.include?(name), "%s was not finished" % name)
750
+ end
751
+
752
+ # Now make sure that cleanup gets rid of those generated types.
753
+ assert_nothing_raised do
754
+ trans.cleanup
755
+ end
756
+ end
757
+
719
758
  def test_ignore_tags?
720
759
  config = Puppet::Node::Catalog.new
721
760
  config.host_config = true
@@ -757,7 +796,7 @@ class TestTransactions < Test::Unit::TestCase
757
796
  def test_proxy_resources
758
797
  type = mkreducer do
759
798
  def evaluate
760
- return Puppet::PropertyChange.new(Fakeprop.new(
799
+ return Puppet::Transaction::Change.new(Fakeprop.new(
761
800
  :path => :path, :is => :is, :should => :should, :name => self.name, :resource => "a parent"), :is)
762
801
  end
763
802
  end
@@ -776,7 +815,7 @@ class TestTransactions < Test::Unit::TestCase
776
815
  assert(changes.length > 0, "did not get any changes")
777
816
 
778
817
  changes.each do |change|
779
- assert_equal(resource, change.source, "change did not get proxy set correctly")
818
+ assert_equal(resource, change.resource, "change did not get proxy set correctly")
780
819
  end
781
820
  end
782
821
 
@@ -866,17 +905,16 @@ class TestTransactions < Test::Unit::TestCase
866
905
  assert(result, "c did not trigger anything")
867
906
  assert_instance_of(Array, result)
868
907
  event = result.shift
869
- assert_instance_of(Puppet::Event, event)
870
- assert_equal(:triggered, event.event, "event was not set correctly")
908
+ assert_instance_of(Puppet::Transaction::Event, event)
909
+ assert_equal(:triggered, event.name, "event was not set correctly")
871
910
  assert_equal(c, event.source, "source was not set correctly")
872
- assert_equal(trans, event.transaction, "transaction was not set correctly")
873
911
 
874
912
  assert(trans.triggered?(c, :refresh),
875
913
  "Transaction did not store the trigger")
876
914
  end
877
915
 
878
916
  def test_set_target
879
- file = Puppet::Type.newfile(:path => tempfile(), :content => "yay")
917
+ file = Puppet::Type.type(:file).create(:path => tempfile(), :content => "yay")
880
918
  exec1 = Puppet::Type.type(:exec).create :command => "/bin/echo exec1"
881
919
  exec2 = Puppet::Type.type(:exec).create :command => "/bin/echo exec2"
882
920
  trans = Puppet::Transaction.new(mk_catalog(file, exec1, exec2))
@@ -911,7 +949,7 @@ class TestTransactions < Test::Unit::TestCase
911
949
  Puppet::Type.rmtype(:norefresh)
912
950
  end
913
951
 
914
- file = Puppet::Type.newfile :path => tempfile(), :content => "yay"
952
+ file = Puppet::Type.type(:file).create :path => tempfile(), :content => "yay"
915
953
  one = klass.create :name => "one", :subscribe => file
916
954
 
917
955
  assert_apply(file, one)
@@ -956,7 +994,7 @@ class TestTransactions < Test::Unit::TestCase
956
994
  newparam(:name) {}
957
995
  newproperty(:testing) do
958
996
  def sync
959
- self.is = self.should
997
+ # noop
960
998
  :ran_testing
961
999
  end
962
1000
  end
@@ -989,8 +1027,8 @@ class TestTransactions < Test::Unit::TestCase
989
1027
  # Now files
990
1028
  d = tempfile()
991
1029
  f = File.join(d, "file")
992
- file = Puppet::Type.newfile(:path => f, :content => "yay")
993
- dir = Puppet::Type.newfile(:path => d, :ensure => :directory, :require => file)
1030
+ file = Puppet::Type.type(:file).create(:path => f, :content => "yay")
1031
+ dir = Puppet::Type.type(:file).create(:path => d, :ensure => :directory, :require => file)
994
1032
 
995
1033
  rels[dir] = file
996
1034
  rels.each do |after, before|
@@ -1014,7 +1052,7 @@ class TestTransactions < Test::Unit::TestCase
1014
1052
  path = tempfile
1015
1053
  epath = tempfile
1016
1054
  spath = tempfile
1017
- file = Puppet::Type.newfile(:path => path, :ensure => :file,
1055
+ file = Puppet::Type.type(:file).create(:path => path, :ensure => :file,
1018
1056
  :title => "file")
1019
1057
  exec = Puppet::Type.type(:exec).create(:command => "touch %s" % epath,
1020
1058
  :path => ENV["PATH"], :subscribe => file, :refreshonly => true,
@@ -1052,7 +1090,7 @@ class TestTransactions < Test::Unit::TestCase
1052
1090
  3.times do |i|
1053
1091
  path = tempfile
1054
1092
  paths << path
1055
- file = Puppet::Type.newfile(:path => path, :ensure => :absent,
1093
+ file = Puppet::Type.type(:file).create(:path => path, :ensure => :absent,
1056
1094
  :backup => false, :title => "file%s" % i)
1057
1095
  File.open(path, "w") { |f| f.puts "" }
1058
1096
  files << file
@@ -151,41 +151,4 @@ class TestRailsHost < PuppetTest::TestCase
151
151
  "loglevel was not added")
152
152
  end
153
153
  end
154
-
155
- def test_freshness_connect_update
156
- Puppet::Rails.init
157
- Puppet[:storeconfigs] = true
158
-
159
- Puppet[:code] = " "
160
- # this is the default server setup
161
- master = Puppet::Network::Handler.configuration.new(
162
- :Local => true
163
- )
164
-
165
- # Create a host
166
- Puppet::Rails::Host.new(:name => "test", :ip => "192.168.0.3").save
167
-
168
- assert_nothing_raised("Failed to update last_connect for unknown host") do
169
- master.version("created",'192.168.0.1')
170
- end
171
-
172
- # Make sure it created the host
173
- created = Puppet::Rails::Host.find_by_name("created")
174
- assert(created, "Freshness did not create host")
175
- assert(created.last_freshcheck,
176
- "Did not set last_freshcheck on created host")
177
-
178
- # Now check on the existing host
179
- assert_nothing_raised("Failed to update last_connect for unknown host") do
180
- master.version("test",'192.168.0.2')
181
- end
182
-
183
- # Recreate it, so we're not using the cached object.
184
- host = Puppet::Rails::Host.find_by_name("test")
185
-
186
- # Make sure it created the host
187
- assert(host.last_freshcheck,
188
- "Did not set last_freshcheck on existing host")
189
- end
190
154
  end
191
-
@@ -530,8 +530,6 @@ class TestCronParsedProvider < Test::Unit::TestCase
530
530
  @provider.initvars
531
531
  str += "\n"
532
532
  target.write(str)
533
- assert_equal(str, target.read,
534
- "Did not write correctly")
535
533
  assert_nothing_raised("Could not prefetch with %s" % str.inspect) do
536
534
  @provider.prefetch
537
535
  end
@@ -551,6 +549,11 @@ class TestCronParsedProvider < Test::Unit::TestCase
551
549
  end
552
550
  end
553
551
 
552
+ # #707
553
+ def test_write_freebsd_special
554
+ assert_equal(@provider.to_line(:record_type => :crontab, :ensure => :present, :special => "reboot", :command => "/bin/echo something"), "@reboot /bin/echo something")
555
+ end
556
+
554
557
  def test_prefetch
555
558
  cron = @type.create :command => "/bin/echo yay", :name => "test", :hour => 4
556
559
 
@@ -599,5 +602,31 @@ class TestCronParsedProvider < Test::Unit::TestCase
599
602
  result = target.read
600
603
  assert_equal("# Puppet Name: test\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
601
604
  end
602
- end
603
605
 
606
+ # Testing #1216
607
+ def test_strange_lines
608
+ @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
609
+ text = " 5 \t\t 1,2 * 1 0 /bin/echo funtest"
610
+
611
+ records = nil
612
+ assert_nothing_raised {
613
+ records = @provider.parse(text)
614
+ }
615
+
616
+ should = {
617
+ :minute => %w{5},
618
+ :hour => %w{1 2},
619
+ :monthday => :absent,
620
+ :month => %w{1},
621
+ :weekday => %w{0},
622
+ :command => "/bin/echo funtest"
623
+ }
624
+
625
+ is = records.shift
626
+ assert(is, "Did not get record")
627
+
628
+ should.each do |p, v|
629
+ assert_equal(v, is[p], "did not parse %s correctly" % p)
630
+ end
631
+ end
632
+ end
@@ -37,12 +37,13 @@ class TestProvider < Test::Unit::TestCase
37
37
  cleanup { Puppet::Type.rmtype(:provider_test) }
38
38
  end
39
39
 
40
- def test_confine
41
- provider = newprovider
40
+ def test_confine_defaults_to_suitable
42
41
 
43
- assert(provider.suitable?,
44
- "Marked unsuitable with no confines")
42
+ provider = newprovider
43
+ assert(provider.suitable?, "Marked unsuitable with no confines")
44
+ end
45
45
 
46
+ def test_confine_results
46
47
  {
47
48
  {:true => true} => true,
48
49
  {:true => false} => false,
@@ -54,6 +55,8 @@ class TestProvider < Test::Unit::TestCase
54
55
  {:exists => echo} => true,
55
56
  {:exists => "/this/file/does/not/exist"} => false,
56
57
  }.each do |hash, result|
58
+ provider = newprovider
59
+
57
60
  # First test :true
58
61
  hash.each do |test, val|
59
62
  assert_nothing_raised do
@@ -61,19 +64,25 @@ class TestProvider < Test::Unit::TestCase
61
64
  end
62
65
  end
63
66
 
64
- assert_equal(result, provider.suitable?,
65
- "Failed for %s" % [hash.inspect])
67
+ assert_equal(result, provider.suitable?, "Failed for %s" % [hash.inspect])
66
68
 
67
69
  provider.initvars
68
70
  end
71
+ end
72
+
73
+ def test_multiple_confines_do_not_override
74
+ provider = newprovider
69
75
 
70
76
  # Make sure multiple confines don't overwrite each other
71
77
  provider.confine :true => false
72
78
  assert(! provider.suitable?)
73
79
  provider.confine :true => true
74
80
  assert(! provider.suitable?)
81
+ end
75
82
 
76
- provider.initvars
83
+ def test_one_failed_confine_is_sufficient
84
+
85
+ provider = newprovider
77
86
 
78
87
  # Make sure we test multiple of them, and that a single false wins
79
88
  provider.confine :true => true, :false => false
@@ -82,6 +91,18 @@ class TestProvider < Test::Unit::TestCase
82
91
  assert(! provider.suitable?)
83
92
  end
84
93
 
94
+ # #1197 - the binary should not be
95
+ def test_command_checks_for_binaries_each_time
96
+ provider = newprovider
97
+
98
+ provider.commands :testing => "/no/such/path"
99
+
100
+ provider.stubs(:binary).returns "/no/such/path"
101
+
102
+ provider.command(:testing)
103
+ assert_equal("/no/such/path", provider.command(:testing), "Did not return correct binary path")
104
+ end
105
+
85
106
  def test_command
86
107
  {:echo => "echo", :echo_with_path => echo, :missing => "nosuchcommand", :missing_qualified => "/path/to/nosuchcommand"}.each do |name, command|
87
108
  provider = newprovider
@@ -145,16 +145,7 @@ class TestFileSources < Test::Unit::TestCase
145
145
  # Make sure the munge didn't actually change the source
146
146
  assert_equal([source], property.should, "munging changed the source")
147
147
 
148
- # First try it with a missing source
149
148
  currentvalue = nil
150
- assert_nothing_raised do
151
- currentvalue = property.retrieve
152
- end
153
-
154
- # And make sure the property considers itself in sync, since there's nothing
155
- # to do
156
- assert(property.insync?(currentvalue), "source thinks there's work to do with no file or dest")
157
-
158
149
  # Now make the dest a directory, and make sure the object sets :ensure
159
150
  # up to create a directory
160
151
  Dir.mkdir(source)
@@ -170,9 +161,6 @@ class TestFileSources < Test::Unit::TestCase
170
161
 
171
162
  # Now remove the source, and make sure :ensure was not modified
172
163
  Dir.rmdir(source)
173
- assert_nothing_raised do
174
- property.retrieve
175
- end
176
164
  assert_equal(:directory, file.should(:ensure),
177
165
  "Did not keep :ensure setting")
178
166
 
@@ -208,10 +196,6 @@ class TestFileSources < Test::Unit::TestCase
208
196
  property = file.property(:source)
209
197
  assert(property, "did not get source property")
210
198
 
211
- # Try it with no source at all
212
- currentvalues = file.retrieve
213
- assert(property.insync?(currentvalues[property]), "source property not in sync with missing source")
214
-
215
199
  # with a directory
216
200
  Dir.mkdir(source)
217
201
  currentvalues = file.retrieve
@@ -623,9 +607,9 @@ class TestFileSources < Test::Unit::TestCase
623
607
  :name => name
624
608
  )
625
609
 
626
- assert_nothing_raised {
610
+ assert_raise Puppet::Error do
627
611
  file.retrieve
628
- }
612
+ end
629
613
 
630
614
  comp = mk_catalog(file)
631
615
  comp.apply
@@ -3,7 +3,6 @@
3
3
  require File.dirname(__FILE__) + '/../../lib/puppettest'
4
4
 
5
5
  require 'puppettest'
6
- require 'puppet/type/sshkey'
7
6
  require 'facter'
8
7
 
9
8
  class TestSSHKey < Test::Unit::TestCase
@@ -362,6 +362,12 @@ class TestUser < Test::Unit::TestCase
362
362
  user.delete(:groups)
363
363
  end
364
364
 
365
+ def test_groups_list_must_not_contain_commas
366
+ assert_raise(Puppet::Error) do
367
+ Puppet::Type.type(:user).create :name => "luke", :groups => "root,adm"
368
+ end
369
+ end
370
+
365
371
  def test_autorequire
366
372
  file = tempfile()
367
373
  comp = nil
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # = Synopsis
5
+ #
6
+ # Run unit tests, usually with the goal of resolving some conflict
7
+ # between tests.
8
+ #
9
+ # = Usage
10
+ #
11
+ # test [-d|--debug] [-f|--files] [-h|--help] [-n method] [-v|--verbose] <file> [file] ...
12
+ #
13
+ # = Description
14
+ #
15
+ # This script is useful for running a specific subset of unit tests, especially
16
+ # when attempting to find a conflict between tests. By default, it will take
17
+ # the first argument you pass it and run that test or test directory with each
18
+ # test directory in turn, looking for a failure. If any tests fail, then
19
+ # the script will drill into that test directory, looking for the specific conflict.
20
+ #
21
+ # In this way, when you have deduced you have two conflicting unit tests (tests which
22
+ # pass in isolation but fail when run together), you can tell this script where
23
+ # the failure is and leave it alone to find the conflict.
24
+ #
25
+ # This script is different from the Rakefile because it will run all tests in
26
+ # a single process, whereas if you ask the Rakefile to run multiple tests, it will
27
+ # run them in separate processes thus making it impossible to find conflicts.
28
+ #
29
+ # = Examples
30
+ #
31
+ # Attempt to resolve a conflict between a single test suite that could be anywhere:
32
+ #
33
+ # ./test ral/providers/user.rb
34
+ #
35
+ # Determine whether two individual files conflict:
36
+ #
37
+ # ./test --files language/functions.rb ral/providers/provider.rb
38
+ #
39
+ # Run the same test, but only run a specific unit test:
40
+ #
41
+ # ./test -d -n test_search --files language/functions.rb ral/providers/provider.rb
42
+ #
43
+ # = Options
44
+ #
45
+ # debug::
46
+ # Enable full debugging.
47
+ #
48
+ # files::
49
+ # Specify exactly which files to test.
50
+ #
51
+ # help::
52
+ # Print this help message
53
+ #
54
+ # n::
55
+ # Specify a single unit test to run. You can still specify as many files
56
+ # as you want.
57
+ #
58
+ # verbose::
59
+ # Print extra information.
60
+ #
61
+ # = Example
62
+ #
63
+ # puppet -l /tmp/script.log script.pp
64
+ #
65
+ # = Author
66
+ #
67
+ # Luke Kanies
68
+ #
69
+ # = Copyright
70
+ #
71
+ # Copyright (c) 2005 Reductive Labs, LLC
72
+ # Licensed under the GNU Public License
73
+
74
+ require 'find'
75
+ require 'getoptlong'
76
+ include Find
77
+
78
+ result = GetoptLong.new(
79
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
80
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
81
+ [ "-n", GetoptLong::REQUIRED_ARGUMENT ],
82
+ [ "--files", "-f", GetoptLong::NO_ARGUMENT ],
83
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
84
+ )
85
+
86
+ usage = "USAGE: %s [--help] suite" % $0
87
+
88
+ $options = {}
89
+ keep = []
90
+
91
+ result.each { |opt,arg|
92
+ case opt
93
+ when "--verbose"
94
+ $options[:verbose] = true
95
+ when "--files"
96
+ $options[:files] = true
97
+ when "--debug"
98
+ $options[:debug] = true
99
+ $options[:verbose] = true
100
+ when "--help"
101
+ puts usage
102
+ exit
103
+ else
104
+ keep << opt
105
+ keep << arg if arg
106
+ end
107
+ }
108
+
109
+ def dirs
110
+ Dir.glob("*").find_all { |d| FileTest.directory?(d) }.reject { |d|
111
+ ["lib", "data"].include?(d)
112
+ }
113
+ end
114
+
115
+ def rake(*args)
116
+ print "trying %s..." % args.join(" ")
117
+ output = %x{rake %s} % args.join(" ")
118
+
119
+ if $?.exitstatus == 0
120
+ puts "succeeded"
121
+ return true
122
+ else
123
+ puts "failed"
124
+ return false
125
+ end
126
+ end
127
+
128
+ def resolve(dir)
129
+ dirs = dirs()
130
+
131
+ # If the passed dir is a subdir or file, put the basedir last
132
+ if dir.include?(File::SEPARATOR)
133
+ basedir = dir.split(File::SEPARATOR)[0]
134
+ if dirs.include?(basedir)
135
+ dirs.delete(basedir)
136
+ dirs << basedir
137
+ end
138
+ end
139
+
140
+ failed = nil
141
+ dirs.each do |d|
142
+ next if d == dir
143
+ unless run([d, dir])
144
+ failed = d
145
+ break
146
+ end
147
+ end
148
+ puts "%s failed" % failed
149
+
150
+ files = ruby_files(failed)
151
+
152
+ files.each do |file|
153
+ unless run([file, dir])
154
+ puts file
155
+ exit(0)
156
+ end
157
+ end
158
+
159
+ exit(1)
160
+ end
161
+
162
+ def ruby_files(dir)
163
+ files = []
164
+ # First collect the entire file list.
165
+ begin
166
+ find(dir) { |f| files << f if f =~ /\.rb$/ }
167
+ rescue => detail
168
+ puts "could not find on %s: %s" % [dir.inspect, detail]
169
+ end
170
+ files
171
+ end
172
+
173
+ def run(files, flags = nil)
174
+ args = %w{ruby}
175
+ args << "-Ilib:../lib"
176
+ args << "lib/rake/puppet_test_loader.rb"
177
+ if flags
178
+ args += flags
179
+ end
180
+ args += ARGV
181
+
182
+ print files.join(" ") + "... "
183
+ $stdout.flush
184
+
185
+ files.each do |file|
186
+ case File.stat(file).ftype
187
+ when "file": args << file
188
+ when "directory": args += ruby_files(file)
189
+ else
190
+ $stderr.puts "Skipping %s; can't handle %s" %
191
+ [file, File.stat(file).ftype]
192
+ end
193
+ end
194
+ args = args.join(" ")
195
+ if $options[:verbose]
196
+ p args
197
+ end
198
+ output = %x{#{args} 2>&1}
199
+ if $options[:debug]
200
+ print output
201
+ end
202
+
203
+ if $?.exitstatus == 0
204
+ puts "succeeded"
205
+ return true
206
+ else
207
+ puts "failed"
208
+ puts output
209
+ return false
210
+ end
211
+ end
212
+
213
+ if $options[:files]
214
+ run(ARGV, keep)
215
+ else
216
+ dir = ARGV.shift
217
+
218
+ unless dir
219
+ $stderr.puts usage
220
+ exit(1)
221
+ end
222
+ resolve(dir)
223
+ end
224
+ #
225
+ #
226
+ #files = []
227
+ #
228
+ #args.each do |test|
229
+ # if FileTest.directory?(test)
230
+ # files += ruby_files(test)
231
+ # end
232
+ #end
233
+
234
+ ## Now load all of our files.
235
+ #files.each do |file|
236
+ # load file unless file =~ /^-/
237
+ #end
238
+ #
239
+ #runner = Test::Unit::AutoRunner.new(false)
240
+ #runner.process_args
241
+ #runner.run