puppet 0.24.6 → 0.24.7

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 (383) hide show
  1. data/CHANGELOG +115 -0
  2. data/Rakefile +43 -14
  3. data/bin/puppetca +6 -5
  4. data/bin/puppetdoc +109 -15
  5. data/bin/ralsh +3 -1
  6. data/conf/redhat/puppet.spec +74 -48
  7. data/examples/mcx_dock_absent.pp +4 -0
  8. data/examples/mcx_dock_default.pp +118 -0
  9. data/examples/mcx_dock_full.pp +125 -0
  10. data/examples/mcx_dock_invalid.pp +9 -0
  11. data/examples/mcx_nogroup.pp +118 -0
  12. data/examples/mcx_notexists_absent.pp +4 -0
  13. data/ext/emacs/puppet-mode.el +1 -1
  14. data/lib/puppet.rb +1 -1
  15. data/lib/puppet/external/nagios/base.rb +114 -71
  16. data/lib/puppet/feature/base.rb +6 -0
  17. data/lib/puppet/indirector/yaml.rb +12 -3
  18. data/lib/puppet/module.rb +1 -1
  19. data/lib/puppet/network/client/master.rb +1 -1
  20. data/lib/puppet/network/xmlrpc/client.rb +3 -1
  21. data/lib/puppet/parameter.rb +1 -1
  22. data/lib/puppet/parser/ast.rb +15 -0
  23. data/lib/puppet/parser/ast/astarray.rb +1 -2
  24. data/lib/puppet/parser/ast/casestatement.rb +2 -0
  25. data/lib/puppet/parser/ast/collection.rb +2 -0
  26. data/lib/puppet/parser/ast/comparison_operator.rb +4 -0
  27. data/lib/puppet/parser/ast/definition.rb +2 -0
  28. data/lib/puppet/parser/ast/else.rb +3 -0
  29. data/lib/puppet/parser/ast/function.rb +19 -12
  30. data/lib/puppet/parser/ast/hostclass.rb +9 -1
  31. data/lib/puppet/parser/ast/ifstatement.rb +3 -0
  32. data/lib/puppet/parser/ast/node.rb +3 -0
  33. data/lib/puppet/parser/ast/resource.rb +3 -0
  34. data/lib/puppet/parser/ast/resource_defaults.rb +2 -0
  35. data/lib/puppet/parser/ast/resource_override.rb +3 -0
  36. data/lib/puppet/parser/ast/vardef.rb +3 -0
  37. data/lib/puppet/parser/functions.rb +14 -0
  38. data/lib/puppet/parser/functions/inline_template.rb +21 -0
  39. data/lib/puppet/parser/functions/template.rb +3 -2
  40. data/lib/puppet/parser/lexer.rb +56 -7
  41. data/lib/puppet/parser/parser.rb +114 -98
  42. data/lib/puppet/parser/parser_support.rb +24 -4
  43. data/lib/puppet/parser/resource/reference.rb +4 -3
  44. data/lib/puppet/parser/templatewrapper.rb +30 -22
  45. data/lib/puppet/property.rb +1 -1
  46. data/lib/puppet/property/list.rb +7 -2
  47. data/lib/puppet/property/ordered_list.rb +22 -0
  48. data/lib/puppet/provider/augeas/augeas.rb +189 -0
  49. data/lib/puppet/provider/computer/computer.rb +22 -0
  50. data/lib/puppet/provider/confine.rb +4 -1
  51. data/lib/puppet/provider/confine/variable.rb +13 -2
  52. data/lib/puppet/provider/confine_collection.rb +4 -1
  53. data/lib/puppet/provider/confiner.rb +1 -1
  54. data/lib/puppet/provider/group/directoryservice.rb +6 -3
  55. data/lib/puppet/provider/group/groupadd.rb +5 -2
  56. data/lib/puppet/provider/group/ldap.rb +11 -9
  57. data/lib/puppet/provider/group/netinfo.rb +8 -4
  58. data/lib/puppet/provider/group/pw.rb +5 -1
  59. data/lib/puppet/provider/host/netinfo.rb +5 -2
  60. data/lib/puppet/provider/macauthorization/macauthorization.rb +315 -0
  61. data/lib/puppet/provider/mcx/mcxcontent.rb +201 -0
  62. data/lib/puppet/provider/nameservice/directoryservice.rb +210 -107
  63. data/lib/puppet/provider/nameservice/netinfo.rb +7 -2
  64. data/lib/puppet/provider/package/appdmg.rb +0 -3
  65. data/lib/puppet/provider/package/apt.rb +6 -0
  66. data/lib/puppet/provider/package/rpm.rb +2 -0
  67. data/lib/puppet/provider/package/yum.rb +5 -1
  68. data/lib/puppet/provider/package/yumhelper.py +9 -0
  69. data/lib/puppet/provider/service/base.rb +9 -6
  70. data/lib/puppet/provider/service/daemontools.rb +25 -15
  71. data/lib/puppet/provider/service/debian.rb +6 -2
  72. data/lib/puppet/provider/service/freebsd.rb +5 -2
  73. data/lib/puppet/provider/service/gentoo.rb +6 -3
  74. data/lib/puppet/provider/service/init.rb +31 -21
  75. data/lib/puppet/provider/service/launchd.rb +195 -0
  76. data/lib/puppet/provider/service/redhat.rb +5 -2
  77. data/lib/puppet/provider/service/runit.rb +30 -20
  78. data/lib/puppet/provider/service/smf.rb +7 -4
  79. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +21 -1
  80. data/lib/puppet/provider/user/directoryservice.rb +1 -0
  81. data/lib/puppet/provider/user/netinfo.rb +9 -3
  82. data/lib/puppet/provider/user/user_role_add.rb +43 -6
  83. data/lib/puppet/provider/zfs/solaris.rb +45 -0
  84. data/lib/puppet/provider/zone/solaris.rb +8 -4
  85. data/lib/puppet/provider/zpool/solaris.rb +116 -0
  86. data/lib/puppet/rails/database/003_add_environment_to_host.rb +9 -0
  87. data/lib/puppet/rails/database/schema.rb +1 -0
  88. data/lib/puppet/rails/host.rb +4 -0
  89. data/lib/puppet/reference/configuration.rb +1 -1
  90. data/lib/puppet/reports/tagmail.rb +15 -6
  91. data/lib/puppet/transaction/change.rb +3 -5
  92. data/lib/puppet/transportable.rb +1 -0
  93. data/lib/puppet/type/augeas.rb +155 -0
  94. data/lib/puppet/type/computer.rb +62 -0
  95. data/lib/puppet/type/exec.rb +2 -1
  96. data/lib/puppet/type/file.rb +1 -1
  97. data/lib/puppet/type/file/ensure.rb +8 -5
  98. data/lib/puppet/type/file/mode.rb +0 -14
  99. data/lib/puppet/type/file/owner.rb +32 -64
  100. data/lib/puppet/type/file/selcontext.rb +3 -8
  101. data/lib/puppet/type/group.rb +27 -45
  102. data/lib/puppet/type/k5login.rb +1 -1
  103. data/lib/puppet/type/macauthorization.rb +141 -0
  104. data/lib/puppet/type/mcx.rb +115 -0
  105. data/lib/puppet/type/mount.rb +1 -1
  106. data/lib/puppet/type/nagios_hostdependency.rb +3 -0
  107. data/lib/puppet/type/ssh_authorized_key.rb +16 -0
  108. data/lib/puppet/type/tidy.rb +43 -14
  109. data/lib/puppet/type/user.rb +25 -1
  110. data/lib/puppet/type/zfs.rb +51 -0
  111. data/lib/puppet/type/zone.rb +8 -0
  112. data/lib/puppet/type/zpool.rb +93 -0
  113. data/lib/puppet/util.rb +17 -38
  114. data/lib/puppet/util/file_locking.rb +44 -0
  115. data/lib/puppet/util/filetype.rb +3 -3
  116. data/lib/puppet/util/log.rb +1 -16
  117. data/lib/puppet/util/metric.rb +0 -5
  118. data/lib/puppet/util/rdoc.rb +85 -0
  119. data/lib/puppet/util/rdoc/code_objects.rb +219 -0
  120. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +829 -0
  121. data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +1051 -0
  122. data/lib/puppet/util/rdoc/parser.rb +437 -0
  123. data/lib/puppet/util/selinux.rb +135 -63
  124. data/lib/puppet/util/settings.rb +136 -126
  125. data/lib/puppet/util/storage.rb +4 -2
  126. data/spec/Rakefile +91 -0
  127. data/spec/integration/checksum.rb +47 -0
  128. data/spec/integration/defaults.rb +47 -0
  129. data/spec/integration/file_serving/configuration.rb +43 -0
  130. data/spec/integration/file_serving/content.rb +18 -0
  131. data/spec/integration/file_serving/metadata.rb +18 -0
  132. data/spec/integration/indirector/direct_file_server.rb +80 -0
  133. data/spec/integration/indirector/file_content/file_server.rb +18 -0
  134. data/spec/integration/indirector/file_metadata/file_server.rb +18 -0
  135. data/spec/integration/indirector/module_files.rb +57 -0
  136. data/spec/integration/indirector/node/ldap.rb +15 -0
  137. data/spec/integration/indirector/rest.rb +464 -0
  138. data/spec/integration/network/server/mongrel.rb +48 -0
  139. data/spec/integration/network/server/webrick.rb +48 -0
  140. data/spec/integration/node.rb +93 -0
  141. data/spec/integration/node/catalog.rb +54 -0
  142. data/spec/integration/node/facts.rb +45 -0
  143. data/spec/integration/provider/package.rb +26 -0
  144. data/spec/integration/provider/service/init.rb +32 -0
  145. data/spec/integration/reference/providers.rb +17 -0
  146. data/spec/integration/reports.rb +14 -0
  147. data/spec/integration/transaction/report.rb +26 -0
  148. data/spec/integration/type/package.rb +22 -0
  149. data/spec/integration/util/file_locking.rb +36 -0
  150. data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +46 -0
  151. data/spec/monkey_patches/alias_should_to_must.rb +5 -0
  152. data/spec/shared_behaviours/file_server_terminus.rb +42 -0
  153. data/spec/shared_behaviours/file_serving.rb +64 -0
  154. data/spec/shared_behaviours/memory_terminus.rb +32 -0
  155. data/spec/spec.opts +5 -0
  156. data/spec/spec_helper.rb +36 -0
  157. data/spec/unit/executables/client/certhandler.rb +122 -0
  158. data/spec/unit/file_serving/configuration.rb +224 -0
  159. data/spec/unit/file_serving/configuration/parser.rb +135 -0
  160. data/spec/unit/file_serving/content.rb +71 -0
  161. data/spec/unit/file_serving/file_base.rb +124 -0
  162. data/spec/unit/file_serving/fileset.rb +239 -0
  163. data/spec/unit/file_serving/indirection_hooks.rb +124 -0
  164. data/spec/unit/file_serving/metadata.rb +187 -0
  165. data/spec/unit/file_serving/mount.rb +143 -0
  166. data/spec/unit/file_serving/terminus_helper.rb +76 -0
  167. data/spec/unit/indirector.rb +152 -0
  168. data/spec/unit/indirector/catalog/compiler.rb +156 -0
  169. data/spec/unit/indirector/catalog/yaml.rb +25 -0
  170. data/spec/unit/indirector/checksum/file.rb +139 -0
  171. data/spec/unit/indirector/code.rb +33 -0
  172. data/spec/unit/indirector/direct_file_server.rb +89 -0
  173. data/spec/unit/indirector/envelope.rb +47 -0
  174. data/spec/unit/indirector/exec.rb +51 -0
  175. data/spec/unit/indirector/facts/facter.rb +76 -0
  176. data/spec/unit/indirector/facts/yaml.rb +26 -0
  177. data/spec/unit/indirector/file.rb +154 -0
  178. data/spec/unit/indirector/file_content/file.rb +18 -0
  179. data/spec/unit/indirector/file_content/file_server.rb +18 -0
  180. data/spec/unit/indirector/file_content/modules.rb +18 -0
  181. data/spec/unit/indirector/file_content/rest.rb +11 -0
  182. data/spec/unit/indirector/file_metadata/file.rb +52 -0
  183. data/spec/unit/indirector/file_metadata/file_server.rb +18 -0
  184. data/spec/unit/indirector/file_metadata/modules.rb +42 -0
  185. data/spec/unit/indirector/file_metadata/rest.rb +9 -0
  186. data/spec/unit/indirector/file_server.rb +184 -0
  187. data/spec/unit/indirector/indirection.rb +731 -0
  188. data/spec/unit/indirector/ldap.rb +143 -0
  189. data/spec/unit/indirector/memory.rb +29 -0
  190. data/spec/unit/indirector/module_files.rb +259 -0
  191. data/spec/unit/indirector/node/exec.rb +69 -0
  192. data/spec/unit/indirector/node/ldap.rb +424 -0
  193. data/spec/unit/indirector/node/memory.rb +19 -0
  194. data/spec/unit/indirector/node/plain.rb +19 -0
  195. data/spec/unit/indirector/node/rest.rb +13 -0
  196. data/spec/unit/indirector/node/yaml.rb +25 -0
  197. data/spec/unit/indirector/plain.rb +29 -0
  198. data/spec/unit/indirector/report/processor.rb +81 -0
  199. data/spec/unit/indirector/request.rb +87 -0
  200. data/spec/unit/indirector/rest.rb +372 -0
  201. data/spec/unit/indirector/ssl_rsa/file.rb +116 -0
  202. data/spec/unit/indirector/terminus.rb +245 -0
  203. data/spec/unit/indirector/yaml.rb +145 -0
  204. data/spec/unit/module.rb +247 -0
  205. data/spec/unit/network/client.rb +45 -0
  206. data/spec/unit/network/client/master.rb +442 -0
  207. data/spec/unit/network/handler/fileserver.rb +179 -0
  208. data/spec/unit/network/http.rb +35 -0
  209. data/spec/unit/network/http/mongrel.rb +117 -0
  210. data/spec/unit/network/http/mongrel/rest.rb +377 -0
  211. data/spec/unit/network/http/mongrel/xmlrpc.rb +0 -0
  212. data/spec/unit/network/http/webrick.rb +127 -0
  213. data/spec/unit/network/http/webrick/rest.rb +323 -0
  214. data/spec/unit/network/http/webrick/xmlrpc.rb +0 -0
  215. data/spec/unit/network/http_pool.rb +238 -0
  216. data/spec/unit/network/server.rb +316 -0
  217. data/spec/unit/network/xmlrpc/client.rb +13 -0
  218. data/spec/unit/node.rb +167 -0
  219. data/spec/unit/node/catalog.rb +864 -0
  220. data/spec/unit/node/environment.rb +37 -0
  221. data/spec/unit/node/facts.rb +44 -0
  222. data/spec/unit/other/checksum.rb +92 -0
  223. data/spec/unit/other/pgraph.rb +210 -0
  224. data/spec/unit/other/transaction.rb +33 -0
  225. data/spec/unit/other/transbucket.rb +172 -0
  226. data/spec/unit/other/transobject.rb +92 -0
  227. data/spec/unit/parameter.rb +24 -0
  228. data/spec/unit/parser/ast.rb +37 -0
  229. data/spec/unit/parser/ast/arithmetic_operator.rb +73 -0
  230. data/spec/unit/parser/ast/astarray.rb +66 -0
  231. data/spec/unit/parser/ast/boolean_operator.rb +53 -0
  232. data/spec/unit/parser/ast/collexpr.rb +92 -0
  233. data/spec/unit/parser/ast/comparison_operator.rb +92 -0
  234. data/spec/unit/parser/ast/definition.rb +195 -0
  235. data/spec/unit/parser/ast/function.rb +77 -0
  236. data/spec/unit/parser/ast/hostclass.rb +148 -0
  237. data/spec/unit/parser/ast/minus.rb +36 -0
  238. data/spec/unit/parser/ast/node.rb +125 -0
  239. data/spec/unit/parser/ast/nop.rb +20 -0
  240. data/spec/unit/parser/ast/not.rb +30 -0
  241. data/spec/unit/parser/ast/resource_override.rb +51 -0
  242. data/spec/unit/parser/ast/resource_reference.rb +63 -0
  243. data/spec/unit/parser/ast/vardef.rb +47 -0
  244. data/spec/unit/parser/collector.rb +426 -0
  245. data/spec/unit/parser/compiler.rb +561 -0
  246. data/spec/unit/parser/functions.rb +83 -0
  247. data/spec/unit/parser/functions/inline_template.rb +59 -0
  248. data/spec/unit/parser/functions/template.rb +62 -0
  249. data/spec/unit/parser/interpreter.rb +138 -0
  250. data/spec/unit/parser/lexer.rb +646 -0
  251. data/spec/unit/parser/parser.rb +228 -0
  252. data/spec/unit/parser/resource.rb +336 -0
  253. data/spec/unit/parser/resource/reference.rb +95 -0
  254. data/spec/unit/parser/scope.rb +87 -0
  255. data/spec/unit/parser/templatewrapper.rb +129 -0
  256. data/spec/unit/property.rb +35 -0
  257. data/spec/unit/property/keyvalue.rb +168 -0
  258. data/spec/unit/property/list.rb +156 -0
  259. data/spec/unit/property/ordered_list.rb +64 -0
  260. data/spec/unit/provider/augeas/augeas.rb +238 -0
  261. data/spec/unit/provider/confine.rb +78 -0
  262. data/spec/unit/provider/confine/exists.rb +81 -0
  263. data/spec/unit/provider/confine/false.rb +53 -0
  264. data/spec/unit/provider/confine/feature.rb +60 -0
  265. data/spec/unit/provider/confine/true.rb +53 -0
  266. data/spec/unit/provider/confine/variable.rb +107 -0
  267. data/spec/unit/provider/confine_collection.rb +134 -0
  268. data/spec/unit/provider/confiner.rb +63 -0
  269. data/spec/unit/provider/group/groupadd.rb +31 -0
  270. data/spec/unit/provider/group/ldap.rb +105 -0
  271. data/spec/unit/provider/ldap.rb +248 -0
  272. data/spec/unit/provider/macauthorization.rb +147 -0
  273. data/spec/unit/provider/mcx/mcxcontent.rb +175 -0
  274. data/spec/unit/provider/mount.rb +130 -0
  275. data/spec/unit/provider/mount/parsed.rb +185 -0
  276. data/spec/unit/provider/package/apt.rb +138 -0
  277. data/spec/unit/provider/package/dpkg.rb +163 -0
  278. data/spec/unit/provider/package/gem.rb +87 -0
  279. data/spec/unit/provider/package/hpux.rb +52 -0
  280. data/spec/unit/provider/selboolean.rb +37 -0
  281. data/spec/unit/provider/selmodule-example.pp +0 -0
  282. data/spec/unit/provider/selmodule.rb +66 -0
  283. data/spec/unit/provider/service/daemontools.rb +124 -0
  284. data/spec/unit/provider/service/launchd.rb +134 -0
  285. data/spec/unit/provider/service/runit.rb +117 -0
  286. data/spec/unit/provider/ssh_authorized_key/parsed.rb +102 -0
  287. data/spec/unit/provider/user/hpux.rb +25 -0
  288. data/spec/unit/provider/user/ldap.rb +279 -0
  289. data/spec/unit/provider/user/user_role_add.rb +249 -0
  290. data/spec/unit/provider/user/useradd.rb +115 -0
  291. data/spec/unit/provider/zfs/solaris.rb +87 -0
  292. data/spec/unit/provider/zone/solaris.rb +42 -0
  293. data/spec/unit/provider/zpool/solaris.rb +179 -0
  294. data/spec/unit/rails.rb +125 -0
  295. data/spec/unit/relationship.rb +149 -0
  296. data/spec/unit/reports.rb +61 -0
  297. data/spec/unit/resource_reference.rb +73 -0
  298. data/spec/unit/simple_graph.rb +280 -0
  299. data/spec/unit/transaction/change.rb +187 -0
  300. data/spec/unit/transaction/event.rb +25 -0
  301. data/spec/unit/transaction/report.rb +40 -0
  302. data/spec/unit/type.rb +64 -0
  303. data/spec/unit/type/augeas.rb +113 -0
  304. data/spec/unit/type/computer.rb +82 -0
  305. data/spec/unit/type/exec.rb +91 -0
  306. data/spec/unit/type/file.rb +155 -0
  307. data/spec/unit/type/file/ensure.rb +21 -0
  308. data/spec/unit/type/file/group.rb +118 -0
  309. data/spec/unit/type/file/owner.rb +132 -0
  310. data/spec/unit/type/file/selinux.rb +82 -0
  311. data/spec/unit/type/group.rb +40 -0
  312. data/spec/unit/type/macauthorization.rb +78 -0
  313. data/spec/unit/type/mcx.rb +108 -0
  314. data/spec/unit/type/mount.rb +219 -0
  315. data/spec/unit/type/nagios.rb +63 -0
  316. data/spec/unit/type/noop_metaparam.rb +38 -0
  317. data/spec/unit/type/package.rb +246 -0
  318. data/spec/unit/type/resources.rb +27 -0
  319. data/spec/unit/type/schedule.rb +339 -0
  320. data/spec/unit/type/selboolean.rb +47 -0
  321. data/spec/unit/type/selmodule.rb +18 -0
  322. data/spec/unit/type/service.rb +254 -0
  323. data/spec/unit/type/ssh_authorized_key.rb +106 -0
  324. data/spec/unit/type/tidy.rb +68 -0
  325. data/spec/unit/type/user.rb +260 -0
  326. data/spec/unit/type/zfs.rb +45 -0
  327. data/spec/unit/type/zone.rb +20 -0
  328. data/spec/unit/type/zpool.rb +110 -0
  329. data/spec/unit/util/checksums.rb +99 -0
  330. data/spec/unit/util/constant_inflector.rb +70 -0
  331. data/spec/unit/util/file_locking.rb +115 -0
  332. data/spec/unit/util/ldap/connection.rb +169 -0
  333. data/spec/unit/util/ldap/generator.rb +54 -0
  334. data/spec/unit/util/ldap/manager.rb +654 -0
  335. data/spec/unit/util/loadedfile.rb +65 -0
  336. data/spec/unit/util/log.rb +107 -0
  337. data/spec/unit/util/metric.rb +95 -0
  338. data/spec/unit/util/nagios_maker.rb +128 -0
  339. data/spec/unit/util/posix.rb +256 -0
  340. data/spec/unit/util/resource_template.rb +58 -0
  341. data/spec/unit/util/selinux.rb +219 -0
  342. data/spec/unit/util/settings.rb +847 -0
  343. data/spec/unit/util/storage.rb +248 -0
  344. data/spec/unit/util/tagging.rb +92 -0
  345. data/spec/unit/util/uri_helper.rb +41 -0
  346. data/spec/unit/util/user_attr.rb +47 -0
  347. data/spec/unit/util/warnings.rb +35 -0
  348. data/test/certmgr/support.rb +0 -6
  349. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
  350. data/test/data/snippets/multilinecomments.pp +6 -0
  351. data/test/data/snippets/multipleclass.pp +9 -0
  352. data/test/language/functions.rb +11 -1
  353. data/test/language/snippets.rb +16 -0
  354. data/test/lib/puppettest/runnable_test.rb +1 -1
  355. data/test/network/handler/fileserver.rb +5 -0
  356. data/test/other/report.rb +0 -4
  357. data/test/ral/type/resources.rb +2 -19
  358. data/test/util/settings.rb +4 -4
  359. data/test/util/storage.rb +0 -24
  360. data/test/util/utiltest.rb +0 -33
  361. metadata +319 -26
  362. data/conf/debian/README.source +0 -2
  363. data/conf/debian/TODO.Debian +0 -1
  364. data/conf/debian/changelog +0 -257
  365. data/conf/debian/compat +0 -1
  366. data/conf/debian/control +0 -45
  367. data/conf/debian/copyright +0 -17
  368. data/conf/debian/docs +0 -1
  369. data/conf/debian/fileserver.conf +0 -12
  370. data/conf/debian/puppet.NEWS +0 -63
  371. data/conf/debian/puppet.conf +0 -8
  372. data/conf/debian/puppet.dirs +0 -7
  373. data/conf/debian/puppet.files +0 -6
  374. data/conf/debian/puppet.init +0 -64
  375. data/conf/debian/puppet.logrotate +0 -11
  376. data/conf/debian/puppet.postinst +0 -9
  377. data/conf/debian/puppet.postrm +0 -21
  378. data/conf/debian/puppet.preinst +0 -25
  379. data/conf/debian/puppetmaster.files +0 -4
  380. data/conf/debian/puppetmaster.init +0 -58
  381. data/conf/debian/rules +0 -115
  382. data/conf/debian/watch +0 -2
  383. data/lib/puppet/type/nagios_hostgroupescalation.rb +0 -3
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Puppet::Module, " when building its search path" do
6
+ include PuppetTest
7
+
8
+ it "should fully qualify unqualified paths in the search path" do
9
+ Puppet[:modulepath] = "something:/my/something"
10
+ File.stubs(:directory?).returns(true)
11
+ Puppet::Module.modulepath.should == [File.join(Dir.getwd, 'something'), "/my/something"]
12
+ end
13
+
14
+ it "should ignore paths that do not exist" do
15
+ Puppet[:modulepath] = "/yes:/no"
16
+ File.expects(:directory?).with("/yes").returns(true)
17
+ File.expects(:directory?).with("/no").returns(false)
18
+ Puppet::Module.modulepath.should == %w{/yes}
19
+ end
20
+
21
+ it "should prepend PUPPETLIB in search path when set" do
22
+ Puppet[:modulepath] = "/my/mod:/other/mod"
23
+ ENV["PUPPETLIB"] = "/env/mod:/myenv/mod"
24
+ File.stubs(:directory?).returns(true)
25
+ Puppet::Module.modulepath.should == %w{/env/mod /myenv/mod /my/mod /other/mod}
26
+ end
27
+
28
+ it "should use the environment-specific search path when a node environment is provided" do
29
+ Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/mone:/mtwo")
30
+ File.stubs(:directory?).returns(true)
31
+ Puppet::Module.modulepath("myenv").should == %w{/mone /mtwo}
32
+ end
33
+
34
+ after do
35
+ ENV["PUPPETLIB"] = nil
36
+ end
37
+ end
38
+
39
+ describe Puppet::Module, " when searching for modules" do
40
+ it "should find modules in the search path" do
41
+ path = %w{/dir/path}
42
+ Puppet::Module.stubs(:modulepath).returns(path)
43
+ File.stubs(:directory?).returns(true)
44
+ mod = Puppet::Module.find("mymod")
45
+ mod.should be_an_instance_of(Puppet::Module)
46
+ mod.path.should == "/dir/path/mymod"
47
+ end
48
+
49
+ it "should not search for fully qualified modules" do
50
+ path = %w{/dir/path}
51
+ Puppet::Module.expects(:modulepath).never
52
+ File.expects(:directory?).never
53
+ Puppet::Module.find("/mymod").should be_nil
54
+ end
55
+
56
+ it "should search for modules in the order specified in the search path" do
57
+ Puppet[:modulepath] = "/one:/two:/three"
58
+ Puppet::Module.stubs(:modulepath).returns %w{/one /two /three}
59
+ File.expects(:directory?).with("/one/mod").returns(false)
60
+ File.expects(:directory?).with("/two/mod").returns(true)
61
+ File.expects(:directory?).with("/three/mod").never
62
+ mod = Puppet::Module.find("mod")
63
+ mod.path.should == "/two/mod"
64
+ end
65
+
66
+ it "should use a node environment if specified" do
67
+ Puppet::Module.expects(:modulepath).with("myenv").returns([])
68
+ Puppet::Module.find("mymod", "myenv")
69
+ end
70
+ end
71
+
72
+ describe Puppet::Module, " when searching for templates" do
73
+ it "should return fully-qualified templates directly" do
74
+ Puppet::Module.expects(:modulepath).never
75
+ Puppet::Module.find_template("/my/template").should == "/my/template"
76
+ end
77
+
78
+ it "should return the template from the first found module" do
79
+ Puppet[:modulepath] = "/one:/two"
80
+ File.stubs(:directory?).returns(true)
81
+ Puppet::Module.find_template("mymod/mytemplate").should == "/one/mymod/templates/mytemplate"
82
+ end
83
+
84
+ it "should return the file in the templatedir if it exists" do
85
+ Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
86
+ Puppet[:modulepath] = "/one:/two"
87
+ File.stubs(:directory?).returns(true)
88
+ File.stubs(:exists?).returns(true)
89
+ Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate"
90
+ end
91
+
92
+ it "should raise an error if no valid templatedir exists" do
93
+ Puppet::Module.stubs(:templatepath).with(nil).returns(nil)
94
+ lambda { Puppet::Module.find_template("mytemplate") }.should raise_error
95
+ end
96
+
97
+ it "should not raise an error if no valid templatedir exists and the template exists in a module" do
98
+ Puppet::Module.stubs(:templatepath).with(nil).returns(nil)
99
+ Puppet[:modulepath] = "/one:/two"
100
+ File.stubs(:directory?).returns(true)
101
+ File.stubs(:exists?).returns(true)
102
+ Puppet::Module.find_template("mymod/mytemplate").should == "/one/mymod/templates/mytemplate"
103
+ end
104
+
105
+ it "should use the main templatedir if no module is found" do
106
+ Puppet::Module.stubs(:templatepath).with(nil).returns(["/my/templates"])
107
+ Puppet::Module.expects(:find).with("mymod", nil).returns(nil)
108
+ Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate"
109
+ end
110
+
111
+ it "should return unqualified templates directly in the template dir" do
112
+ Puppet::Module.stubs(:templatepath).with(nil).returns(["/my/templates"])
113
+ Puppet::Module.expects(:find).never
114
+ Puppet::Module.find_template("mytemplate").should == "/my/templates/mytemplate"
115
+ end
116
+
117
+ it "should accept relative templatedirs" do
118
+ Puppet[:templatedir] = "my/templates"
119
+ File.expects(:directory?).with(File.join(Dir.getwd,"my/templates")).returns(true)
120
+ Puppet::Module.find_template("mytemplate").should == File.join(Dir.getwd,"my/templates/mytemplate")
121
+ end
122
+
123
+ it "should use the environment templatedir if no module is found and an environment is specified" do
124
+ Puppet::Module.stubs(:templatepath).with("myenv").returns(["/myenv/templates"])
125
+ Puppet::Module.expects(:find).with("mymod", "myenv").returns(nil)
126
+ Puppet::Module.find_template("mymod/mytemplate", "myenv").should == "/myenv/templates/mymod/mytemplate"
127
+ end
128
+
129
+ it "should use first dir from environment templatedir if no module is found and an environment is specified" do
130
+ Puppet::Module.stubs(:templatepath).with("myenv").returns(["/myenv/templates", "/two/templates"])
131
+ Puppet::Module.expects(:find).with("mymod", "myenv").returns(nil)
132
+ Puppet::Module.find_template("mymod/mytemplate", "myenv").should == "/myenv/templates/mymod/mytemplate"
133
+ end
134
+
135
+ it "should use a valid dir when templatedir is a path for unqualified templates and the first dir contains template" do
136
+ Puppet::Module.stubs(:templatepath).returns(["/one/templates", "/two/templates"])
137
+ File.expects(:exists?).with("/one/templates/mytemplate").returns(true)
138
+ Puppet::Module.expects(:find).never
139
+ Puppet::Module.find_template("mytemplate").should == "/one/templates/mytemplate"
140
+ end
141
+
142
+ it "should use a valid dir when templatedir is a path for unqualified templates and only second dir contains template" do
143
+ Puppet::Module.stubs(:templatepath).returns(["/one/templates", "/two/templates"])
144
+ File.expects(:exists?).with("/one/templates/mytemplate").returns(false)
145
+ File.expects(:exists?).with("/two/templates/mytemplate").returns(true)
146
+ Puppet::Module.expects(:find).never
147
+ Puppet::Module.find_template("mytemplate").should == "/two/templates/mytemplate"
148
+ end
149
+
150
+ it "should use the node environment if specified" do
151
+ Puppet.settings.stubs(:value).returns.returns("/my/directory")
152
+ Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/modules")
153
+ File.stubs(:directory?).returns(true)
154
+ Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/modules/mymod/templates/envtemplate"
155
+ end
156
+
157
+ after { Puppet.settings.clear }
158
+ end
159
+
160
+ describe Puppet::Module, " when searching for manifests when no module is found" do
161
+ before do
162
+ File.stubs(:find).returns(nil)
163
+ end
164
+
165
+ it "should not look for modules when paths are fully qualified" do
166
+ Puppet.expects(:value).with(:modulepath).never
167
+ file = "/fully/qualified/file.pp"
168
+ Dir.stubs(:glob).with(file).returns([file])
169
+ Puppet::Module.find_manifests(file)
170
+ end
171
+
172
+ it "should directly return fully qualified files" do
173
+ file = "/fully/qualified/file.pp"
174
+ Dir.stubs(:glob).with(file).returns([file])
175
+ Puppet::Module.find_manifests(file).should == [file]
176
+ end
177
+
178
+ it "should match against provided fully qualified patterns" do
179
+ pattern = "/fully/qualified/pattern/*"
180
+ Dir.expects(:glob).with(pattern).returns(%w{my file list})
181
+ Puppet::Module.find_manifests(pattern).should == %w{my file list}
182
+ end
183
+
184
+ it "should look for files relative to the current directory" do
185
+ cwd = Dir.getwd
186
+ Dir.expects(:glob).with("#{cwd}/foobar/init.pp").returns(["#{cwd}/foobar/init.pp"])
187
+ Puppet::Module.find_manifests("foobar/init.pp").should == ["#{cwd}/foobar/init.pp"]
188
+ end
189
+
190
+ it "should only return files, not directories" do
191
+ pattern = "/fully/qualified/pattern/*"
192
+ file = "/my/file"
193
+ dir = "/my/directory"
194
+ Dir.expects(:glob).with(pattern).returns([file, dir])
195
+ FileTest.expects(:directory?).with(file).returns(false)
196
+ FileTest.expects(:directory?).with(dir).returns(true)
197
+ Puppet::Module.find_manifests(pattern).should == [file]
198
+ end
199
+ end
200
+
201
+ describe Puppet::Module, " when searching for manifests in a found module" do
202
+ it "should return the manifests from the first found module" do
203
+ Puppet[:modulepath] = "/one:/two"
204
+ File.stubs(:directory?).returns(true)
205
+ Dir.expects(:glob).with("/one/mymod/manifests/init.pp").returns(%w{/one/mymod/manifests/init.pp})
206
+ Puppet::Module.find_manifests("mymod/init.pp").should == ["/one/mymod/manifests/init.pp"]
207
+ end
208
+
209
+ it "should use the node environment if specified" do
210
+ Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/env/modules")
211
+ File.stubs(:directory?).returns(true)
212
+ Dir.expects(:glob).with("/env/modules/mymod/manifests/envmanifest.pp").returns(%w{/env/modules/mymod/manifests/envmanifest.pp})
213
+ Puppet::Module.find_manifests("mymod/envmanifest.pp", :environment => "myenv").should == ["/env/modules/mymod/manifests/envmanifest.pp"]
214
+ end
215
+
216
+ it "should return all manifests matching the glob pattern" do
217
+ Puppet.settings.expects(:value).with(:modulepath, nil).returns("/my/modules")
218
+ File.stubs(:directory?).returns(true)
219
+ Dir.expects(:glob).with("/my/modules/mymod/manifests/yay/*.pp").returns(%w{/one /two})
220
+ Puppet::Module.find_manifests("mymod/yay/*.pp").should == %w{/one /two}
221
+ end
222
+
223
+ it "should not return directories" do
224
+ Puppet.settings.expects(:value).with(:modulepath, nil).returns("/my/modules")
225
+ File.stubs(:directory?).returns(true)
226
+ Dir.expects(:glob).with("/my/modules/mymod/manifests/yay/*.pp").returns(%w{/one /two})
227
+ FileTest.expects(:directory?).with("/one").returns false
228
+ FileTest.expects(:directory?).with("/two").returns true
229
+ Puppet::Module.find_manifests("mymod/yay/*.pp").should == %w{/one}
230
+ end
231
+
232
+ it "should default to the 'init.pp' file in the manifests directory" do
233
+ Puppet.settings.expects(:value).with(:modulepath, nil).returns("/my/modules")
234
+ File.stubs(:directory?).returns(true)
235
+ Dir.expects(:glob).with("/my/modules/mymod/manifests/init.pp").returns(%w{my manifest})
236
+ Puppet::Module.find_manifests("mymod").should == %w{my manifest}
237
+ end
238
+
239
+ after { Puppet.settings.clear }
240
+ end
241
+
242
+ describe Puppet::Module, " when returning files" do
243
+ it "should return the path to the module's 'files' directory" do
244
+ mod = Puppet::Module.send(:new, "mymod", "/my/mod")
245
+ mod.files.should == "/my/mod/files"
246
+ end
247
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Luke Kanies on 2008-3-24.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ require File.dirname(__FILE__) + '/../../spec_helper'
7
+
8
+ require 'puppet/network/client'
9
+
10
+ describe Puppet::Network::Client do
11
+ before do
12
+ Puppet.settings.stubs(:use).returns(true)
13
+ Puppet::Network::HttpPool.stubs(:cert_setup)
14
+ end
15
+
16
+ describe "when keep-alive is enabled" do
17
+ before do
18
+ Puppet::Network::HttpPool.stubs(:keep_alive?).returns true
19
+ end
20
+ it "should start the http client up on creation" do
21
+ http = mock 'http'
22
+ http.stub_everything
23
+ http.expects(:start)
24
+ Net::HTTP.stubs(:new).returns http
25
+
26
+ # Pick a random subclass...
27
+ Puppet::Network::Client.master.new :Server => Puppet[:server]
28
+ end
29
+ end
30
+
31
+ describe "when keep-alive is disabled" do
32
+ before do
33
+ Puppet::Network::HttpPool.stubs(:keep_alive?).returns false
34
+ end
35
+ it "should not start the http client up on creation" do
36
+ http = mock 'http'
37
+ http.stub_everything
38
+ http.expects(:start).never
39
+ Net::HTTP.stubs(:new).returns http
40
+
41
+ # Pick a random subclass...
42
+ Puppet::Network::Client.master.new :Server => Puppet[:server]
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,442 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Luke Kanies on 2007-11-12.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require File.dirname(__FILE__) + '/../../../spec_helper'
7
+ require 'puppet/network/client/master'
8
+
9
+ describe Puppet::Network::Client::Master, " when retrieving the catalog" do
10
+ before do
11
+ Puppet.settings.stubs(:use).returns(true)
12
+ @master = mock 'master'
13
+ @client = Puppet::Network::Client.master.new(
14
+ :Master => @master
15
+ )
16
+ @facts = {"one" => "two", "three" => "four"}
17
+ end
18
+
19
+ it "should initialize the metadata store" do
20
+ @client.class.stubs(:facts).returns(@facts)
21
+ @client.expects(:dostorage)
22
+ @master.stubs(:getconfig).returns(nil)
23
+ @client.getconfig
24
+ end
25
+
26
+ it "should collect facts to use for catalog retrieval" do
27
+ @client.stubs(:dostorage)
28
+ @client.class.expects(:facts).returns(@facts)
29
+ @master.stubs(:getconfig).returns(nil)
30
+ @client.getconfig
31
+ end
32
+
33
+ it "should fail if no facts could be collected" do
34
+ @client.stubs(:dostorage)
35
+ @client.class.expects(:facts).returns({})
36
+ @master.stubs(:getconfig).returns(nil)
37
+ proc { @client.getconfig }.should raise_error(Puppet::Network::ClientError)
38
+ end
39
+
40
+ it "should retrieve plugins if :pluginsync is enabled" do
41
+ file = "/path/to/cachefile"
42
+ @client.stubs(:cachefile).returns(file)
43
+ @client.stubs(:dostorage)
44
+ @client.class.stubs(:facts).returns(@facts)
45
+ Puppet.settings.expects(:value).with(:pluginsync).returns(true)
46
+ @client.expects(:getplugins)
47
+ @client.stubs(:get_actual_config).returns(nil)
48
+ FileTest.stubs(:exist?).with(file).returns(true)
49
+ @client.stubs(:use_cached_config).returns(true)
50
+ @client.class.stubs(:facts).returns(@facts)
51
+ @client.getconfig
52
+ end
53
+
54
+ it "should use the cached catalog if no catalog could be retrieved" do
55
+ @client.stubs(:dostorage)
56
+ @client.class.stubs(:facts).returns(@facts)
57
+ @master.stubs(:getconfig).raises(ArgumentError.new("whev"))
58
+ @client.expects(:use_cached_config).with(true)
59
+ @client.getconfig
60
+ end
61
+
62
+ describe "when the catalog format is set to yaml" do
63
+ before do
64
+ Puppet.settings.stubs(:value).returns "foo"
65
+ Puppet.settings.stubs(:value).with(:pluginsync).returns false
66
+ Puppet.settings.stubs(:value).with(:configtimeout).returns 10
67
+ Puppet.settings.stubs(:value).with(:factsync).returns false
68
+ Puppet.settings.stubs(:value).with(:catalog_format).returns "yaml"
69
+ end
70
+
71
+ it "should request a yaml-encoded catalog" do
72
+ @client.stubs(:dostorage)
73
+ @client.class.stubs(:facts).returns(@facts)
74
+ @master.expects(:getconfig).with { |*args| args[1] == "yaml" }
75
+
76
+ @client.getconfig
77
+ end
78
+
79
+ it "should load the retrieved catalog using YAML" do
80
+ @client.stubs(:dostorage)
81
+ @client.class.stubs(:facts).returns(@facts)
82
+ @master.stubs(:getconfig).returns("myconfig")
83
+
84
+ config = mock 'config'
85
+ YAML.expects(:load).with("myconfig").returns(config)
86
+
87
+ @client.stubs(:setclasses)
88
+
89
+ config.stubs(:classes)
90
+ config.stubs(:to_catalog).returns(config)
91
+ config.stubs(:host_config=)
92
+ config.stubs(:from_cache).returns(true)
93
+
94
+ @client.getconfig
95
+ end
96
+
97
+ it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do
98
+ @client.stubs(:dostorage)
99
+ @client.class.stubs(:facts).returns(@facts)
100
+ @master.stubs(:getconfig).returns("myconfig")
101
+
102
+ YAML.expects(:load).with("myconfig").raises(ArgumentError)
103
+
104
+ @client.expects(:use_cached_config).with(true)
105
+
106
+ @client.getconfig
107
+ end
108
+ end
109
+
110
+ describe "from Marshal" do
111
+ before do
112
+ Puppet.settings.stubs(:value).returns "foo"
113
+ Puppet.settings.stubs(:value).with(:pluginsync).returns false
114
+ Puppet.settings.stubs(:value).with(:configtimeout).returns 10
115
+ Puppet.settings.stubs(:value).with(:factsync).returns false
116
+ Puppet.settings.stubs(:value).with(:catalog_format).returns "marshal"
117
+ end
118
+
119
+ it "should load the retrieved catalog using Marshal" do
120
+ @client.stubs(:dostorage)
121
+ @client.class.stubs(:facts).returns(@facts)
122
+ @master.stubs(:getconfig).returns("myconfig")
123
+
124
+ config = mock 'config'
125
+ Marshal.expects(:load).with("myconfig").returns(config)
126
+
127
+ @client.stubs(:setclasses)
128
+
129
+ config.stubs(:classes)
130
+ config.stubs(:to_catalog).returns(config)
131
+ config.stubs(:host_config=)
132
+ config.stubs(:from_cache).returns(true)
133
+
134
+ @client.getconfig
135
+ end
136
+
137
+ it "should use the cached catalog if the retrieved catalog cannot be converted from Marshal" do
138
+ @client.stubs(:dostorage)
139
+ @client.class.stubs(:facts).returns(@facts)
140
+ @master.stubs(:getconfig).returns("myconfig")
141
+
142
+ Marshal.expects(:load).with("myconfig").raises(ArgumentError)
143
+
144
+ @client.expects(:use_cached_config).with(true)
145
+
146
+ @client.getconfig
147
+ end
148
+ end
149
+
150
+ it "should set the classes.txt file with the classes listed in the retrieved catalog" do
151
+ @client.stubs(:dostorage)
152
+ @client.class.stubs(:facts).returns(@facts)
153
+ @master.stubs(:getconfig).returns("myconfig")
154
+
155
+ config = mock 'config'
156
+ YAML.expects(:load).with("myconfig").returns(config)
157
+
158
+ config.expects(:classes).returns(:myclasses)
159
+ @client.expects(:setclasses).with(:myclasses)
160
+
161
+ config.stubs(:to_catalog).returns(config)
162
+ config.stubs(:host_config=)
163
+ config.stubs(:from_cache).returns(true)
164
+
165
+ @client.getconfig
166
+ end
167
+
168
+ it "should convert the retrieved catalog to a RAL catalog" do
169
+ @client.stubs(:dostorage)
170
+ @client.class.stubs(:facts).returns(@facts)
171
+ @master.stubs(:getconfig).returns("myconfig")
172
+
173
+ yamlconfig = mock 'yaml config'
174
+ YAML.stubs(:load).returns(yamlconfig)
175
+
176
+ @client.stubs(:setclasses)
177
+
178
+ config = mock 'config'
179
+
180
+ yamlconfig.stubs(:classes)
181
+ yamlconfig.expects(:to_catalog).returns(config)
182
+
183
+ config.stubs(:host_config=)
184
+ config.stubs(:from_cache).returns(true)
185
+
186
+ @client.getconfig
187
+ end
188
+
189
+ it "should use the cached catalog if the retrieved catalog cannot be converted to a RAL catalog" do
190
+ @client.stubs(:dostorage)
191
+ @client.class.stubs(:facts).returns(@facts)
192
+ @master.stubs(:getconfig).returns("myconfig")
193
+
194
+ yamlconfig = mock 'yaml config'
195
+ YAML.stubs(:load).returns(yamlconfig)
196
+
197
+ @client.stubs(:setclasses)
198
+
199
+ config = mock 'config'
200
+
201
+ yamlconfig.stubs(:classes)
202
+ yamlconfig.expects(:to_catalog).raises(ArgumentError)
203
+
204
+ @client.expects(:use_cached_config).with(true)
205
+
206
+ @client.getconfig
207
+ end
208
+
209
+ it "should clear the failed catalog if using the cached catalog after failing to instantiate the retrieved catalog" do
210
+ @client.stubs(:dostorage)
211
+ @client.class.stubs(:facts).returns(@facts)
212
+ @master.stubs(:getconfig).returns("myconfig")
213
+
214
+ yamlconfig = mock 'yaml config'
215
+ YAML.stubs(:load).returns(yamlconfig)
216
+
217
+ @client.stubs(:setclasses)
218
+
219
+ config = mock 'config'
220
+
221
+ yamlconfig.stubs(:classes)
222
+ yamlconfig.stubs(:to_catalog).raises(ArgumentError)
223
+
224
+ @client.stubs(:use_cached_config).with(true)
225
+
226
+ @client.expects(:clear)
227
+
228
+ @client.getconfig
229
+ end
230
+
231
+ it "should cache the retrieved yaml catalog if it is not from the cache and is valid" do
232
+ @client.stubs(:dostorage)
233
+ @client.class.stubs(:facts).returns(@facts)
234
+ @master.stubs(:getconfig).returns("myconfig")
235
+
236
+ yamlconfig = mock 'yaml config'
237
+ YAML.stubs(:load).returns(yamlconfig)
238
+
239
+ @client.stubs(:setclasses)
240
+
241
+ config = mock 'config'
242
+
243
+ yamlconfig.stubs(:classes)
244
+ yamlconfig.expects(:to_catalog).returns(config)
245
+
246
+ config.stubs(:host_config=)
247
+
248
+ config.expects(:from_cache).returns(false)
249
+
250
+ @client.expects(:cache).with("myconfig")
251
+
252
+ @client.getconfig
253
+ end
254
+
255
+ it "should mark the catalog as a host catalog" do
256
+ @client.stubs(:dostorage)
257
+ @client.class.stubs(:facts).returns(@facts)
258
+ @master.stubs(:getconfig).returns("myconfig")
259
+
260
+ yamlconfig = mock 'yaml config'
261
+ YAML.stubs(:load).returns(yamlconfig)
262
+
263
+ @client.stubs(:setclasses)
264
+
265
+ config = mock 'config'
266
+
267
+ yamlconfig.stubs(:classes)
268
+ yamlconfig.expects(:to_catalog).returns(config)
269
+
270
+ config.stubs(:from_cache).returns(true)
271
+
272
+ config.expects(:host_config=).with(true)
273
+
274
+ @client.getconfig
275
+ end
276
+ end
277
+
278
+ describe Puppet::Network::Client::Master, " when using the cached catalog" do
279
+ before do
280
+ Puppet.settings.stubs(:use).returns(true)
281
+ @master = mock 'master'
282
+ @client = Puppet::Network::Client.master.new(
283
+ :Master => @master
284
+ )
285
+ @facts = {"one" => "two", "three" => "four"}
286
+ end
287
+
288
+ it "should return do nothing and true if there is already an in-memory catalog" do
289
+ @client.catalog = :whatever
290
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
291
+ @client.use_cached_config.should be_true
292
+ end
293
+ end
294
+
295
+ it "should return do nothing and false if it has been told there is a failure and :nocacheonfailure is enabled" do
296
+ Puppet.settings.expects(:value).with(:usecacheonfailure).returns(false)
297
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
298
+ @client.use_cached_config(true).should be_false
299
+ end
300
+ end
301
+
302
+ it "should return false if no cached catalog can be found" do
303
+ @client.expects(:retrievecache).returns(nil)
304
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
305
+ @client.use_cached_config().should be_false
306
+ end
307
+ end
308
+
309
+ it "should return false if the cached catalog cannot be instantiated" do
310
+ YAML.expects(:load).raises(ArgumentError)
311
+ @client.expects(:retrievecache).returns("whatever")
312
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
313
+ @client.use_cached_config().should be_false
314
+ end
315
+ end
316
+
317
+ it "should warn if the cached catalog cannot be instantiated" do
318
+ YAML.stubs(:load).raises(ArgumentError)
319
+ @client.stubs(:retrievecache).returns("whatever")
320
+ Puppet.expects(:warning).with { |m| m.include?("Could not load cache") }
321
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
322
+ @client.use_cached_config().should be_false
323
+ end
324
+ end
325
+
326
+ it "should clear the client if the cached catalog cannot be instantiated" do
327
+ YAML.stubs(:load).raises(ArgumentError)
328
+ @client.stubs(:retrievecache).returns("whatever")
329
+ @client.expects(:clear)
330
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
331
+ @client.use_cached_config().should be_false
332
+ end
333
+ end
334
+
335
+ it "should return true if the cached catalog can be instantiated" do
336
+ config = mock 'config'
337
+ YAML.stubs(:load).returns(config)
338
+
339
+ ral_config = mock 'ral config'
340
+ ral_config.stubs(:from_cache=)
341
+ ral_config.stubs(:host_config=)
342
+ config.expects(:to_catalog).returns(ral_config)
343
+
344
+ @client.stubs(:retrievecache).returns("whatever")
345
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
346
+ @client.use_cached_config().should be_true
347
+ end
348
+ end
349
+
350
+ it "should set the catalog instance variable if the cached catalog can be instantiated" do
351
+ config = mock 'config'
352
+ YAML.stubs(:load).returns(config)
353
+
354
+ ral_config = mock 'ral config'
355
+ ral_config.stubs(:from_cache=)
356
+ ral_config.stubs(:host_config=)
357
+ config.expects(:to_catalog).returns(ral_config)
358
+
359
+ @client.stubs(:retrievecache).returns("whatever")
360
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
361
+ @client.use_cached_config()
362
+ end
363
+
364
+ @client.catalog.should equal(ral_config)
365
+ end
366
+
367
+ it "should mark the catalog as a host_config if valid" do
368
+ config = mock 'config'
369
+ YAML.stubs(:load).returns(config)
370
+
371
+ ral_config = mock 'ral config'
372
+ ral_config.stubs(:from_cache=)
373
+ ral_config.expects(:host_config=).with(true)
374
+ config.expects(:to_catalog).returns(ral_config)
375
+
376
+ @client.stubs(:retrievecache).returns("whatever")
377
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
378
+ @client.use_cached_config()
379
+ end
380
+
381
+ @client.catalog.should equal(ral_config)
382
+ end
383
+
384
+ it "should mark the catalog as from the cache if valid" do
385
+ config = mock 'config'
386
+ YAML.stubs(:load).returns(config)
387
+
388
+ ral_config = mock 'ral config'
389
+ ral_config.expects(:from_cache=).with(true)
390
+ ral_config.stubs(:host_config=)
391
+ config.expects(:to_catalog).returns(ral_config)
392
+
393
+ @client.stubs(:retrievecache).returns("whatever")
394
+ Puppet::Network::Client::Master.publicize_methods :use_cached_config do
395
+ @client.use_cached_config()
396
+ end
397
+
398
+ @client.catalog.should equal(ral_config)
399
+ end
400
+
401
+ describe "when calling splay" do
402
+ it "should do nothing if splay is not enabled" do
403
+ Puppet.stubs(:[]).with(:splay).returns(false)
404
+ @client.expects(:rand).never
405
+ @client.send(:splay)
406
+ end
407
+
408
+ describe "when splay is enabled" do
409
+ before do
410
+ Puppet.stubs(:[]).with(:splay).returns(true)
411
+ Puppet.stubs(:[]).with(:splaylimit).returns(42)
412
+ end
413
+
414
+ it "should sleep for a random time plus 1" do
415
+ @client.expects(:rand).with(43).returns(43)
416
+ @client.expects(:sleep).with(43)
417
+ @client.send(:splay)
418
+ end
419
+
420
+ it "should inform that it is splayed" do
421
+ @client.stubs(:rand).with(43).returns(43)
422
+ @client.stubs(:sleep).with(43)
423
+ Puppet.expects(:info)
424
+ @client.send(:splay)
425
+ end
426
+
427
+ it "should set splay = true" do
428
+ @client.stubs(:rand).returns(43)
429
+ @client.stubs(:sleep)
430
+ @client.send(:splay)
431
+ @client.send(:splayed?).should == true
432
+ end
433
+
434
+ it "should do nothing if already splayed" do
435
+ @client.stubs(:rand).returns(43).at_most_once
436
+ @client.stubs(:sleep).at_most_once
437
+ @client.send(:splay)
438
+ @client.send(:splay)
439
+ end
440
+ end
441
+ end
442
+ end