puppet 2.7.13 → 2.7.14

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 (215) hide show
  1. data/CHANGELOG +144 -1
  2. data/conf/osx/preflight +1 -1
  3. data/conf/redhat/puppet.spec +9 -5
  4. data/conf/suse/puppet.spec +4 -1
  5. data/conf/windows/eventlog/Rakefile +32 -0
  6. data/conf/windows/eventlog/puppetres.dll +0 -0
  7. data/conf/windows/eventlog/puppetres.mc +18 -0
  8. data/ext/rack/files/apache2.conf +3 -0
  9. data/install.rb +23 -1
  10. data/lib/puppet.rb +1 -1
  11. data/lib/puppet/agent.rb +1 -14
  12. data/lib/puppet/application/kick.rb +1 -1
  13. data/lib/puppet/application/module.rb +11 -0
  14. data/lib/puppet/daemon.rb +74 -3
  15. data/lib/puppet/defaults.rb +1 -1
  16. data/lib/puppet/face/certificate.rb +1 -1
  17. data/lib/puppet/face/help/man.erb +1 -1
  18. data/lib/puppet/face/module.rb +17 -0
  19. data/lib/puppet/face/module/build.rb +10 -4
  20. data/lib/puppet/face/module/changes.rb +5 -5
  21. data/lib/puppet/face/module/generate.rb +6 -4
  22. data/lib/puppet/face/module/install.rb +122 -32
  23. data/lib/puppet/face/module/list.rb +234 -33
  24. data/lib/puppet/face/module/search.rb +56 -23
  25. data/lib/puppet/face/module/uninstall.rb +33 -38
  26. data/lib/puppet/face/module/upgrade.rb +84 -0
  27. data/lib/puppet/feature/eventlog.rb +6 -0
  28. data/lib/puppet/forge.rb +67 -122
  29. data/lib/puppet/forge/cache.rb +1 -1
  30. data/lib/puppet/forge/repository.rb +6 -25
  31. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  32. data/lib/puppet/interface/action.rb +1 -1
  33. data/lib/puppet/module.rb +79 -28
  34. data/lib/puppet/module_tool.rb +72 -34
  35. data/lib/puppet/module_tool/applications.rb +12 -14
  36. data/lib/puppet/module_tool/applications/application.rb +21 -19
  37. data/lib/puppet/module_tool/applications/builder.rb +4 -4
  38. data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
  39. data/lib/puppet/module_tool/applications/generator.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +163 -34
  41. data/lib/puppet/module_tool/applications/searcher.rb +2 -3
  42. data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
  43. data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
  44. data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
  45. data/lib/puppet/module_tool/checksums.rb +2 -2
  46. data/lib/puppet/module_tool/contents_description.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +2 -2
  48. data/lib/puppet/module_tool/errors.rb +9 -0
  49. data/lib/puppet/module_tool/errors/base.rb +15 -0
  50. data/lib/puppet/module_tool/errors/installer.rb +90 -0
  51. data/lib/puppet/module_tool/errors/shared.rb +115 -0
  52. data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
  53. data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
  54. data/lib/puppet/module_tool/metadata.rb +2 -2
  55. data/lib/puppet/module_tool/modulefile.rb +7 -7
  56. data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
  57. data/lib/puppet/module_tool/skeleton.rb +1 -1
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/parser/ast/leaf.rb +1 -1
  60. data/lib/puppet/parser/functions/create_resources.rb +3 -2
  61. data/lib/puppet/parser/scope.rb +44 -9
  62. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  63. data/lib/puppet/provider/exec.rb +8 -3
  64. data/lib/puppet/provider/exec/shell.rb +1 -2
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
  66. data/lib/puppet/provider/package/gem.rb +1 -1
  67. data/lib/puppet/provider/package/pkg.rb +10 -21
  68. data/lib/puppet/provider/selmodule/semodule.rb +1 -2
  69. data/lib/puppet/provider/service/upstart.rb +33 -17
  70. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  71. data/lib/puppet/rails/inventory_node.rb +7 -7
  72. data/lib/puppet/reports/http.rb +4 -1
  73. data/lib/puppet/reports/tagmail.rb +8 -1
  74. data/lib/puppet/resource/type.rb +1 -1
  75. data/lib/puppet/test/test_helper.rb +138 -0
  76. data/lib/puppet/type.rb +9 -1
  77. data/lib/puppet/type/file.rb +18 -10
  78. data/lib/puppet/type/package.rb +13 -9
  79. data/lib/puppet/type/resources.rb +1 -1
  80. data/lib/puppet/type/ssh_authorized_key.rb +3 -4
  81. data/lib/puppet/type/sshkey.rb +4 -4
  82. data/lib/puppet/type/user.rb +1 -0
  83. data/lib/puppet/type/vlan.rb +1 -1
  84. data/lib/puppet/util.rb +31 -14
  85. data/lib/puppet/util/autoload.rb +1 -1
  86. data/lib/puppet/util/command_line.rb +2 -6
  87. data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
  88. data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
  89. data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
  90. data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
  91. data/lib/puppet/util/log.rb +3 -1
  92. data/lib/puppet/util/log/destinations.rb +38 -0
  93. data/lib/puppet/util/monkey_patches.rb +45 -0
  94. data/lib/puppet/util/network_device/base.rb +1 -1
  95. data/lib/puppet/util/network_device/cisco.rb +1 -1
  96. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  97. data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
  98. data/lib/puppet/util/network_device/config.rb +1 -1
  99. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  100. data/lib/puppet/util/network_device/transport.rb +1 -1
  101. data/lib/puppet/util/network_device/transport/base.rb +1 -1
  102. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  103. data/lib/puppet/util/settings.rb +2 -11
  104. data/lib/puppet/util/settings/file_setting.rb +3 -5
  105. data/lib/puppet/util/terminal.rb +16 -0
  106. data/lib/puppet/util/zaml.rb +3 -1
  107. data/lib/semver.rb +15 -7
  108. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
  109. data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
  110. data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
  111. data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
  112. data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
  113. data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
  114. data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
  115. data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
  116. data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
  117. data/spec/integration/faces/documentation_spec.rb +1 -1
  118. data/spec/integration/network/rest_authconfig_spec.rb +1 -1
  119. data/spec/lib/puppet_spec/compiler.rb +6 -0
  120. data/spec/lib/puppet_spec/database.rb +30 -0
  121. data/spec/lib/puppet_spec/files.rb +4 -2
  122. data/spec/shared_behaviours/path_parameters.rb +2 -29
  123. data/spec/shared_contexts/platform.rb +43 -0
  124. data/spec/spec_helper.rb +36 -65
  125. data/spec/unit/agent_spec.rb +0 -32
  126. data/spec/unit/application/kick_spec.rb +2 -2
  127. data/spec/unit/daemon_spec.rb +1 -17
  128. data/spec/unit/face/module/install_spec.rb +158 -0
  129. data/spec/unit/face/module/list_spec.rb +182 -0
  130. data/spec/unit/face/module/search_spec.rb +163 -0
  131. data/spec/unit/face/module/uninstall_spec.rb +77 -0
  132. data/spec/unit/face/module/upgrade_spec.rb +26 -0
  133. data/spec/unit/forge/repository_spec.rb +0 -30
  134. data/spec/unit/forge_spec.rb +28 -86
  135. data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
  136. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
  137. data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
  138. data/spec/unit/indirector/resource/ral_spec.rb +7 -2
  139. data/spec/unit/module_spec.rb +240 -107
  140. data/spec/unit/module_tool/application_spec.rb +3 -5
  141. data/spec/unit/module_tool/applications/application_spec.rb +19 -0
  142. data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
  143. data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
  144. data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
  145. data/spec/unit/module_tool/metadata_spec.rb +2 -2
  146. data/spec/unit/module_tool_spec.rb +109 -1
  147. data/spec/unit/node/environment_spec.rb +16 -1
  148. data/spec/unit/parser/ast/leaf_spec.rb +16 -1
  149. data/spec/unit/parser/collector_spec.rb +2 -12
  150. data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
  151. data/spec/unit/parser/functions/generate_spec.rb +2 -10
  152. data/spec/unit/parser/scope_spec.rb +345 -16
  153. data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
  154. data/spec/unit/provider/exec/shell_spec.rb +17 -14
  155. data/spec/unit/provider/exec/windows_spec.rb +1 -7
  156. data/spec/unit/provider/exec_spec.rb +35 -0
  157. data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
  158. data/spec/unit/provider/package/dpkg_spec.rb +2 -1
  159. data/spec/unit/provider/package/gem_spec.rb +15 -0
  160. data/spec/unit/provider/package/openbsd_spec.rb +5 -4
  161. data/spec/unit/provider/package/pacman_spec.rb +3 -2
  162. data/spec/unit/provider/package/pkg_spec.rb +56 -33
  163. data/spec/unit/provider/selmodule_spec.rb +11 -4
  164. data/spec/unit/provider/service/redhat_spec.rb +1 -3
  165. data/spec/unit/provider/service/smf_spec.rb +1 -3
  166. data/spec/unit/provider/service/upstart_spec.rb +38 -0
  167. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
  168. data/spec/unit/rails/host_spec.rb +6 -12
  169. data/spec/unit/rails/param_value_spec.rb +3 -8
  170. data/spec/unit/rails/resource_spec.rb +2 -8
  171. data/spec/unit/reports/http_spec.rb +47 -31
  172. data/spec/unit/reports/tagmail_spec.rb +77 -0
  173. data/spec/unit/resource/type_spec.rb +2 -2
  174. data/spec/unit/resource_spec.rb +18 -20
  175. data/spec/unit/semver_spec.rb +31 -13
  176. data/spec/unit/type/exec_spec.rb +8 -15
  177. data/spec/unit/type/group_spec.rb +0 -9
  178. data/spec/unit/type/package_spec.rb +10 -0
  179. data/spec/unit/type/resources_spec.rb +4 -5
  180. data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
  181. data/spec/unit/type/sshkey_spec.rb +9 -11
  182. data/spec/unit/type/user_spec.rb +123 -127
  183. data/spec/unit/type_spec.rb +20 -0
  184. data/spec/unit/util/command_line_spec.rb +2 -2
  185. data/spec/unit/util/instrumentation/data_spec.rb +1 -1
  186. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
  187. data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
  188. data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
  189. data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
  190. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
  191. data/spec/unit/util/instrumentation_spec.rb +1 -1
  192. data/spec/unit/util/log/destinations_spec.rb +4 -8
  193. data/spec/unit/util/log_spec.rb +47 -0
  194. data/spec/unit/util/reference_spec.rb +1 -1
  195. data/spec/unit/util/settings/file_setting_spec.rb +9 -0
  196. data/spec/unit/util/settings_spec.rb +0 -53
  197. data/spec/unit/util/terminal_spec.rb +42 -0
  198. data/spec/unit/util/zaml_spec.rb +7 -0
  199. data/spec/unit/util_spec.rb +63 -20
  200. data/tasks/rake/manpages.rake +1 -1
  201. data/test/data/snippets/arithmetic_expression.pp +1 -1
  202. data/test/other/puppet.rb +0 -1
  203. data/test/util/log.rb +6 -6
  204. metadata +41 -16
  205. data/lib/puppet/external/event-loop.rb +0 -1
  206. data/lib/puppet/external/event-loop/better-definers.rb +0 -367
  207. data/lib/puppet/external/event-loop/event-loop.rb +0 -355
  208. data/lib/puppet/external/event-loop/signal-system.rb +0 -218
  209. data/lib/puppet/face/module/clean.rb +0 -30
  210. data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
  211. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
  212. data/lib/puppet/module_tool/utils.rb +0 -5
  213. data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
  214. data/spec/integration/module_tool_spec.rb +0 -475
  215. data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -23,4 +23,4 @@ class Puppet::Util::NetworkDevice::Transport::Base
23
23
  end
24
24
  end
25
25
 
26
- end
26
+ end
@@ -118,4 +118,4 @@ class Puppet::Util::NetworkDevice::Transport::Ssh < Puppet::Util::NetworkDevice:
118
118
  end
119
119
  end
120
120
  end
121
- end
121
+ end
@@ -1,7 +1,6 @@
1
1
  require 'puppet'
2
2
  require 'sync'
3
3
  require 'getoptlong'
4
- require 'puppet/external/event-loop'
5
4
  require 'puppet/util/loadedfile'
6
5
 
7
6
  # The class for handling configuration files.
@@ -296,10 +295,6 @@ class Puppet::Util::Settings
296
295
  @sync.synchronize do
297
296
  unsafe_parse(self[:config])
298
297
  end
299
-
300
- # Create a timer so that this file will get checked automatically
301
- # and reparsed if necessary.
302
- set_filetimeout_timer
303
298
  end
304
299
 
305
300
  # Unsafely parse the file -- this isn't thread-safe and causes plenty of problems if used directly.
@@ -549,12 +544,6 @@ class Puppet::Util::Settings
549
544
  call.each { |setting| setting.handle(self.value(setting.name)) }
550
545
  end
551
546
 
552
- # Create a timer to check whether the file should be reparsed.
553
- def set_filetimeout_timer
554
- return unless timeout = self[:filetimeout] and timeout = Integer(timeout) and timeout > 0
555
- timer = EventLoop::Timer.new(:interval => timeout, :tolerance => 1, :start? => true) { self.reparse }
556
- end
557
-
558
547
  # Convert the settings we manage into a catalog full of resources that model those settings.
559
548
  def to_catalog(*sections)
560
549
  sections = nil if sections.empty?
@@ -932,4 +921,6 @@ if @config.include?(:run_mode)
932
921
  end
933
922
  end
934
923
  end
924
+
925
+
935
926
  end
@@ -50,12 +50,10 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
50
50
  def munge(value)
51
51
  # If it's not a fully qualified path...
52
52
  if value.is_a?(String) and value !~ /^\$/ and value != 'false'
53
- # Make it one
53
+ # Preserve trailing slash (stripped by expand_path)
54
+ isdir = value =~ /\/$/
54
55
  value = File.expand_path(value)
55
- end
56
- if value.to_s =~ /\/$/
57
- @type = :directory
58
- return value.sub(/\/$/, '')
56
+ value += '/' if isdir
59
57
  end
60
58
  value
61
59
  end
@@ -0,0 +1,16 @@
1
+ module Puppet::Util::Terminal
2
+ # Attempts to determine the width of the terminal. This is currently only
3
+ # supported on POSIX systems, and relies on the claims of `stty` (or `tput`).
4
+ #
5
+ # Inspired by code from Thor; thanks wycats!
6
+ # @return [Number] The column width of the terminal. Defaults to 80 columns.
7
+ def self.width
8
+ if Puppet.features.posix?
9
+ result = %x{stty size 2>/dev/null}.split[1] ||
10
+ %x{tput cols 2>/dev/null}.split[0]
11
+ end
12
+ return (result || '80').to_i
13
+ rescue
14
+ return 80
15
+ end
16
+ end
@@ -242,7 +242,9 @@ class String
242
242
  end
243
243
  def to_zaml(z)
244
244
  z.first_time_only(self) {
245
- num = '[-+]?(0x)?\d+\.?\d*'
245
+ hex_num = '0x[a-f\d]+'
246
+ float = '\d+\.?\d*'
247
+ num = "[-+]?(?:#{float}|#{hex_num})"
246
248
  case
247
249
  when self == ''
248
250
  z.emit('""')
@@ -17,17 +17,21 @@ class SemVer < Numeric
17
17
  versions.select { |v| v.matched_by?("#{pattern}") }.sort.last
18
18
  end
19
19
 
20
+ def self.pre(vstring)
21
+ vstring =~ /-/ ? vstring : vstring + '-'
22
+ end
23
+
20
24
  def self.[](range)
21
25
  range.gsub(/([><=])\s+/, '\1').split(/\b\s+(?!-)/).map do |r|
22
26
  case r
23
27
  when SemVer::VERSION
24
- SemVer.new(r + '-') .. SemVer.new(r)
28
+ SemVer.new(pre(r)) .. SemVer.new(r)
25
29
  when SemVer::SIMPLE_RANGE
26
30
  r += ".0" unless SemVer.valid?(r.gsub(/x/i, '0'))
27
31
  SemVer.new(r.gsub(/x/i, '0'))...SemVer.new(r.gsub(/(\d+)\.x/i) { "#{$1.to_i + 1}.0" } + '-')
28
32
  when /\s+-\s+/
29
33
  a, b = r.split(/\s+-\s+/)
30
- SemVer.new(a + '-') .. SemVer.new(b)
34
+ SemVer.new(pre(a)) .. SemVer.new(b)
31
35
  when /^~/
32
36
  ver = r.sub(/~/, '').split('.').map(&:to_i)
33
37
  start = (ver + [0] * (3 - ver.length)).join('.')
@@ -36,20 +40,24 @@ class SemVer < Numeric
36
40
  ver[-1] = ver.last + 1
37
41
 
38
42
  finish = (ver + [0] * (3 - ver.length)).join('.')
39
- SemVer.new(start + '-') ... SemVer.new(finish + '-')
43
+ SemVer.new(pre(start)) ... SemVer.new(pre(finish))
40
44
  when /^>=/
41
45
  ver = r.sub(/^>=/, '')
42
- SemVer.new(ver + '-') .. SemVer::MAX
46
+ SemVer.new(pre(ver)) .. SemVer::MAX
43
47
  when /^<=/
44
48
  ver = r.sub(/^<=/, '')
45
49
  SemVer::MIN .. SemVer.new(ver)
46
50
  when /^>/
47
- ver = r.sub(/^>/, '').split('.').map(&:to_i)
48
- ver[2] = ver.last + 1
51
+ if r =~ /-/
52
+ ver = [r[1..-1]]
53
+ else
54
+ ver = r.sub(/^>/, '').split('.').map(&:to_i)
55
+ ver[2] = ver.last + 1
56
+ end
49
57
  SemVer.new(ver.join('.') + '-') .. SemVer::MAX
50
58
  when /^</
51
59
  ver = r.sub(/^</, '')
52
- SemVer::MIN ... SemVer.new(ver + '-')
60
+ SemVer::MIN ... SemVer.new(pre(ver))
53
61
  else
54
62
  (1..1)
55
63
  end
@@ -1 +1 @@
1
- {"dependencies":[],"types":[{"providers":[{"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. "}],"parameters":[{"name":"name","doc":"The name of the module to be managed"}],"properties":[{"name":"ensure","doc":"The basic property that the resource should be in. Valid values are ``present``, ``absent``."}],"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu"}],"checksums":{"manifests/params.pp":"71734796921dbdbfd58f503622527616","tests/ssl.pp":"191912535199531fd631f911c6329e56","tests/vhost.pp":"1b91e03c8ef89a7ecb6793831ac18399","manifests/php.pp":"b78cc593f1c4cd800c906e0891c9b11f","files/httpd":"295f5e924afe6f752d29327e73fe6d0a","tests/php.pp":"ce7bb9eef69d32b42a32ce32d9653625","lib/puppet/provider/a2mod/a2mod.rb":"18c5bb180b75a2375e95e07f88a94257","files/test.vhost":"0602022c19a7b6b289f218c7b93c1aea","manifests/ssl.pp":"b4334a161a2ba5fa8a62cf7b38f352c8","manifests/dev.pp":"510813942246cc9a7786d8f2d8874a35","manifests/vhost.pp":"cbc4657b0cce5cd432057393d5f6b0c2","tests/init.pp":"4eac4a7ef68499854c54a78879e25535","lib/puppet/type/a2mod.rb":"0e1b4843431413a10320ac1f6a055d15","tests/apache.pp":"4eac4a7ef68499854c54a78879e25535","tests/dev.pp":"4cf15c1fecea3ca86009f182b402c7ab","templates/vhost-default.conf.erb":"9055aed946e1111c30ab81fedac2c8b0","manifests/init.pp":"dc503e26e8021351078813b541c4bd3d","Modulefile":"d43334b4072cd1744121b3b25cd9ed15"},"version":"0.0.1","name":"jamtur01-apache"}
1
+ {"dependencies":[],"types":[{"providers":[{"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. "}],"parameters":[{"name":"name","doc":"The name of the module to be managed"}],"properties":[{"name":"ensure","doc":"The basic property that the resource should be in. Valid values are ``present``, ``absent``."}],"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu"}],"checksums":{"manifests/params.pp":"71734796921dbdbfd58f503622527616","tests/ssl.pp":"191912535199531fd631f911c6329e56","tests/vhost.pp":"1b91e03c8ef89a7ecb6793831ac18399","manifests/php.pp":"b78cc593f1c4cd800c906e0891c9b11f","files/httpd":"295f5e924afe6f752d29327e73fe6d0a","tests/php.pp":"ce7bb9eef69d32b42a32ce32d9653625","lib/puppet/provider/a2mod/a2mod.rb":"18c5bb180b75a2375e95e07f88a94257","files/test.vhost":"0602022c19a7b6b289f218c7b93c1aea","manifests/ssl.pp":"b4334a161a2ba5fa8a62cf7b38f352c8","manifests/dev.pp":"510813942246cc9a7786d8f2d8874a35","manifests/vhost.pp":"cbc4657b0cce5cd432057393d5f6b0c2","tests/init.pp":"4eac4a7ef68499854c54a78879e25535","lib/puppet/type/a2mod.rb":"0e1b4843431413a10320ac1f6a055d15","tests/apache.pp":"4eac4a7ef68499854c54a78879e25535","tests/dev.pp":"4cf15c1fecea3ca86009f182b402c7ab","templates/vhost-default.conf.erb":"9055aed946e1111c30ab81fedac2c8b0","manifests/init.pp":"dc503e26e8021351078813b541c4bd3d","Modulefile":"d43334b4072cd1744121b3b25cd9ed15"},"version":"0.0.1","name":"jamtur01-apache"}
@@ -5,4 +5,4 @@ $two = 2.034e-2
5
5
  $result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9)
6
6
 
7
7
 
8
- notice("result is $result == 1295.87692307692")
8
+ notice("result is $result == 1295.87692307692")
@@ -0,0 +1 @@
1
+ dummy 2.5.5-0.111 installed ----
@@ -0,0 +1 @@
1
+ dummy 2.5.5-0.111 installed ---- RANDOM_TRASH
@@ -0,0 +1,2 @@
1
+ SUNWpcre (solaris) 8.8-0.111 installed ----
2
+ service/network/ssh (solaris) 0.5.11-0.151.0.1 installed -----
@@ -0,0 +1,4 @@
1
+ SUNPython 2.5.5-0.111 installed ----
2
+ SUNWbind 9.3.6.1-0.111 installed ----
3
+ SUNWdistro-license-copyright 0.5.11-0.111 installed ----
4
+ SUNWfppd 0.2008.8.18-0.111 installed ----
@@ -0,0 +1,2 @@
1
+ secure: user@domain.com
2
+
@@ -61,4 +61,4 @@
61
61
  - Total
62
62
  - 0
63
63
  records: {}
64
- time: 2010-09-23 16:17:26.987789 -07:00
64
+ time: 2010-09-23 16:17:26.987789 -07:00
@@ -187,4 +187,4 @@
187
187
  - hourly
188
188
  time: 2010-09-23 15:44:06.432185 -07:00
189
189
  version: 1285281846
190
- time: 2010-09-23 15:44:05.894401 -07:00
190
+ time: 2010-09-23 15:44:05.894401 -07:00
@@ -49,7 +49,7 @@ describe "documentation of faces" do
49
49
  # REVISIT: This is less that ideal, I think, but right now I am more
50
50
  # comfortable watching us ship with some copyright than without any; we
51
51
  # can redress that when it becomes appropriate. --daniel 2011-04-27
52
- its :copyright do should =~ /2011/ end
52
+ its :copyright do should =~ /20\d{2}/ end
53
53
  end
54
54
  end
55
55
  end
@@ -142,4 +142,4 @@ describe Puppet::Network::RestAuthConfig do
142
142
  @auth.should_not allow(request)
143
143
  end
144
144
 
145
- end
145
+ end
@@ -0,0 +1,6 @@
1
+ module PuppetSpec::Compiler
2
+ def compile_to_catalog(string)
3
+ Puppet[:code] = string
4
+ Puppet::Parser::Compiler.compile(Puppet::Node.new('foonode'))
5
+ end
6
+ end
@@ -0,0 +1,30 @@
1
+ # This just makes some nice things available at global scope, and for setup of
2
+ # tests to use a real fake database, rather than a fake stubs-that-don't-work
3
+ # version of the same. Fun times.
4
+ def sqlite?
5
+ if $sqlite.nil?
6
+ begin
7
+ require 'sqlite3'
8
+ $sqlite = true
9
+ rescue LoadError
10
+ $sqlite = false
11
+ end
12
+ end
13
+ $sqlite
14
+ end
15
+
16
+ def can_use_scratch_database?
17
+ sqlite? and Puppet.features.rails?
18
+ end
19
+
20
+
21
+ # This is expected to be called in your `before :each` block, and will get you
22
+ # ready to roll with a serious database and all. Cleanup is handled
23
+ # automatically for you. Nothing to do there.
24
+ def setup_scratch_database
25
+ dir = PuppetSpec::Files.tmpdir('puppet-sqlite')
26
+ Puppet[:dbadapter] = 'sqlite3'
27
+ Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
28
+ Puppet[:railslog] = '/dev/null'
29
+ Puppet::Rails.init
30
+ end
@@ -35,7 +35,8 @@ module PuppetSpec::Files
35
35
  path
36
36
  end
37
37
 
38
- def tmpfile(name)
38
+ def tmpfile(name) PuppetSpec::Files.tmpfile(name) end
39
+ def self.tmpfile(name)
39
40
  # Generate a temporary file, just for the name...
40
41
  source = Tempfile.new(name)
41
42
  path = source.path
@@ -49,7 +50,8 @@ module PuppetSpec::Files
49
50
  path
50
51
  end
51
52
 
52
- def tmpdir(name)
53
+ def tmpdir(name) PuppetSpec::Files.tmpdir(name) end
54
+ def self.tmpdir(name)
53
55
  path = tmpfile(name)
54
56
  FileUtils.mkdir_p(path)
55
57
  path
@@ -87,26 +87,7 @@ shared_examples_for "all path parameters" do |param, options|
87
87
  @param = param
88
88
  end
89
89
 
90
- before :each do
91
- @file_separator = File::SEPARATOR
92
- end
93
- after :each do
94
- with_verbose_disabled do
95
- verbose, $VERBOSE = $VERBOSE, nil
96
- File::SEPARATOR = @file_separator
97
- $VERBOSE = verbose
98
- end
99
- end
100
-
101
- describe "on a Unix-like platform it" do
102
- before :each do
103
- with_verbose_disabled do
104
- File::SEPARATOR = '/'
105
- end
106
- Puppet.features.stubs(:microsoft_windows?).returns(false)
107
- Puppet.features.stubs(:posix?).returns(true)
108
- end
109
-
90
+ describe "on a Unix-like platform it", :as_platform => :posix do
110
91
  if array then
111
92
  it_should_behave_like "all pathname parameters with arrays", false
112
93
  end
@@ -134,15 +115,7 @@ shared_examples_for "all path parameters" do |param, options|
134
115
  end
135
116
  end
136
117
 
137
- describe "on a Windows-like platform it" do
138
- before :each do
139
- with_verbose_disabled do
140
- File::SEPARATOR = '\\'
141
- end
142
- Puppet.features.stubs(:microsoft_windows?).returns(true)
143
- Puppet.features.stubs(:posix?).returns(false)
144
- end
145
-
118
+ describe "on a Windows-like platform it", :as_platform => :windows do
146
119
  if array then
147
120
  it_should_behave_like "all pathname parameters with arrays", true
148
121
  end
@@ -0,0 +1,43 @@
1
+ # Contexts for stubbing platforms
2
+ # In a describe or context block, adding :as_platform => :windows or
3
+ # :as_platform => :posix will stub the relevant Puppet features, as well as
4
+ # the behavior of Ruby's filesystem methods by changing File::ALT_SEPARATOR.
5
+
6
+ shared_context "windows", :as_platform => :windows do
7
+ before :each do
8
+ Facter.stubs(:value).with(:operatingsystem).returns 'Windows'
9
+ Puppet.features.stubs(:microsoft_windows?).returns(true)
10
+ Puppet.features.stubs(:posix?).returns(false)
11
+ end
12
+
13
+ around do |example|
14
+ file_alt_separator = File::ALT_SEPARATOR
15
+ # prevent Ruby from warning about changing a constant
16
+ with_verbose_disabled do
17
+ File::ALT_SEPARATOR = '\\'
18
+ end
19
+ example.run
20
+ with_verbose_disabled do
21
+ File::ALT_SEPARATOR = file_alt_separator
22
+ end
23
+ end
24
+ end
25
+
26
+ shared_context "posix", :as_platform => :posix do
27
+ before :each do
28
+ Puppet.features.stubs(:microsoft_windows?).returns(false)
29
+ Puppet.features.stubs(:posix?).returns(true)
30
+ end
31
+
32
+ around do |example|
33
+ file_alt_separator = File::ALT_SEPARATOR
34
+ # prevent Ruby from warning about changing a constant
35
+ with_verbose_disabled do
36
+ File::ALT_SEPARATOR = nil
37
+ end
38
+ example.run
39
+ with_verbose_disabled do
40
+ File::ALT_SEPARATOR = file_alt_separator
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,7 @@
1
+ # NOTE: a lot of the stuff in this file is duplicated in the "puppet_spec_helper" in the project
2
+ # puppetlabs_spec_helper. We should probably eat our own dog food and get rid of most of this from here,
3
+ # and have the puppet core itself use puppetlabs_spec_helper
4
+
1
5
  dir = File.expand_path(File.dirname(__FILE__))
2
6
  $LOAD_PATH.unshift File.join(dir, 'lib')
3
7
 
@@ -21,8 +25,14 @@ require 'puppet_spec/verbose'
21
25
  require 'puppet_spec/files'
22
26
  require 'puppet_spec/fixtures'
23
27
  require 'puppet_spec/matchers'
28
+ require 'puppet_spec/database'
24
29
  require 'monkey_patches/alias_should_to_must'
25
30
  require 'monkey_patches/publicize_methods'
31
+ require 'puppet/test/test_helper'
32
+
33
+ Pathname.glob("#{dir}/shared_contexts/*.rb") do |file|
34
+ require file.relative_path_from(Pathname.new(dir))
35
+ end
26
36
 
27
37
  Pathname.glob("#{dir}/shared_behaviours/**/*.rb") do |behaviour|
28
38
  require behaviour.relative_path_from(Pathname.new(dir))
@@ -33,97 +43,58 @@ RSpec.configure do |config|
33
43
 
34
44
  config.mock_with :mocha
35
45
 
46
+ config.before :all do
47
+ Puppet::Test::TestHelper.before_all_tests()
48
+ end
49
+
50
+ config.after :all do
51
+ Puppet::Test::TestHelper.after_all_tests()
52
+ end
53
+
36
54
  config.before :each do
37
55
  # Disabling garbage collection inside each test, and only running it at
38
56
  # the end of each block, gives us an ~ 15 percent speedup, and more on
39
57
  # some platforms *cough* windows *cough* that are a little slower.
40
58
  GC.disable
41
59
 
42
- # We need to preserve the current state of all our indirection cache and
43
- # terminus classes. This is pretty important, because changes to these
44
- # are global and lead to order dependencies in our testing.
45
- #
46
- # We go direct to the implementation because there is no safe, sane public
47
- # API to manage restoration of these to their default values. This
48
- # should, once the value is proved, be moved to a standard API on the
49
- # indirector.
50
- #
51
- # To make things worse, a number of the tests stub parts of the
52
- # indirector. These stubs have very specific expectations that what
53
- # little of the public API we could use is, well, likely to explode
54
- # randomly in some tests. So, direct access. --daniel 2011-08-30
55
- $saved_indirection_state = {}
56
- indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
57
- indirections.each do |indirector|
58
- $saved_indirection_state[indirector.name] = {
59
- :@terminus_class => indirector.instance_variable_get(:@terminus_class),
60
- :@cache_class => indirector.instance_variable_get(:@cache_class)
61
- }
62
- end
63
-
64
- # these globals are set by Application
65
- $puppet_application_mode = nil
66
- $puppet_application_name = nil
67
-
68
60
  # REVISIT: I think this conceals other bad tests, but I don't have time to
69
61
  # fully diagnose those right now. When you read this, please come tell me
70
62
  # I suck for letting this float. --daniel 2011-04-21
71
63
  Signal.stubs(:trap)
72
64
 
73
- # Longer keys are secure, but they sure make for some slow testing - both
74
- # in terms of generating keys, and in terms of anything the next step down
75
- # the line doing validation or whatever. Most tests don't care how long
76
- # or secure it is, just that it exists, so these are better and faster
77
- # defaults, in testing only.
78
- #
79
- # I would make these even shorter, but OpenSSL doesn't support anything
80
- # below 512 bits. Sad, really, because a 0 bit key would be just fine.
81
- Puppet[:req_bits] = 512
82
- Puppet[:keylength] = 512
83
-
84
- # Set the confdir and vardir to gibberish so that tests
85
- # have to be correctly mocked.
86
- Puppet[:confdir] = "/dev/null"
87
- Puppet[:vardir] = "/dev/null"
88
-
89
- # Avoid opening ports to the outside world
90
- Puppet.settings[:bindaddress] = "127.0.0.1"
91
65
 
66
+ # TODO: in a more sane world, we'd move this logging redirection into our TestHelper class.
67
+ # Without doing so, external projects will all have to roll their own solution for
68
+ # redirecting logging, and for validating expected log messages. However, because the
69
+ # current implementation of this involves creating an instance variable "@logs" on
70
+ # EVERY SINGLE TEST CLASS, and because there are over 1300 tests that are written to expect
71
+ # this instance variable to be available--we can't easily solve this problem right now.
72
+ #
73
+ # redirecting logging away from console, because otherwise the test output will be
74
+ # obscured by all of the log output
92
75
  @logs = []
93
76
  Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
94
77
 
95
78
  @log_level = Puppet::Util::Log.level
79
+
80
+ Puppet::Test::TestHelper.before_each_test()
81
+
96
82
  end
97
83
 
98
84
  config.after :each do
99
- Puppet.settings.clear
100
- Puppet::Node::Environment.clear
101
- Puppet::Util::Storage.clear
102
- Puppet::Util::ExecutionStub.reset
85
+ Puppet::Test::TestHelper.after_each_test()
103
86
 
87
+ # TODO: would like to move this into puppetlabs_spec_helper, but there are namespace issues at the moment.
104
88
  PuppetSpec::Files.cleanup
105
89
 
90
+ # TODO: this should be abstracted in the future--see comments above the '@logs' block in the
91
+ # "before" code above.
92
+ #
93
+ # clean up after the logging changes that we made before each test.
106
94
  @logs.clear
107
95
  Puppet::Util::Log.close_all
108
96
  Puppet::Util::Log.level = @log_level
109
97
 
110
- # Restore the indirector configuration. See before hook.
111
- indirections = Puppet::Indirector::Indirection.send(:class_variable_get, :@@indirections)
112
- indirections.each do |indirector|
113
- $saved_indirection_state.fetch(indirector.name, {}).each do |variable, value|
114
- indirector.instance_variable_set(variable, value)
115
- end
116
- end
117
- $saved_indirection_state = nil
118
-
119
- # Some tests can cause us to connect, in which case the lingering
120
- # connection is a resource that can cause unexpected failure in later
121
- # tests, as well as sharing state accidentally.
122
- # We're testing if ActiveRecord::Base is defined because some test cases
123
- # may stub Puppet.features.rails? which is how we should normally
124
- # introspect for this functionality.
125
- ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base)
126
-
127
98
  # This will perform a GC between tests, but only if actually required. We
128
99
  # experimented with forcing a GC run, and that was less efficient than
129
100
  # just letting it run all the time.