puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32

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 (342) hide show
  1. data/CONTRIBUTING.md +5 -0
  2. data/Gemfile +17 -9
  3. data/README.md +1 -0
  4. data/conf/fileserver.conf +4 -3
  5. data/ext/README.environment +8 -0
  6. data/ext/build_defaults.yaml +1 -1
  7. data/ext/debian/control +2 -2
  8. data/ext/debian/puppet-common.dirs +4 -0
  9. data/ext/debian/rules +4 -0
  10. data/ext/emacs/puppet-mode-init.el +1 -1
  11. data/ext/emacs/puppet-mode.el +36 -17
  12. data/ext/redhat/client.init +3 -3
  13. data/ext/redhat/puppet.spec.erb +9 -0
  14. data/ext/systemd/puppet.service +3 -4
  15. data/ext/systemd/puppetmaster.service +1 -3
  16. data/install.rb +1 -1
  17. data/lib/puppet.rb +2 -1
  18. data/lib/puppet/agent.rb +1 -1
  19. data/lib/puppet/application.rb +17 -17
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/configurer.rb +4 -1
  22. data/lib/puppet/configurer/downloader.rb +13 -12
  23. data/lib/puppet/configurer/plugin_handler.rb +3 -3
  24. data/lib/puppet/context.rb +6 -1
  25. data/lib/puppet/defaults.rb +82 -12
  26. data/lib/puppet/environments.rb +169 -13
  27. data/lib/puppet/external/nagios/grammar.ry +2 -0
  28. data/lib/puppet/external/nagios/parser.rb +28 -19
  29. data/lib/puppet/face/config.rb +19 -6
  30. data/lib/puppet/face/module/generate.rb +209 -7
  31. data/lib/puppet/face/module/install.rb +17 -16
  32. data/lib/puppet/face/module/list.rb +83 -82
  33. data/lib/puppet/face/module/search.rb +1 -1
  34. data/lib/puppet/face/module/upgrade.rb +10 -9
  35. data/lib/puppet/face/parser.rb +3 -2
  36. data/lib/puppet/face/plugin.rb +8 -4
  37. data/lib/puppet/file_bucket/dipper.rb +6 -3
  38. data/lib/puppet/file_bucket/file.rb +4 -2
  39. data/lib/puppet/file_serving/metadata.rb +1 -1
  40. data/lib/puppet/file_system/memory_file.rb +27 -1
  41. data/lib/puppet/file_system/memory_impl.rb +15 -1
  42. data/lib/puppet/forge.rb +148 -52
  43. data/lib/puppet/forge/cache.rb +5 -1
  44. data/lib/puppet/forge/errors.rb +10 -0
  45. data/lib/puppet/forge/repository.rb +61 -26
  46. data/lib/puppet/functions.rb +548 -0
  47. data/lib/puppet/functions/assert_type.rb +42 -0
  48. data/lib/puppet/functions/import.rb +7 -0
  49. data/lib/puppet/indirector/facts/facter.rb +1 -1
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  51. data/lib/puppet/indirector/rest.rb +18 -0
  52. data/lib/puppet/loaders.rb +20 -0
  53. data/lib/puppet/module.rb +2 -2
  54. data/lib/puppet/module_tool.rb +40 -14
  55. data/lib/puppet/module_tool/applications.rb +0 -1
  56. data/lib/puppet/module_tool/applications/application.rb +35 -26
  57. data/lib/puppet/module_tool/applications/builder.rb +16 -6
  58. data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
  59. data/lib/puppet/module_tool/applications/installer.rb +196 -35
  60. data/lib/puppet/module_tool/applications/searcher.rb +1 -0
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
  62. data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
  63. data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
  64. data/lib/puppet/module_tool/checksums.rb +5 -8
  65. data/lib/puppet/module_tool/errors/installer.rb +12 -44
  66. data/lib/puppet/module_tool/errors/shared.rb +84 -11
  67. data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
  68. data/lib/puppet/module_tool/install_directory.rb +7 -6
  69. data/lib/puppet/module_tool/installed_modules.rb +92 -0
  70. data/lib/puppet/module_tool/local_tarball.rb +91 -0
  71. data/lib/puppet/module_tool/metadata.rb +119 -115
  72. data/lib/puppet/module_tool/modulefile.rb +9 -9
  73. data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
  74. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
  75. data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
  76. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
  77. data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
  78. data/lib/puppet/module_tool/tar.rb +3 -7
  79. data/lib/puppet/module_tool/tar/gnu.rb +21 -9
  80. data/lib/puppet/module_tool/tar/mini.rb +2 -8
  81. data/lib/puppet/network/http/api/v1.rb +1 -1
  82. data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
  83. data/lib/puppet/network/http/issues.rb +1 -0
  84. data/lib/puppet/network/http_pool.rb +15 -6
  85. data/lib/puppet/node/environment.rb +91 -20
  86. data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
  87. data/lib/puppet/parser/collector.rb +1 -1
  88. data/lib/puppet/parser/compiler.rb +50 -7
  89. data/lib/puppet/parser/functions.rb +6 -0
  90. data/lib/puppet/parser/functions/generate.rb +1 -1
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/pops.rb +22 -1
  93. data/lib/puppet/pops/adapters.rb +8 -1
  94. data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
  95. data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
  96. data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
  97. data/lib/puppet/pops/binder/producers.rb +2 -2
  98. data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
  99. data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
  100. data/lib/puppet/pops/evaluator/closure.rb +57 -2
  101. data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
  102. data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
  103. data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
  104. data/lib/puppet/pops/functions/dispatch.rb +71 -0
  105. data/lib/puppet/pops/functions/dispatcher.rb +237 -0
  106. data/lib/puppet/pops/functions/function.rb +77 -0
  107. data/lib/puppet/pops/issues.rb +12 -0
  108. data/lib/puppet/pops/loader/base_loader.rb +102 -0
  109. data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
  110. data/lib/puppet/pops/loader/gem_support.rb +49 -0
  111. data/lib/puppet/pops/loader/loader.rb +180 -0
  112. data/lib/puppet/pops/loader/loader_paths.rb +137 -0
  113. data/lib/puppet/pops/loader/module_loaders.rb +242 -0
  114. data/lib/puppet/pops/loader/null_loader.rb +44 -0
  115. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
  116. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
  117. data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
  118. data/lib/puppet/pops/loader/static_loader.rb +69 -0
  119. data/lib/puppet/pops/loader/uri_helper.rb +22 -0
  120. data/lib/puppet/pops/loaders.rb +240 -0
  121. data/lib/puppet/pops/model/factory.rb +13 -5
  122. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
  123. data/lib/puppet/pops/parser/egrammar.ra +31 -18
  124. data/lib/puppet/pops/parser/eparser.rb +1137 -1106
  125. data/lib/puppet/pops/parser/lexer2.rb +17 -16
  126. data/lib/puppet/pops/semantic_error.rb +17 -0
  127. data/lib/puppet/pops/types/type_calculator.rb +150 -15
  128. data/lib/puppet/pops/types/type_factory.rb +69 -0
  129. data/lib/puppet/pops/types/type_parser.rb +9 -0
  130. data/lib/puppet/pops/types/types.rb +65 -4
  131. data/lib/puppet/pops/validation/checker4_0.rb +1 -1
  132. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  133. data/lib/puppet/property/list.rb +1 -1
  134. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  135. data/lib/puppet/provider/cron/crontab.rb +13 -2
  136. data/lib/puppet/provider/package.rb +24 -0
  137. data/lib/puppet/provider/package/apt.rb +6 -1
  138. data/lib/puppet/provider/package/gem.rb +8 -2
  139. data/lib/puppet/provider/package/msi.rb +0 -15
  140. data/lib/puppet/provider/package/openbsd.rb +0 -24
  141. data/lib/puppet/provider/package/rpm.rb +3 -29
  142. data/lib/puppet/provider/package/windows.rb +0 -15
  143. data/lib/puppet/provider/package/yum.rb +101 -24
  144. data/lib/puppet/provider/package/yumhelper.py +31 -1
  145. data/lib/puppet/provider/package/zypper.rb +10 -28
  146. data/lib/puppet/provider/service/debian.rb +1 -1
  147. data/lib/puppet/provider/service/init.rb +3 -0
  148. data/lib/puppet/provider/service/openbsd.rb +318 -0
  149. data/lib/puppet/provider/service/redhat.rb +6 -3
  150. data/lib/puppet/provider/service/systemd.rb +2 -2
  151. data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
  152. data/lib/puppet/resource.rb +13 -9
  153. data/lib/puppet/resource/catalog.rb +12 -6
  154. data/lib/puppet/resource/type_collection.rb +3 -3
  155. data/lib/puppet/settings.rb +57 -36
  156. data/lib/puppet/settings/config_file.rb +5 -0
  157. data/lib/puppet/settings/environment_conf.rb +147 -0
  158. data/lib/puppet/settings/ttl_setting.rb +48 -0
  159. data/lib/puppet/ssl/certificate_authority.rb +2 -3
  160. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
  161. data/lib/puppet/ssl/certificate_request.rb +4 -4
  162. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  163. data/lib/puppet/status.rb +1 -1
  164. data/lib/puppet/test/test_helper.rb +1 -0
  165. data/lib/puppet/type/augeas.rb +13 -1
  166. data/lib/puppet/type/cron.rb +32 -18
  167. data/lib/puppet/type/file.rb +4 -2
  168. data/lib/puppet/type/file/checksum.rb +15 -5
  169. data/lib/puppet/type/file/content.rb +3 -1
  170. data/lib/puppet/type/file/source.rb +5 -5
  171. data/lib/puppet/type/package.rb +12 -17
  172. data/lib/puppet/type/resources.rb +3 -1
  173. data/lib/puppet/type/scheduled_task.rb +4 -5
  174. data/lib/puppet/type/service.rb +12 -2
  175. data/lib/puppet/type/user.rb +106 -0
  176. data/lib/puppet/type/yumrepo.rb +9 -1
  177. data/lib/puppet/util/checksums.rb +60 -1
  178. data/lib/puppet/util/diff.rb +3 -1
  179. data/lib/puppet/util/execution.rb +20 -16
  180. data/lib/puppet/util/feature.rb +3 -0
  181. data/lib/puppet/util/logging.rb +19 -12
  182. data/lib/puppet/util/rubygems.rb +10 -0
  183. data/lib/puppet/util/watched_file.rb +1 -1
  184. data/lib/puppet/util/windows/security.rb +5 -3
  185. data/lib/puppet/vendor/load_semantic.rb +1 -0
  186. data/lib/puppet/vendor/require_vendored.rb +2 -0
  187. data/lib/puppet/vendor/semantic/Gemfile +20 -0
  188. data/lib/puppet/vendor/semantic/Rakefile +69 -0
  189. data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
  190. data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
  191. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
  192. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
  193. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
  194. data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
  195. data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
  196. data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
  197. data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
  198. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
  199. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
  200. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
  201. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
  202. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
  203. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
  204. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
  205. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
  206. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
  207. data/lib/puppet/version.rb +1 -1
  208. data/spec/fixtures/java.tgz +0 -0
  209. data/spec/fixtures/stdlib.tgz +0 -0
  210. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
  211. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
  212. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
  213. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
  214. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
  215. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
  216. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
  217. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
  218. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
  219. data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
  220. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
  221. data/spec/fixtures/unit/type/user/authorized_keys +5 -0
  222. data/spec/integration/application/apply_spec.rb +1 -2
  223. data/spec/integration/configurer_spec.rb +2 -2
  224. data/spec/integration/faces/plugin_spec.rb +62 -0
  225. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
  226. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  227. data/spec/integration/node/environment_spec.rb +2 -2
  228. data/spec/integration/parser/future_compiler_spec.rb +96 -142
  229. data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
  230. data/spec/integration/provider/cron/crontab_spec.rb +35 -0
  231. data/spec/integration/type/file_spec.rb +74 -72
  232. data/spec/integration/util/windows/security_spec.rb +17 -0
  233. data/spec/lib/matchers/resource.rb +45 -13
  234. data/spec/lib/puppet_spec/files.rb +18 -0
  235. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
  236. data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
  237. data/spec/shared_contexts/checksums.rb +55 -0
  238. data/spec/unit/application/apply_spec.rb +10 -7
  239. data/spec/unit/application/doc_spec.rb +17 -10
  240. data/spec/unit/application/indirection_base_spec.rb +18 -10
  241. data/spec/unit/application/inspect_spec.rb +22 -20
  242. data/spec/unit/configurer/downloader_spec.rb +7 -6
  243. data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
  244. data/spec/unit/configurer_spec.rb +1 -1
  245. data/spec/unit/context_spec.rb +23 -0
  246. data/spec/unit/environments_spec.rb +274 -16
  247. data/spec/unit/face/config_spec.rb +111 -11
  248. data/spec/unit/face/module/install_spec.rb +14 -85
  249. data/spec/unit/face/module/list_spec.rb +108 -62
  250. data/spec/unit/face/module/search_spec.rb +1 -1
  251. data/spec/unit/face/module/uninstall_spec.rb +21 -42
  252. data/spec/unit/face/parser_spec.rb +5 -2
  253. data/spec/unit/file_bucket/dipper_spec.rb +92 -86
  254. data/spec/unit/file_bucket/file_spec.rb +23 -75
  255. data/spec/unit/file_serving/metadata_spec.rb +74 -74
  256. data/spec/unit/forge/module_release_spec.rb +131 -0
  257. data/spec/unit/forge/repository_spec.rb +21 -20
  258. data/spec/unit/forge_spec.rb +99 -23
  259. data/spec/unit/functions/assert_type_spec.rb +59 -0
  260. data/spec/unit/functions4_spec.rb +671 -0
  261. data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
  262. data/spec/unit/indirector/facts/facter_spec.rb +9 -3
  263. data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
  264. data/spec/unit/indirector/rest_spec.rb +8 -0
  265. data/spec/unit/interface/face_collection_spec.rb +35 -23
  266. data/spec/unit/module_spec.rb +20 -8
  267. data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
  268. data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
  269. data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
  270. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
  271. data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
  272. data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
  273. data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
  274. data/spec/unit/module_tool/metadata_spec.rb +223 -14
  275. data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
  276. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  277. data/spec/unit/module_tool/tar_spec.rb +4 -18
  278. data/spec/unit/module_tool_spec.rb +123 -27
  279. data/spec/unit/network/formats_spec.rb +2 -2
  280. data/spec/unit/network/http_pool_spec.rb +21 -0
  281. data/spec/unit/network/rights_spec.rb +10 -8
  282. data/spec/unit/node/environment_spec.rb +27 -2
  283. data/spec/unit/parser/collector_spec.rb +1 -1
  284. data/spec/unit/parser/compiler_spec.rb +1 -1
  285. data/spec/unit/parser/functions/generate_spec.rb +4 -0
  286. data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
  287. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
  288. data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
  289. data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
  290. data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
  291. data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
  292. data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
  293. data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
  294. data/spec/unit/pops/types/type_factory_spec.rb +101 -0
  295. data/spec/unit/pops/types/type_parser_spec.rb +22 -0
  296. data/spec/unit/property/list_spec.rb +9 -1
  297. data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
  298. data/spec/unit/provider/cron/crontab_spec.rb +1 -0
  299. data/spec/unit/provider/cron/parsed_spec.rb +15 -0
  300. data/spec/unit/provider/naginator_spec.rb +14 -0
  301. data/spec/unit/provider/package/apt_spec.rb +78 -64
  302. data/spec/unit/provider/package/gem_spec.rb +15 -0
  303. data/spec/unit/provider/package/rpm_spec.rb +6 -6
  304. data/spec/unit/provider/package/windows_spec.rb +1 -1
  305. data/spec/unit/provider/package/yum_spec.rb +199 -104
  306. data/spec/unit/provider/package/zypper_spec.rb +41 -15
  307. data/spec/unit/provider/service/openbsd_spec.rb +129 -22
  308. data/spec/unit/provider/service/redhat_spec.rb +18 -4
  309. data/spec/unit/provider/service/systemd_spec.rb +5 -9
  310. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  311. data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
  312. data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
  313. data/spec/unit/resource/catalog_spec.rb +20 -104
  314. data/spec/unit/resource/type_collection_spec.rb +10 -9
  315. data/spec/unit/settings/config_file_spec.rb +29 -6
  316. data/spec/unit/settings/environment_conf_spec.rb +51 -0
  317. data/spec/unit/settings_spec.rb +97 -12
  318. data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
  319. data/spec/unit/type/augeas_spec.rb +1 -1
  320. data/spec/unit/type/cron_spec.rb +6 -7
  321. data/spec/unit/type/file/checksum_spec.rb +6 -0
  322. data/spec/unit/type/file/content_spec.rb +277 -207
  323. data/spec/unit/type/file_spec.rb +9 -7
  324. data/spec/unit/type/user_spec.rb +106 -18
  325. data/spec/unit/type/yumrepo_spec.rb +8 -0
  326. data/spec/unit/util/checksums_spec.rb +12 -5
  327. data/spec/unit/util/diff_spec.rb +8 -0
  328. data/spec/unit/util/execution_spec.rb +4 -4
  329. data/spec/unit/util/feature_spec.rb +2 -0
  330. data/spec/unit/util/logging_spec.rb +14 -4
  331. data/spec/unit/util/rdoc/parser_spec.rb +5 -4
  332. data/spec/unit/util/rubygems_spec.rb +14 -0
  333. data/tasks/parallel.rake +2 -2
  334. metadata +154 -21
  335. checksums.yaml +0 -7
  336. data/lib/puppet/module_tool/applications/generator.rb +0 -142
  337. data/lib/puppet/module_tool/skeleton.rb +0 -37
  338. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
  339. data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
  340. data/lib/puppet/module_tool/tar/solaris.rb +0 -5
  341. data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
  342. data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -5,32 +5,44 @@ require 'tmpdir'
5
5
  require 'puppet/interface'
6
6
 
7
7
  describe Puppet::Interface::FaceCollection do
8
- # To avoid cross-pollution we have to save and restore both the hash
9
- # containing all the interface data, and the array used by require. Restoring
10
- # both means that we don't leak side-effects across the code. --daniel 2011-04-06
11
- #
12
- # Worse luck, we *also* need to flush $" of anything defining a face,
13
- # because otherwise we can cross-pollute from other test files and end up
14
- # with no faces loaded, but the require value set true. --daniel 2011-04-10
15
- before :each do
16
- @original_faces = subject.instance_variable_get("@faces").dup
17
- @original_required = $".dup
18
- $".delete_if do |path| path =~ %r{/face/.*\.rb$} end
19
- subject.instance_variable_get(:@faces).clear
20
- subject.instance_variable_set(:@loaded, false)
21
- @autoload_loaded = {}
22
- Puppet::Util::Autoload.stubs(:loaded).returns(@autoload_loaded)
8
+
9
+ # To prevent conflicts with other specs that use faces, we must save and restore global state.
10
+ # Because there are specs that do 'describe Puppet::Face[...]', we must restore the same objects otherwise
11
+ # the 'subject' of the specs will differ.
12
+ before :all do
13
+ # Save FaceCollection's global state
14
+ faces = subject.instance_variable_get(:@faces)
15
+ @faces = faces.dup
16
+ faces.each do |k, v|
17
+ @faces[k] = v.dup
18
+ end
19
+ @faces_loaded = subject.instance_variable_get(:@loaded)
20
+
21
+ # Save the already required face files
22
+ @required = []
23
+ $".each do |path|
24
+ @required << path if path =~ /face\/.*\.rb$/
25
+ end
26
+
27
+ # Save Autoload's global state
28
+ @loaded = Puppet::Util::Autoload.instance_variable_get(:@loaded).dup
23
29
  end
24
30
 
25
- after :each do
26
- # Just pushing the duplicate back into place doesn't work as reliably as
27
- # this method to restore the state. Honestly, I need to make this horror
28
- # go away entirely. --daniel 2012-04-28
29
- faces = subject.instance_variable_get("@faces")
30
- faces.clear
31
- @original_faces.each {|k,v| faces[k] = v }
31
+ after :all do
32
+ # Restore global state
33
+ subject.instance_variable_set :@faces, @faces
34
+ subject.instance_variable_set :@loaded, @faces_loaded
35
+ $".delete_if { |path| path =~ /face\/.*\.rb$/ }
36
+ @required.each { |path| $".push path unless $".include? path }
37
+ Puppet::Util::Autoload.instance_variable_set(:@loaded, @loaded)
38
+ end
32
39
 
33
- @original_required.each {|f| $".push f unless $".include? f }
40
+ before :each do
41
+ # Before each test, clear the faces
42
+ subject.instance_variable_get(:@faces).clear
43
+ subject.instance_variable_set(:@loaded, false)
44
+ Puppet::Util::Autoload.instance_variable_get(:@loaded).clear
45
+ $".delete_if { |path| path =~ /face\/.*\.rb$/ }
34
46
  end
35
47
 
36
48
  describe "::[]" do
@@ -19,19 +19,19 @@ describe Puppet::Module do
19
19
  end
20
20
 
21
21
  it "should have a class method that returns a named module from a given environment" do
22
- env = mock 'module'
22
+ env = Puppet::Node::Environment.create(:myenv, [])
23
23
  env.expects(:module).with(name).returns "yep"
24
- Puppet::Node::Environment.expects(:new).with("myenv").returns env
25
-
26
- Puppet::Module.find(name, "myenv").should == "yep"
24
+ Puppet.override(:environments => Puppet::Environments::Static.new(env)) do
25
+ Puppet::Module.find(name, "myenv").should == "yep"
26
+ end
27
27
  end
28
28
 
29
29
  it "should return nil if asked for a named module that doesn't exist" do
30
- env = mock 'module'
30
+ env = Puppet::Node::Environment.create(:myenv, [])
31
31
  env.expects(:module).with(name).returns nil
32
- Puppet::Node::Environment.expects(:new).with("myenv").returns env
33
-
34
- Puppet::Module.find(name, "myenv").should be_nil
32
+ Puppet.override(:environments => Puppet::Environments::Static.new(env)) do
33
+ Puppet::Module.find(name, "myenv").should be_nil
34
+ end
35
35
  end
36
36
 
37
37
  describe "attributes" do
@@ -97,6 +97,7 @@ describe Puppet::Module do
97
97
 
98
98
  it "should list modules that are missing" do
99
99
  metadata_file = "#{@modpath}/needy/metadata.json"
100
+ Puppet::FileSystem.expects(:exist?).with(metadata_file).returns true
100
101
  mod = PuppetSpec::Modules.create(
101
102
  'needy',
102
103
  @modpath,
@@ -118,6 +119,7 @@ describe Puppet::Module do
118
119
 
119
120
  it "should list modules that are missing and have invalid names" do
120
121
  metadata_file = "#{@modpath}/needy/metadata.json"
122
+ Puppet::FileSystem.expects(:exist?).with(metadata_file).returns true
121
123
  mod = PuppetSpec::Modules.create(
122
124
  'needy',
123
125
  @modpath,
@@ -140,6 +142,10 @@ describe Puppet::Module do
140
142
  it "should list modules with unmet version requirement" do
141
143
  env = Puppet::Node::Environment.create(:testing, [@modpath])
142
144
 
145
+ ['test_gte_req', 'test_specific_req', 'foobar'].each do |mod_name|
146
+ metadata_file = "#{@modpath}/#{mod_name}/metadata.json"
147
+ Puppet::FileSystem.stubs(:exist?).with(metadata_file).returns true
148
+ end
143
149
  mod = PuppetSpec::Modules.create(
144
150
  'test_gte_req',
145
151
  @modpath,
@@ -217,6 +223,8 @@ describe Puppet::Module do
217
223
  it "should consider a dependency without a semantic version to be unmet" do
218
224
  env = Puppet::Node::Environment.create(:testing, [@modpath])
219
225
 
226
+ metadata_file = "#{@modpath}/foobar/metadata.json"
227
+ Puppet::FileSystem.expects(:exist?).with(metadata_file).times(3).returns true
220
228
  mod = PuppetSpec::Modules.create(
221
229
  'foobar',
222
230
  @modpath,
@@ -261,6 +269,10 @@ describe Puppet::Module do
261
269
  it "should only list unmet dependencies" do
262
270
  env = Puppet::Node::Environment.create(:testing, [@modpath])
263
271
 
272
+ [name, 'satisfied'].each do |mod_name|
273
+ metadata_file = "#{@modpath}/#{mod_name}/metadata.json"
274
+ Puppet::FileSystem.expects(:exist?).with(metadata_file).twice.returns true
275
+ end
264
276
  mod = PuppetSpec::Modules.create(
265
277
  name,
266
278
  @modpath,
@@ -6,15 +6,42 @@ describe Puppet::ModuleTool::Applications::Builder do
6
6
  include PuppetSpec::Files
7
7
 
8
8
  let(:path) { tmpdir("working_dir") }
9
- let(:module_name) { 'myusername-mytarball' }
9
+ let(:module_name) { 'mymodule-mytarball' }
10
10
  let(:version) { '0.0.1' }
11
11
  let(:release_name) { "#{module_name}-#{version}" }
12
12
  let(:tarball) { File.join(path, 'pkg', release_name) + ".tar.gz" }
13
13
  let(:builder) { Puppet::ModuleTool::Applications::Builder.new(path) }
14
14
 
15
- before :each do
16
- File.open(File.join(path, 'Modulefile'), 'w') do |f|
17
- f.write(<<EOM)
15
+ context 'with metadata.json' do
16
+ before :each do
17
+ File.open(File.join(path, 'metadata.json'), 'w') do |f|
18
+ f.puts({
19
+ "name" => "#{module_name}",
20
+ "version" => "#{version}",
21
+ "source" => "http://github.com/testing/#{module_name}",
22
+ "author" => "testing",
23
+ "license" => "Apache License Version 2.0",
24
+ "summary" => "Puppet testing module",
25
+ "description" => "This module can be used for basic testing",
26
+ "project_page" => "http://github.com/testing/#{module_name}"
27
+ }.to_json)
28
+ end
29
+ end
30
+
31
+ it "packages the module in a tarball named after the module" do
32
+ tarrer = mock('tarrer')
33
+ Puppet::ModuleTool::Tar.expects(:instance).returns(tarrer)
34
+ Dir.expects(:chdir).with(File.join(path, 'pkg')).yields
35
+ tarrer.expects(:pack).with(release_name, tarball)
36
+
37
+ builder.run
38
+ end
39
+ end
40
+
41
+ context 'with Modulefile' do
42
+ before :each do
43
+ File.open(File.join(path, 'Modulefile'), 'w') do |f|
44
+ f.write <<-MODULEFILE
18
45
  name '#{module_name}'
19
46
  version '#{version}'
20
47
  source 'http://github.com/testing/#{module_name}'
@@ -23,16 +50,17 @@ license 'Apache License Version 2.0'
23
50
  summary 'Puppet testing module'
24
51
  description 'This module can be used for basic testing'
25
52
  project_page 'http://github.com/testing/#{module_name}'
26
- EOM
53
+ MODULEFILE
54
+ end
27
55
  end
28
- end
29
56
 
30
- it "should attempt to create a module relative to the pkg directory" do
31
- tarrer = mock('tarrer')
32
- Puppet::ModuleTool::Tar.expects(:instance).with(module_name).returns(tarrer)
33
- Dir.expects(:chdir).with(File.join(path, 'pkg')).yields
34
- tarrer.expects(:pack).with(release_name, tarball)
57
+ it "packages the module in a tarball named after the module" do
58
+ tarrer = mock('tarrer')
59
+ Puppet::ModuleTool::Tar.expects(:instance).returns(tarrer)
60
+ Dir.expects(:chdir).with(File.join(path, 'pkg')).yields
61
+ tarrer.expects(:pack).with(release_name, tarball)
35
62
 
36
- builder.run
63
+ builder.run
64
+ end
37
65
  end
38
66
  end
@@ -1,134 +1,115 @@
1
1
  require 'spec_helper'
2
2
  require 'puppet/module_tool/applications'
3
+ require 'puppet_spec/files'
4
+ require 'pathname'
3
5
 
4
6
  describe Puppet::ModuleTool::Applications::Checksummer do
5
- subject {
6
- Puppet::ModuleTool::Applications::Checksummer.new(module_install_path)
7
- }
8
-
9
- let(:module_install_path) { 'foo' }
10
- let(:module_metadata_file) { 'metadata.json' }
11
-
12
- let(:module_install_pathname) {
13
- module_install_pathname = mock()
14
- Pathname.expects(:new).with(module_install_path).\
15
- returns(module_install_pathname)
16
- module_install_pathname
17
- }
18
-
19
- def stub_module_file_pathname(relative_path, present)
20
- module_file_pathname = mock() do
21
- expects(:exist?).with().returns(present)
22
- end
7
+ let(:tmpdir) do
8
+ Pathname.new(PuppetSpec::Files.tmpdir('checksummer'))
9
+ end
10
+
11
+ let(:checksums) { Puppet::ModuleTool::Checksums.new(tmpdir).data }
23
12
 
24
- module_install_pathname.expects(:+).with(relative_path).\
25
- returns(module_file_pathname)
13
+ subject do
14
+ described_class.run(tmpdir)
15
+ end
26
16
 
27
- module_file_pathname
17
+ before do
18
+ File.open(tmpdir + 'README', 'w') { |f| f.puts "This is a README!" }
19
+ File.open(tmpdir + 'CHANGES', 'w') { |f| f.puts "This is a changelog!" }
20
+ File.open(tmpdir + 'DELETEME', 'w') { |f| f.puts "I've got a really good feeling about this!" }
21
+ Dir.mkdir(tmpdir + 'pkg')
22
+ File.open(tmpdir + 'pkg' + 'build-artifact', 'w') { |f| f.puts "I'm unimportant!" }
23
+ File.open(tmpdir + 'metadata.json', 'w') { |f| f.puts '{"name": "package-name", "version": "1.0.0"}' }
24
+ File.open(tmpdir + 'checksums.json', 'w') { |f| f.puts '{}' }
28
25
  end
29
26
 
30
- context %q{when metadata.json doesn't exist in the specified module install path} do
31
- before(:each) do
32
- stub_module_file_pathname(module_metadata_file, false)
33
- subject.expects(:metadata_file).with().\
34
- returns(module_install_pathname + module_metadata_file)
27
+ context 'with checksums.json' do
28
+ before do
29
+ File.open(tmpdir + 'checksums.json', 'w') { |f| f.puts checksums.to_json }
30
+ File.open(tmpdir + 'CHANGES', 'w') { |f| f.puts "This is a changed log!" }
31
+ File.open(tmpdir + 'pkg' + 'build-artifact', 'w') { |f| f.puts "I'm still unimportant!" }
32
+ (tmpdir + 'DELETEME').unlink
35
33
  end
36
34
 
37
- it 'raises an ArgumentError exception' do
38
- lambda {
39
- subject.run
40
- }.should raise_error(ArgumentError, 'No metadata.json found.')
35
+ it 'reports changed files' do
36
+ expect(subject).to include 'CHANGES'
41
37
  end
42
- end
43
38
 
44
- context 'when metadata.json exists in the specified module install path' do
45
- module_files = {
46
- 'README' => '1',
47
- 'CHANGELOG' => '2',
48
- 'Modulefile' => '3',
49
- }
50
- let(:module_files) { module_files }
51
- let(:checksum_computer) {
52
- checksum_computer = mock()
53
- Puppet::ModuleTool::Checksums.\
54
- expects(:new).with(module_install_pathname).\
55
- returns(checksum_computer)
56
- checksum_computer
57
- }
58
- # all possible combinations (of all lengths) of the module files
59
- module_files_combination =
60
- 1.upto(module_files.size()).inject([]) { |module_files_combination, n|
61
- module_files.keys.combination(n) { |combination|
62
- module_files_combination << combination
63
- }
64
- module_files_combination
65
- }
66
-
67
- def stub_module_file_pathname_with_checksum(relative_path, checksum)
68
- module_file_pathname =
69
- stub_module_file_pathname(relative_path, present = !checksum.nil?)
70
- # mock the call of Puppet::ModuleTool::Checksums#checksum
71
- expectation = checksum_computer.\
72
- expects(:checksum).with(module_file_pathname)
73
- if present
74
- # return the cheksum directly
75
- expectation.returns(checksum)
76
- else
77
- # if the file is not present, then the method should not be called
78
- expectation.times(0)
79
- end
80
- module_file_pathname
39
+ it 'reports removed files' do
40
+ expect(subject).to include 'DELETEME'
81
41
  end
82
42
 
83
- def stub_module_files(overrides = {})
84
- overrides.reject! { |key, value|
85
- !module_files.include?(key)
86
- }
87
- module_files.merge(overrides).each { |relative_path, checksum|
88
- stub_module_file_pathname_with_checksum(relative_path, checksum)
89
- }
43
+ it 'does not report unchanged files' do
44
+ expect(subject).to_not include 'README'
90
45
  end
91
46
 
92
- before(:each) do
93
- stub_module_file_pathname(module_metadata_file, true)
94
- subject.expects(:metadata_file).with().\
95
- returns(module_install_pathname + module_metadata_file)
96
- subject.expects(:metadata).with().\
97
- returns({ 'checksums' => module_files })
47
+ it 'does not report build artifacts' do
48
+ expect(subject).to_not include 'pkg/build-artifact'
98
49
  end
99
50
 
100
- module_files_combination.each do |removed_files|
101
- it "reports removed file(s) #{removed_files.inspect}" do
102
- stub_module_files(
103
- removed_files.inject({}) { |overrides, removed_file|
104
- overrides[removed_file] = nil
105
- overrides
106
- }
107
- )
51
+ it 'does not report checksums.json' do
52
+ expect(subject).to_not include 'checksums.json'
53
+ end
54
+ end
55
+
56
+ context 'without checksums.json' do
57
+ context 'but with metadata.json containing checksums' do
58
+ before do
59
+ (tmpdir + 'checksums.json').unlink
60
+ File.open(tmpdir + 'metadata.json', 'w') { |f| f.puts "{\"checksums\":#{checksums.to_json}}" }
61
+ File.open(tmpdir + 'CHANGES', 'w') { |f| f.puts "This is a changed log!" }
62
+ File.open(tmpdir + 'pkg' + 'build-artifact', 'w') { |f| f.puts "I'm still unimportant!" }
63
+ (tmpdir + 'DELETEME').unlink
64
+ end
65
+
66
+ it 'reports changed files' do
67
+ expect(subject).to include 'CHANGES'
68
+ end
108
69
 
109
- subject.run.should == removed_files
70
+ it 'reports removed files' do
71
+ expect(subject).to include 'DELETEME'
72
+ end
73
+
74
+ it 'does not report unchanged files' do
75
+ expect(subject).to_not include 'README'
76
+ end
77
+
78
+ it 'does not report build artifacts' do
79
+ expect(subject).to_not include 'pkg/build-artifact'
80
+ end
81
+
82
+ it 'does not report checksums.json' do
83
+ expect(subject).to_not include 'checksums.json'
110
84
  end
111
85
  end
112
86
 
113
- module_files_combination.each do |modified_files|
114
- it "reports modified file(s) #{modified_files.inspect}" do
115
- stub_module_files(
116
- modified_files.inject({}) { |overrides, modified_file|
117
- modified_checksum = module_files[modified_file].to_s.succ
118
- modified_checksum = ' ' if modified_checksum.empty?
119
- overrides[modified_file] = modified_checksum
120
- overrides
121
- }
122
- )
123
-
124
- subject.run.should == modified_files
87
+ context 'and with metadata.json that does not contain checksums' do
88
+ before do
89
+ (tmpdir + 'checksums.json').unlink
90
+ File.open(tmpdir + 'CHANGES', 'w') { |f| f.puts "This is a changed log!" }
91
+ File.open(tmpdir + 'pkg' + 'build-artifact', 'w') { |f| f.puts "I'm still unimportant!" }
92
+ (tmpdir + 'DELETEME').unlink
93
+ end
94
+
95
+ it 'fails' do
96
+ expect { subject }.to raise_error(ArgumentError, 'No file containing checksums found.')
125
97
  end
126
98
  end
127
99
 
128
- it 'does not report unmodified files' do
129
- stub_module_files()
100
+ context 'and without metadata.json' do
101
+ before do
102
+ (tmpdir + 'checksums.json').unlink
103
+ (tmpdir + 'metadata.json').unlink
130
104
 
131
- subject.run.should == []
105
+ File.open(tmpdir + 'CHANGES', 'w') { |f| f.puts "This is a changed log!" }
106
+ File.open(tmpdir + 'pkg' + 'build-artifact', 'w') { |f| f.puts "I'm still unimportant!" }
107
+ (tmpdir + 'DELETEME').unlink
108
+ end
109
+
110
+ it 'fails' do
111
+ expect { subject }.to raise_error(ArgumentError, 'No file containing checksums found.')
112
+ end
132
113
  end
133
114
  end
134
115
  end
@@ -1,331 +1,363 @@
1
1
  require 'spec_helper'
2
2
  require 'puppet/module_tool/applications'
3
- require 'puppet_spec/modules'
3
+ require 'puppet_spec/module_tool/shared_functions'
4
+ require 'puppet_spec/module_tool/stub_source'
4
5
  require 'semver'
5
6
 
6
7
  describe Puppet::ModuleTool::Applications::Installer do
8
+ include PuppetSpec::ModuleTool::SharedFunctions
7
9
  include PuppetSpec::Files
10
+ include PuppetSpec::Fixtures
8
11
 
9
- let(:unpacker) { stub(:run) }
10
- let(:installer_class) { Puppet::ModuleTool::Applications::Installer }
11
- let(:modpath1) do
12
- path = File.join(tmpdir("installer"), "modpath1")
13
- FileUtils.mkdir_p(path)
14
- path
15
- end
16
- let(:stdlib_pkg) do
17
- mod = File.join(modpath1, "pmtacceptance-stdlib-0.0.1.tar.gz")
18
- FileUtils.touch(mod)
19
- mod
20
- end
21
- let(:env) { Puppet::Node::Environment.create(:env, [modpath1]) }
22
- let(:options) do
23
- {
24
- :target_dir => modpath1,
25
- :environment_instance => env,
26
- }
12
+ before do
13
+ FileUtils.mkdir_p(primary_dir)
14
+ FileUtils.mkdir_p(secondary_dir)
27
15
  end
28
16
 
29
- let(:forge) do
30
- forge = mock("Puppet::Forge")
17
+ let(:vardir) { tmpdir('installer') }
18
+ let(:primary_dir) { File.join(vardir, "primary") }
19
+ let(:secondary_dir) { File.join(vardir, "secondary") }
20
+ let(:remote_source) { PuppetSpec::ModuleTool::StubSource.new }
31
21
 
32
- forge.stubs(:remote_dependency_info).returns(remote_dependency_info)
33
- forge.stubs(:uri).returns('forge-dev.puppetlabs.com')
34
- remote_dependency_info.each_key do |mod|
35
- remote_dependency_info[mod].each do |release|
36
- forge.stubs(:retrieve).with(release['file']).returns("/fake_cache#{release['file']}")
37
- end
22
+ let(:install_dir) do
23
+ mock("Puppet::ModuleTool::InstallDirectory").tap do |dir|
24
+ dir.stubs(:prepare)
25
+ dir.stubs(:target).returns(primary_dir)
38
26
  end
27
+ end
39
28
 
40
- forge
29
+ before do
30
+ Semantic::Dependency.clear_sources
31
+ installer = Puppet::ModuleTool::Applications::Installer.any_instance
32
+ installer.stubs(:module_repository).returns(remote_source)
41
33
  end
42
34
 
43
- let(:install_dir) do
44
- install_dir = mock("Puppet::ModuleTool::InstallDirectory")
45
- install_dir.stubs(:prepare)
46
- install_dir
35
+ def installer(modname, target_dir, options)
36
+ Puppet::ModuleTool.set_option_defaults(options)
37
+ Puppet::ModuleTool::Applications::Installer.new(modname, target_dir, options)
47
38
  end
48
39
 
49
- let(:remote_dependency_info) do
50
- {
51
- "pmtacceptance/apache" => [
52
- { "dependencies" => [],
53
- "version" => "1.0.0-alpha",
54
- "file" => "/pmtacceptance-apache-1.0.0-alpha.tar.gz" },
55
- { "dependencies" => [],
56
- "version" => "1.0.0-beta",
57
- "file" => "/pmtacceptance-apache-1.0.0-beta.tar.gz" },
58
- { "dependencies" => [],
59
- "version" => "1.0.0-rc1",
60
- "file" => "/pmtacceptance-apache-1.0.0-rc1.tar.gz" },
61
- ],
62
- "pmtacceptance/stdlib" => [
63
- { "dependencies" => [],
64
- "version" => "0.0.1",
65
- "file" => "/pmtacceptance-stdlib-0.0.1.tar.gz" },
66
- { "dependencies" => [],
67
- "version" => "0.0.2",
68
- "file" => "/pmtacceptance-stdlib-0.0.2.tar.gz" },
69
- { "dependencies" => [],
70
- "version" => "1.0.0-pre",
71
- "file" => "/pmtacceptance-stdlib-1.0.0-pre.tar.gz" },
72
- { "dependencies" => [],
73
- "version" => "1.0.0",
74
- "file" => "/pmtacceptance-stdlib-1.0.0.tar.gz" },
75
- { "dependencies" => [],
76
- "version" => "1.5.0-pre",
77
- "file" => "/pmtacceptance-stdlib-1.5.0-pre.tar.gz" },
78
- ],
79
- "pmtacceptance/java" => [
80
- { "dependencies" => [["pmtacceptance/stdlib", ">= 0.0.1"]],
81
- "version" => "1.7.0",
82
- "file" => "/pmtacceptance-java-1.7.0.tar.gz" },
83
- { "dependencies" => [["pmtacceptance/stdlib", "1.0.0"]],
84
- "version" => "1.7.1",
85
- "file" => "/pmtacceptance-java-1.7.1.tar.gz" }
86
- ],
87
- "pmtacceptance/apollo" => [
88
- { "dependencies" => [
89
- ["pmtacceptance/java", "1.7.1"],
90
- ["pmtacceptance/stdlib", "0.0.1"]
91
- ],
92
- "version" => "0.0.1",
93
- "file" => "/pmtacceptance-apollo-0.0.1.tar.gz" },
94
- { "dependencies" => [
95
- ["pmtacceptance/java", ">= 1.7.0"],
96
- ["pmtacceptance/stdlib", ">= 1.0.0"]
97
- ],
98
- "version" => "0.0.2",
99
- "file" => "/pmtacceptance-apollo-0.0.2.tar.gz" }
100
- ]
101
- }
40
+ let(:environment) do
41
+ Puppet.lookup(:current_environment).override_with(
42
+ :vardir => vardir,
43
+ :modulepath => [ primary_dir, secondary_dir ]
44
+ )
102
45
  end
103
46
 
104
- describe "the behavior of .is_module_package?" do
105
- it "should return true when file is a module package" do
106
- installer = installer_class.new("foo", forge, install_dir, options)
107
- installer.send(:is_module_package?, stdlib_pkg).should be_true
108
- end
47
+ context '#run' do
48
+ let(:module) { 'pmtacceptance-stdlib' }
109
49
 
110
- it "should return false when file is not a module package" do
111
- installer = installer_class.new("foo", forge, install_dir, options)
112
- installer.send(:is_module_package?, "pmtacceptance-apollo-0.0.2.tar").
113
- should be_false
50
+ def options
51
+ { :environment => environment }
114
52
  end
115
- end
116
53
 
117
- context "when the source is a repository" do
118
- it "should require a valid name" do
119
- lambda { installer_class.run('puppet', install_dir, params) }.should
120
- raise_error(ArgumentError, "Could not install module with invalid name: puppet")
121
- end
54
+ let(:application) { installer(self.module, install_dir, options) }
55
+ subject { application.run }
122
56
 
123
- it "should install the current stable version of the requested module" do
124
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
125
- with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options).
126
- returns(unpacker)
127
- results = installer_class.run('pmtacceptance-stdlib', forge, install_dir, options)
128
- results[:installed_modules].length == 1
129
- results[:installed_modules][0][:module].should == "pmtacceptance-stdlib"
130
- results[:installed_modules][0][:version][:vstring].should == "1.0.0"
57
+ it 'installs the specified module' do
58
+ subject.should include :result => :success
59
+ graph_should_include 'pmtacceptance-stdlib', nil => v('4.1.0')
131
60
  end
132
61
 
133
- it "should install the most recent version of requested module in the absence of a stable version" do
134
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
135
- with('/fake_cache/pmtacceptance-apache-1.0.0-rc1.tar.gz', options).
136
- returns(unpacker)
137
- results = installer_class.run('pmtacceptance-apache', forge, install_dir, options)
138
- results[:installed_modules].length == 1
139
- results[:installed_modules][0][:module].should == "pmtacceptance-apache"
140
- results[:installed_modules][0][:version][:vstring].should == "1.0.0-rc1"
141
- end
62
+ context 'with a tarball file' do
63
+ let(:module) { fixtures('stdlib.tgz') }
142
64
 
143
- it "should install the most recent stable version of requested module for the requested version range" do
144
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
145
- with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options.merge(:version => '1.x')).
146
- returns(unpacker)
147
- results = installer_class.run('pmtacceptance-stdlib', forge, install_dir, options.merge(:version => '1.x'))
148
- results[:installed_modules].length == 1
149
- results[:installed_modules][0][:module].should == "pmtacceptance-stdlib"
150
- results[:installed_modules][0][:version][:vstring].should == "1.0.0"
151
- end
65
+ it 'installs the specified tarball' do
66
+ subject.should include :result => :success
67
+ graph_should_include 'puppetlabs-stdlib', nil => v('3.2.0')
68
+ end
152
69
 
153
- it "should install the most recent version of requested module for the requested version range in the absence of a stable version" do
154
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
155
- with('/fake_cache/pmtacceptance-stdlib-1.5.0-pre.tar.gz', options.merge(:version => '1.5.0-pre')).
156
- returns(unpacker)
157
- results = installer_class.run('pmtacceptance-stdlib', forge, install_dir, options.merge(:version => '1.5.0-pre'))
158
- results[:installed_modules].length == 1
159
- results[:installed_modules][0][:module].should == "pmtacceptance-stdlib"
160
- results[:installed_modules][0][:version][:vstring].should == "1.5.0-pre"
161
- end
70
+ context 'with --ignore-dependencies' do
71
+ def options
72
+ super.merge(:ignore_dependencies => true)
73
+ end
162
74
 
163
- context "should check the target directory" do
164
- let(:installer) do
165
- installer_class.new('pmtacceptance-stdlib', forge, install_dir, options)
75
+ it 'installs the specified tarball' do
76
+ remote_source.expects(:fetch).never
77
+ subject.should include :result => :success
78
+ graph_should_include 'puppetlabs-stdlib', nil => v('3.2.0')
79
+ end
166
80
  end
167
81
 
168
- def expect_normal_unpacker
169
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
170
- with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options).
171
- returns(unpacker)
82
+ context 'with dependencies' do
83
+ let(:module) { fixtures('java.tgz') }
84
+
85
+ it 'installs the specified tarball' do
86
+ subject.should include :result => :success
87
+ graph_should_include 'puppetlabs-java', nil => v('1.0.0')
88
+ graph_should_include 'puppetlabs-stdlib', nil => v('4.1.0')
89
+ end
90
+
91
+ context 'with --ignore-dependencies' do
92
+ def options
93
+ super.merge(:ignore_dependencies => true)
94
+ end
95
+
96
+ it 'installs the specified tarball without dependencies' do
97
+ remote_source.expects(:fetch).never
98
+ subject.should include :result => :success
99
+ graph_should_include 'puppetlabs-java', nil => v('1.0.0')
100
+ graph_should_include 'puppetlabs-stdlib', nil
101
+ end
102
+ end
172
103
  end
104
+ end
105
+
106
+ context 'with dependencies' do
107
+ let(:module) { 'pmtacceptance-apache' }
173
108
 
174
- def expect_normal_results
175
- results
109
+ it 'installs the specified module and its dependencies' do
110
+ subject.should include :result => :success
111
+ graph_should_include 'pmtacceptance-apache', nil => v('0.10.0')
112
+ graph_should_include 'pmtacceptance-stdlib', nil => v('4.1.0')
176
113
  end
177
114
 
178
- it "(#15202) prepares the install directory" do
179
- expect_normal_unpacker
180
- install_dir.expects(:prepare).with("pmtacceptance-stdlib", "latest")
115
+ context 'and using --ignore_dependencies' do
116
+ def options
117
+ super.merge(:ignore_dependencies => true)
118
+ end
119
+
120
+ it 'installs only the specified module' do
121
+ subject.should include :result => :success
122
+ graph_should_include 'pmtacceptance-apache', nil => v('0.10.0')
123
+ graph_should_include 'pmtacceptance-stdlib', nil
124
+ end
125
+ end
126
+
127
+ context 'that are already installed' do
128
+ context 'and satisfied' do
129
+ before { preinstall('pmtacceptance-stdlib', '4.1.0') }
130
+
131
+ it 'installs only the specified module' do
132
+ subject.should include :result => :success
133
+ graph_should_include 'pmtacceptance-apache', nil => v('0.10.0')
134
+ graph_should_include 'pmtacceptance-stdlib', :path => primary_dir
135
+ end
136
+
137
+ context '(outdated but suitable version)' do
138
+ before { preinstall('pmtacceptance-stdlib', '2.4.0') }
139
+
140
+ it 'installs only the specified module' do
141
+ subject.should include :result => :success
142
+ graph_should_include 'pmtacceptance-apache', nil => v('0.10.0')
143
+ graph_should_include 'pmtacceptance-stdlib', v('2.4.0') => v('2.4.0'), :path => primary_dir
144
+ end
145
+ end
146
+
147
+ context '(outdated and unsuitable version)' do
148
+ before { preinstall('pmtacceptance-stdlib', '1.0.0') }
149
+
150
+ it 'installs a version that is compatible with the installed dependencies' do
151
+ subject.should include :result => :success
152
+ graph_should_include 'pmtacceptance-apache', nil => v('0.0.4')
153
+ graph_should_include 'pmtacceptance-stdlib', nil
154
+ end
155
+ end
156
+ end
181
157
 
182
- results = installer.run
158
+ context 'but not satisfied' do
159
+ let(:module) { 'pmtacceptance-keystone' }
183
160
 
184
- results[:installed_modules].length.should eq 1
185
- results[:installed_modules][0][:module].should == "pmtacceptance-stdlib"
186
- results[:installed_modules][0][:version][:vstring].should == "1.0.0"
161
+ def options
162
+ super.merge(:version => '2.0.0')
163
+ end
164
+
165
+ before { preinstall('pmtacceptance-mysql', '2.1.0') }
166
+
167
+ it 'installs only the specified module' do
168
+ subject.should include :result => :success
169
+ graph_should_include 'pmtacceptance-keystone', nil => v('2.0.0')
170
+ graph_should_include 'pmtacceptance-mysql', v('2.1.0') => v('2.1.0')
171
+ graph_should_include 'pmtacceptance-stdlib', nil
172
+ end
173
+ end
187
174
  end
188
175
 
189
- it "(#15202) reports an error when the install directory cannot be prepared" do
190
- install_dir.expects(:prepare).with("pmtacceptance-stdlib", "latest").
191
- raises(Puppet::ModuleTool::Errors::PermissionDeniedCreateInstallDirectoryError.new("original", :module => "pmtacceptance-stdlib"))
176
+ context 'that are already installed in other modulepath directories' do
177
+ before { preinstall('pmtacceptance-stdlib', '1.0.0', :into => secondary_dir) }
178
+ let(:module) { 'pmtacceptance-apache' }
179
+
180
+ context 'without dependency updates' do
181
+ it 'installs the module only' do
182
+ subject.should include :result => :success
183
+ graph_should_include 'pmtacceptance-apache', nil => v('0.0.4')
184
+ graph_should_include 'pmtacceptance-stdlib', nil
185
+ end
186
+ end
192
187
 
193
- results = installer.run
188
+ context 'with dependency updates' do
189
+ before { preinstall('pmtacceptance-stdlib', '2.0.0', :into => secondary_dir) }
194
190
 
195
- results[:result].should == :failure
196
- results[:error][:oneline].should =~ /Permission is denied/
191
+ it 'installs the module and upgrades dependencies in-place' do
192
+ subject.should include :result => :success
193
+ graph_should_include 'pmtacceptance-apache', nil => v('0.10.0')
194
+ graph_should_include 'pmtacceptance-stdlib', v('2.0.0') => v('2.6.0'), :path => secondary_dir
195
+ end
196
+ end
197
197
  end
198
198
  end
199
199
 
200
- context "when the requested module has dependencies" do
201
- it "should install dependencies" do
202
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
203
- with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options).
204
- returns(unpacker)
205
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
206
- with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options).
207
- returns(unpacker)
208
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
209
- with('/fake_cache/pmtacceptance-java-1.7.1.tar.gz', options).
210
- returns(unpacker)
211
-
212
- results = installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
213
- installed_dependencies = results[:installed_modules][0][:dependencies]
214
-
215
- dependencies = installed_dependencies.inject({}) do |result, dep|
216
- result[dep[:module]] = dep[:version][:vstring]
217
- result
200
+ context 'with a specified' do
201
+
202
+ context 'version' do
203
+ def options
204
+ super.merge(:version => '3.0.0')
218
205
  end
219
206
 
220
- dependencies.length.should == 2
221
- dependencies['pmtacceptance-java'].should == '1.7.1'
222
- dependencies['pmtacceptance-stdlib'].should == '1.0.0'
207
+ it 'installs the specified release (or a prerelease thereof)' do
208
+ subject.should include :result => :success
209
+ graph_should_include 'pmtacceptance-stdlib', nil => v('3.0.0')
210
+ end
223
211
  end
224
212
 
225
- it "should install requested module if the '--force' flag is used" do
226
- options.merge!(:force => true)
227
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
228
- with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options).
229
- returns(unpacker)
230
- results = installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
231
- results[:installed_modules][0][:module].should == "pmtacceptance-apollo"
213
+ context 'version range' do
214
+ def options
215
+ super.merge(:version => '3.x')
216
+ end
217
+
218
+ it 'installs the greatest available version matching that range' do
219
+ subject.should include :result => :success
220
+ graph_should_include 'pmtacceptance-stdlib', nil => v('3.2.0')
221
+ end
232
222
  end
223
+ end
224
+
225
+ context 'when depended upon' do
226
+ before { preinstall('pmtacceptance-keystone', '2.1.0') }
227
+ let(:module) { 'pmtacceptance-mysql' }
233
228
 
234
- it "should not install dependencies if the '--force' flag is used" do
235
- options.merge!(:force => true)
236
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
237
- with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options).
238
- returns(unpacker)
239
- results = installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
240
- dependencies = results[:installed_modules][0][:dependencies]
241
- dependencies.should == []
229
+ it 'installs the greatest available version meeting the dependency constraints' do
230
+ subject.should include :result => :success
231
+ graph_should_include 'pmtacceptance-mysql', nil => v('0.9.0')
242
232
  end
243
233
 
244
- it "should not install dependencies if the '--ignore-dependencies' flag is used" do
245
- options.merge!(:ignore_dependencies => true)
246
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
247
- with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options).
248
- returns(unpacker)
249
- results = installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
250
- dependencies = results[:installed_modules][0][:dependencies]
251
- dependencies.should == []
234
+ context 'with a --version that can satisfy' do
235
+ def options
236
+ super.merge(:version => '0.8.0')
237
+ end
238
+
239
+ it 'installs the greatest available version satisfying both constraints' do
240
+ subject.should include :result => :success
241
+ graph_should_include 'pmtacceptance-mysql', nil => v('0.8.0')
242
+ end
252
243
  end
253
244
 
254
- it "should set an error if dependencies can't be resolved" do
255
- options.merge!(:version => '0.0.1')
256
- oneline = "'pmtacceptance-apollo' (v0.0.1) requested; Invalid dependency cycle"
257
- multiline = <<-MSG.strip
258
- Could not install module 'pmtacceptance-apollo' (v0.0.1)
259
- No version of 'pmtacceptance-stdlib' will satisfy dependencies
260
- You specified 'pmtacceptance-apollo' (v0.0.1),
261
- which depends on 'pmtacceptance-java' (v1.7.1),
262
- which depends on 'pmtacceptance-stdlib' (v1.0.0)
263
- Use `puppet module install --force` to install this module anyway
264
- MSG
265
-
266
- results = installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
267
- results[:result].should == :failure
268
- results[:error][:oneline].should == oneline
269
- results[:error][:multiline].should == multiline
245
+ context 'with a --version that cannot satisfy' do
246
+ def options
247
+ super.merge(:version => '> 1.0.0')
248
+ end
249
+
250
+ it 'fails to install, since there is no version that can satisfy both constraints' do
251
+ subject.should include :result => :failure
252
+ end
253
+
254
+ context 'with --ignore-dependencies' do
255
+ def options
256
+ super.merge(:ignore_dependencies => true)
257
+ end
258
+
259
+ it 'fails to install, since ignore_dependencies should still respect dependencies from installed modules' do
260
+ subject.should include :result => :failure
261
+ end
262
+ end
263
+
264
+ context 'with --force' do
265
+ def options
266
+ super.merge(:force => true)
267
+ end
268
+
269
+ it 'installs the greatest available version, ignoring dependencies' do
270
+ subject.should include :result => :success
271
+ graph_should_include 'pmtacceptance-mysql', nil => v('2.1.0')
272
+ end
273
+ end
270
274
  end
275
+ end
271
276
 
272
- it "resolves conflicts for each dependency only once" do
273
- Puppet::Log.level = :debug
277
+ context 'when already installed' do
278
+ before { preinstall('pmtacceptance-stdlib', '1.0.0') }
274
279
 
275
- installed_modules = [
276
- Puppet::Module.new('ntp', File.join(modpath1, 'ntp'), env.name),
277
- Puppet::Module.new('mysql', File.join(modpath1, 'mysql'), env.name),
278
- Puppet::Module.new('apache', File.join(modpath1, 'apache'), env.name)
279
- ]
280
+ context 'but matching the requested version' do
281
+ it 'does nothing, since the installed version satisfies' do
282
+ subject.should include :result => :noop
283
+ end
280
284
 
281
- env.stubs(:modules_by_path).returns({modpath1 => installed_modules})
285
+ context 'with --force' do
286
+ def options
287
+ super.merge(:force => true)
288
+ end
282
289
 
283
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
284
- with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options).
285
- returns(unpacker)
286
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
287
- with('/fake_cache/pmtacceptance-java-1.7.1.tar.gz', options).
288
- returns(unpacker)
289
- Puppet::ModuleTool::Applications::Unpacker.expects(:new).
290
- with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options).
291
- returns(unpacker)
290
+ it 'does reinstall the module' do
291
+ subject.should include :result => :success
292
+ graph_should_include 'pmtacceptance-stdlib', v('1.0.0') => v('4.1.0')
293
+ end
294
+ end
292
295
 
293
- installer_class.run('pmtacceptance-apollo', forge, install_dir, options)
296
+ context 'with local changes' do
297
+ before do
298
+ release = application.send(:installed_modules)['pmtacceptance-stdlib']
299
+ mark_changed(release.mod.path)
300
+ end
301
+
302
+ it 'does nothing, since local changes do not affect that' do
303
+ subject.should include :result => :noop
304
+ end
305
+
306
+ context 'with --force' do
307
+ def options
308
+ super.merge(:force => true)
309
+ end
310
+
311
+ it 'does reinstall the module, since --force ignores local changes' do
312
+ subject.should include :result => :success
313
+ graph_should_include 'pmtacceptance-stdlib', v('1.0.0') => v('4.1.0')
314
+ end
315
+ end
316
+ end
317
+ end
294
318
 
295
- modules = @logs.map do |log|
296
- data = log.message.match(/Resolving conflicts for (.*)/)
297
- data ? data[1] : nil
298
- end.compact
319
+ context 'but not matching the requested version' do
320
+ def options
321
+ super.merge(:version => '2.x')
322
+ end
299
323
 
300
- expect(modules).to eq(["pmtacceptance-apollo", "pmtacceptance-java,pmtacceptance-stdlib"])
324
+ it 'fails to install the module, since it is already installed' do
325
+ subject.should include :result => :failure
326
+ subject[:error].should include :oneline => "'pmtacceptance-stdlib' (v2.x) requested; 'pmtacceptance-stdlib' (v1.0.0) already installed"
327
+ end
328
+
329
+ context 'with --force' do
330
+ def options
331
+ super.merge(:force => true)
332
+ end
333
+
334
+ it 'installs the greatest version matching the new version range' do
335
+ subject.should include :result => :success
336
+ graph_should_include 'pmtacceptance-stdlib', v('1.0.0') => v('2.6.0')
337
+ end
338
+ end
301
339
  end
302
340
  end
303
341
 
304
- context "when there are modules installed" do
305
- it "should use local version when already exists and satisfies constraints"
306
- it "should reinstall the local version if force is used"
307
- it "should upgrade local version when necessary to satisfy constraints"
308
- it "should error when a local version can't be upgraded to satisfy constraints"
309
- end
342
+ context 'when a module with the same name is already installed' do
343
+ let(:module) { 'pmtacceptance-stdlib' }
344
+ before { preinstall('puppetlabs-stdlib', '4.1.0') }
310
345
 
311
- context "when a local module needs upgrading to satisfy constraints but has changes" do
312
- it "should error"
313
- it "should warn and continue if force is used"
314
- end
346
+ it 'fails to install, since two modules with the same name cannot be installed simultaneously' do
347
+ subject.should include :result => :failure
348
+ end
315
349
 
316
- it "should error when a local version of a dependency has no version metadata"
317
- it "should error when a local version of a dependency has a non-semver version"
318
- it "should error when a local version of a dependency has a different forge name"
319
- it "should error when a local version of a dependency has no metadata"
320
- end
350
+ context 'using --force' do
351
+ def options
352
+ super.merge(:force => true)
353
+ end
321
354
 
322
- context "when the source is a filesystem" do
323
- before do
324
- @sourcedir = tmpdir('sourcedir')
355
+ it 'overwrites the existing module with the greatest version of the requested module' do
356
+ subject.should include :result => :success
357
+ graph_should_include 'pmtacceptance-stdlib', nil => v('4.1.0')
358
+ end
359
+ end
325
360
  end
326
361
 
327
- it "should error if it can't parse the name"
328
-
329
- it "should try to get_release_package_from_filesystem if it has a valid name"
330
362
  end
331
363
  end