puppet 0.24.1 → 0.24.2

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 (266) hide show
  1. data/CHANGELOG +94 -0
  2. data/Rakefile +0 -4
  3. data/bin/puppet +18 -10
  4. data/bin/puppetd +1 -1
  5. data/bin/puppetdoc +14 -4
  6. data/bin/puppetmasterd +1 -1
  7. data/bin/puppetrun +3 -8
  8. data/bin/ralsh +12 -11
  9. data/conf/freebsd/puppetd +1 -1
  10. data/conf/freebsd/puppetmasterd +1 -1
  11. data/conf/gentoo/puppet/puppet.conf +29 -0
  12. data/conf/namespaceauth.conf +20 -0
  13. data/conf/redhat/puppet.spec +4 -1
  14. data/conf/solaris/smf/puppetd.xml +1 -1
  15. data/conf/solaris/smf/puppetmasterd.xml +1 -1
  16. data/conf/suse/puppet.spec +10 -8
  17. data/examples/root/etc/puppet/{puppetmasterd.conf → puppet.conf} +6 -3
  18. data/ext/logcheck/puppet +7 -0
  19. data/ext/puppet-test +28 -5
  20. data/lib/puppet.rb +2 -1
  21. data/lib/puppet/defaults.rb +12 -5
  22. data/lib/puppet/dsl.rb +43 -45
  23. data/lib/puppet/external/{gratr/rdot.rb → dot.rb} +0 -0
  24. data/lib/puppet/external/nagios.rb +50 -0
  25. data/lib/puppet/external/nagios/base.rb +421 -0
  26. data/lib/puppet/external/nagios/parser.rb +816 -0
  27. data/lib/puppet/file_serving/file_base.rb +16 -3
  28. data/lib/puppet/file_serving/metadata.rb +29 -11
  29. data/lib/puppet/indirector/terminus.rb +1 -0
  30. data/lib/puppet/metatype/closure.rb +4 -0
  31. data/lib/puppet/metatype/evaluation.rb +2 -17
  32. data/lib/puppet/metatype/metaparams.rb +1 -1
  33. data/lib/puppet/network.rb +3 -0
  34. data/lib/puppet/network/client.rb +4 -5
  35. data/lib/puppet/network/client/master.rb +10 -7
  36. data/lib/puppet/network/handler/fileserver.rb +22 -45
  37. data/lib/puppet/network/http_pool.rb +3 -0
  38. data/lib/puppet/network/http_server/mongrel.rb +7 -1
  39. data/lib/puppet/network/http_server/webrick.rb +4 -3
  40. data/lib/puppet/network/xmlrpc/client.rb +12 -1
  41. data/lib/puppet/node/catalog.rb +51 -40
  42. data/lib/puppet/parser/ast.rb +27 -49
  43. data/lib/puppet/parser/ast/astarray.rb +5 -24
  44. data/lib/puppet/parser/ast/caseopt.rb +4 -4
  45. data/lib/puppet/parser/ast/casestatement.rb +4 -5
  46. data/lib/puppet/parser/ast/collection.rb +3 -5
  47. data/lib/puppet/parser/ast/collexpr.rb +3 -5
  48. data/lib/puppet/parser/ast/definition.rb +148 -159
  49. data/lib/puppet/parser/ast/else.rb +2 -3
  50. data/lib/puppet/parser/ast/function.rb +3 -10
  51. data/lib/puppet/parser/ast/hostclass.rb +66 -59
  52. data/lib/puppet/parser/ast/ifstatement.rb +4 -5
  53. data/lib/puppet/parser/ast/leaf.rb +6 -6
  54. data/lib/puppet/parser/ast/node.rb +26 -58
  55. data/lib/puppet/parser/ast/resource.rb +5 -7
  56. data/lib/puppet/parser/ast/resource_defaults.rb +2 -4
  57. data/lib/puppet/parser/ast/resource_override.rb +4 -6
  58. data/lib/puppet/parser/ast/resource_reference.rb +2 -4
  59. data/lib/puppet/parser/ast/resourceparam.rb +2 -4
  60. data/lib/puppet/parser/ast/selector.rb +5 -6
  61. data/lib/puppet/parser/ast/tag.rb +2 -4
  62. data/lib/puppet/parser/ast/vardef.rb +3 -4
  63. data/lib/puppet/parser/collector.rb +5 -5
  64. data/lib/puppet/parser/{compile.rb → compiler.rb} +69 -107
  65. data/lib/puppet/parser/functions.rb +3 -3
  66. data/lib/puppet/parser/interpreter.rb +32 -23
  67. data/lib/puppet/parser/lexer.rb +391 -282
  68. data/lib/puppet/parser/parser.rb +5 -4
  69. data/lib/puppet/parser/parser_support.rb +3 -6
  70. data/lib/puppet/parser/resource.rb +24 -36
  71. data/lib/puppet/parser/resource/param.rb +1 -1
  72. data/lib/puppet/parser/resource/reference.rb +7 -3
  73. data/lib/puppet/parser/scope.rb +12 -7
  74. data/lib/puppet/parser/templatewrapper.rb +1 -1
  75. data/lib/puppet/pgraph.rb +9 -98
  76. data/lib/puppet/provider/interface/redhat.rb +65 -65
  77. data/lib/puppet/provider/mount/parsed.rb +1 -1
  78. data/lib/puppet/provider/naginator.rb +55 -0
  79. data/lib/puppet/provider/nameservice/directoryservice.rb +6 -7
  80. data/lib/puppet/provider/package/fink.rb +0 -2
  81. data/lib/puppet/provider/package/gem.rb +9 -5
  82. data/lib/puppet/provider/package/openbsd.rb +1 -1
  83. data/lib/puppet/provider/package/pkgdmg.rb +3 -8
  84. data/lib/puppet/provider/package/portage.rb +4 -4
  85. data/lib/puppet/provider/package/yumhelper.py +8 -6
  86. data/lib/puppet/provider/parsedfile.rb +7 -1
  87. data/lib/puppet/provider/service/debian.rb +2 -0
  88. data/lib/puppet/provider/service/gentoo.rb +4 -0
  89. data/lib/puppet/provider/service/init.rb +1 -1
  90. data/lib/puppet/provider/sshkey/parsed.rb +2 -0
  91. data/lib/puppet/provider/user/useradd.rb +1 -1
  92. data/lib/puppet/rails.rb +4 -0
  93. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +17 -0
  94. data/lib/puppet/rails/fact_value.rb +4 -0
  95. data/lib/puppet/rails/host.rb +1 -2
  96. data/lib/puppet/rails/param_value.rb +4 -0
  97. data/lib/puppet/rails/resource_tag.rb +4 -0
  98. data/lib/puppet/rails/source_file.rb +4 -1
  99. data/lib/puppet/relationship.rb +5 -1
  100. data/lib/puppet/reports/tagmail.rb +12 -1
  101. data/lib/puppet/resource_reference.rb +1 -1
  102. data/lib/puppet/simple_graph.rb +78 -11
  103. data/lib/puppet/sslcertificates.rb +1 -1
  104. data/lib/puppet/sslcertificates/ca.rb +3 -3
  105. data/lib/puppet/transaction.rb +7 -4
  106. data/lib/puppet/transportable.rb +1 -1
  107. data/lib/puppet/type.rb +3 -10
  108. data/lib/puppet/type/cron.rb +18 -0
  109. data/lib/puppet/type/exec.rb +18 -12
  110. data/lib/puppet/type/{pfile.rb → file.rb} +66 -84
  111. data/lib/puppet/type/file/checksum.rb +271 -0
  112. data/lib/puppet/type/{pfile → file}/content.rb +10 -15
  113. data/lib/puppet/type/{pfile → file}/ensure.rb +15 -8
  114. data/lib/puppet/type/{pfile → file}/group.rb +0 -0
  115. data/lib/puppet/type/{pfile → file}/mode.rb +0 -0
  116. data/lib/puppet/type/{pfile → file}/owner.rb +0 -0
  117. data/lib/puppet/type/{pfile → file}/source.rb +34 -48
  118. data/lib/puppet/type/{pfile → file}/target.rb +0 -0
  119. data/lib/puppet/type/{pfile → file}/type.rb +0 -0
  120. data/lib/puppet/type/{pfilebucket.rb → filebucket.rb} +0 -0
  121. data/lib/puppet/type/host.rb +13 -0
  122. data/lib/puppet/type/mailalias.rb +1 -1
  123. data/lib/puppet/type/nagios_command.rb +3 -0
  124. data/lib/puppet/type/nagios_contact.rb +3 -0
  125. data/lib/puppet/type/nagios_contactgroup.rb +3 -0
  126. data/lib/puppet/type/nagios_host.rb +3 -0
  127. data/lib/puppet/type/nagios_hostextinfo.rb +3 -0
  128. data/lib/puppet/type/nagios_hostgroup.rb +3 -0
  129. data/lib/puppet/type/nagios_hostgroupescalation.rb +3 -0
  130. data/lib/puppet/type/nagios_service.rb +3 -0
  131. data/lib/puppet/type/nagios_servicedependency.rb +3 -0
  132. data/lib/puppet/type/nagios_serviceescalation.rb +3 -0
  133. data/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
  134. data/lib/puppet/type/nagios_timeperiod.rb +3 -0
  135. data/lib/puppet/type/package.rb +4 -12
  136. data/lib/puppet/type/service.rb +9 -0
  137. data/lib/puppet/type/sshkey.rb +3 -3
  138. data/lib/puppet/util/autoload.rb +5 -5
  139. data/lib/puppet/util/checksums.rb +51 -13
  140. data/lib/puppet/util/constant_inflector.rb +14 -0
  141. data/lib/puppet/util/filetype.rb +1 -1
  142. data/lib/puppet/util/graph.rb +3 -9
  143. data/lib/puppet/util/nagios_maker.rb +57 -0
  144. data/lib/puppet/util/settings.rb +19 -16
  145. data/lib/puppet/util/tagging.rb +39 -0
  146. data/test/executables/puppetbin.rb +17 -0
  147. data/test/language/ast.rb +8 -58
  148. data/test/language/ast/casestatement.rb +3 -3
  149. data/test/language/ast/resource.rb +6 -7
  150. data/test/language/ast/resource_reference.rb +12 -12
  151. data/test/language/ast/selector.rb +2 -2
  152. data/test/language/ast/variable.rb +2 -2
  153. data/test/language/functions.rb +24 -24
  154. data/test/language/parser.rb +20 -8
  155. data/test/language/resource.rb +5 -42
  156. data/test/language/scope.rb +21 -37
  157. data/test/language/snippets.rb +7 -0
  158. data/test/lib/puppettest.rb +28 -14
  159. data/test/lib/puppettest/parsertesting.rb +10 -10
  160. data/test/lib/puppettest/support/resources.rb +1 -1
  161. data/test/network/client/master.rb +10 -0
  162. data/test/network/handler/fileserver.rb +51 -49
  163. data/test/network/server/webrick.rb +1 -1
  164. data/test/other/dsl.rb +3 -4
  165. data/test/other/transactions.rb +6 -4
  166. data/test/rails/ast.rb +2 -2
  167. data/test/rails/configuration.rb +1 -1
  168. data/test/rails/railsparameter.rb +2 -0
  169. data/test/rails/railsresource.rb +1 -0
  170. data/test/ral/manager/type.rb +4 -4
  171. data/test/ral/providers/cron/crontab.rb +3 -1
  172. data/test/ral/providers/package.rb +1 -1
  173. data/test/ral/{types → type}/basic.rb +2 -2
  174. data/test/ral/{types → type}/cron.rb +0 -0
  175. data/test/ral/{types → type}/exec.rb +42 -2
  176. data/test/ral/{types → type}/file.rb +34 -79
  177. data/test/ral/{types → type}/file/target.rb +0 -0
  178. data/test/ral/{types → type}/filebucket.rb +0 -0
  179. data/test/ral/{types → type}/fileignoresource.rb +0 -0
  180. data/test/ral/{types → type}/filesources.rb +8 -27
  181. data/test/ral/{types → type}/group.rb +0 -0
  182. data/test/ral/{types → type}/host.rb +16 -0
  183. data/test/ral/{types → type}/mailalias.rb +0 -0
  184. data/test/ral/{types → type}/parameter.rb +0 -0
  185. data/test/ral/{types → type}/port.rb +0 -0
  186. data/test/ral/{types → type}/property.rb +0 -0
  187. data/test/ral/{types → type}/resources.rb +0 -0
  188. data/test/ral/{types → type}/service.rb +0 -0
  189. data/test/ral/{types → type}/sshkey.rb +0 -0
  190. data/test/ral/{types → type}/tidy.rb +1 -0
  191. data/test/ral/{types → type}/user.rb +0 -0
  192. data/test/ral/{types → type}/yumrepo.rb +0 -0
  193. data/test/ral/{types → type}/zone.rb +0 -0
  194. data/test/util/autoload.rb +24 -5
  195. metadata +60 -107
  196. data/conf/gentoo/puppet/puppetca.conf +0 -29
  197. data/conf/gentoo/puppet/puppetd.conf +0 -29
  198. data/conf/gentoo/puppet/puppetmasterd.conf +0 -29
  199. data/examples/root/etc/puppet/puppetd.conf +0 -4
  200. data/lib/puppet/external/gratr.rb +0 -33
  201. data/lib/puppet/external/gratr/adjacency_graph.rb +0 -257
  202. data/lib/puppet/external/gratr/base.rb +0 -34
  203. data/lib/puppet/external/gratr/biconnected.rb +0 -116
  204. data/lib/puppet/external/gratr/chinese_postman.rb +0 -123
  205. data/lib/puppet/external/gratr/common.rb +0 -73
  206. data/lib/puppet/external/gratr/comparability.rb +0 -92
  207. data/lib/puppet/external/gratr/digraph.rb +0 -116
  208. data/lib/puppet/external/gratr/digraph_distance.rb +0 -185
  209. data/lib/puppet/external/gratr/dot.rb +0 -90
  210. data/lib/puppet/external/gratr/edge.rb +0 -145
  211. data/lib/puppet/external/gratr/graph.rb +0 -303
  212. data/lib/puppet/external/gratr/graph_api.rb +0 -83
  213. data/lib/puppet/external/gratr/import.rb +0 -44
  214. data/lib/puppet/external/gratr/labels.rb +0 -90
  215. data/lib/puppet/external/gratr/maximum_flow.rb +0 -64
  216. data/lib/puppet/external/gratr/search.rb +0 -409
  217. data/lib/puppet/external/gratr/strong_components.rb +0 -127
  218. data/lib/puppet/external/gratr/undirected_graph.rb +0 -153
  219. data/lib/puppet/rails/external/tagging/acts_as_taggable.rb +0 -62
  220. data/lib/puppet/rails/external/tagging/init.rb +0 -5
  221. data/lib/puppet/rails/external/tagging/tag.rb +0 -50
  222. data/lib/puppet/rails/external/tagging/tagging.rb +0 -12
  223. data/lib/puppet/rails/puppet_class.rb +0 -6
  224. data/lib/puppet/reference/node_source.rb +0 -9
  225. data/lib/puppet/reference/report.rb +0 -21
  226. data/lib/puppet/type/pfile/checksum.rb +0 -326
  227. data/test/language/ast/definition.rb +0 -166
  228. data/test/language/ast/hostclass.rb +0 -184
  229. data/test/language/compile.rb +0 -569
  230. data/test/language/lexer.rb +0 -276
  231. data/test/lib/mocha.rb +0 -19
  232. data/test/lib/mocha/any_instance_method.rb +0 -35
  233. data/test/lib/mocha/auto_verify.rb +0 -113
  234. data/test/lib/mocha/central.rb +0 -35
  235. data/test/lib/mocha/class_method.rb +0 -62
  236. data/test/lib/mocha/deprecation.rb +0 -22
  237. data/test/lib/mocha/exception_raiser.rb +0 -17
  238. data/test/lib/mocha/expectation.rb +0 -378
  239. data/test/lib/mocha/expectation_error.rb +0 -6
  240. data/test/lib/mocha/infinite_range.rb +0 -25
  241. data/test/lib/mocha/inspect.rb +0 -39
  242. data/test/lib/mocha/instance_method.rb +0 -8
  243. data/test/lib/mocha/is_a.rb +0 -9
  244. data/test/lib/mocha/metaclass.rb +0 -7
  245. data/test/lib/mocha/missing_expectation.rb +0 -27
  246. data/test/lib/mocha/mock.rb +0 -207
  247. data/test/lib/mocha/multiple_yields.rb +0 -20
  248. data/test/lib/mocha/no_yields.rb +0 -11
  249. data/test/lib/mocha/object.rb +0 -110
  250. data/test/lib/mocha/parameter_matchers.rb +0 -9
  251. data/test/lib/mocha/parameter_matchers/all_of.rb +0 -39
  252. data/test/lib/mocha/parameter_matchers/any_of.rb +0 -44
  253. data/test/lib/mocha/parameter_matchers/anything.rb +0 -30
  254. data/test/lib/mocha/parameter_matchers/has_entry.rb +0 -39
  255. data/test/lib/mocha/parameter_matchers/has_key.rb +0 -39
  256. data/test/lib/mocha/parameter_matchers/has_value.rb +0 -39
  257. data/test/lib/mocha/parameter_matchers/includes.rb +0 -37
  258. data/test/lib/mocha/pretty_parameters.rb +0 -28
  259. data/test/lib/mocha/return_values.rb +0 -31
  260. data/test/lib/mocha/setup_and_teardown.rb +0 -23
  261. data/test/lib/mocha/single_return_value.rb +0 -24
  262. data/test/lib/mocha/single_yield.rb +0 -18
  263. data/test/lib/mocha/standalone.rb +0 -32
  264. data/test/lib/mocha/stub.rb +0 -18
  265. data/test/lib/mocha/test_case_adapter.rb +0 -49
  266. data/test/lib/mocha/yield_parameters.rb +0 -31
@@ -27,7 +27,7 @@ class TestScope < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_variables
30
- config = mkcompile
30
+ config = mkcompiler
31
31
  topscope = config.topscope
32
32
  midscope = config.newscope(topscope)
33
33
  botscope = config.newscope(midscope)
@@ -94,7 +94,7 @@ class TestScope < Test::Unit::TestCase
94
94
  classes = ["", "one", "one::two", "one::two::three"].each do |name|
95
95
  klass = parser.newclass(name)
96
96
  Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
97
- scopes[name] = scope.compile.class_scope(klass)
97
+ scopes[name] = scope.compiler.class_scope(klass)
98
98
  end
99
99
 
100
100
  classes.each do |name|
@@ -125,7 +125,7 @@ class TestScope < Test::Unit::TestCase
125
125
  end
126
126
 
127
127
  def test_setdefaults
128
- config = mkcompile
128
+ config = mkcompiler
129
129
 
130
130
  scope = config.topscope
131
131
 
@@ -151,7 +151,7 @@ class TestScope < Test::Unit::TestCase
151
151
  end
152
152
 
153
153
  def test_lookupdefaults
154
- config = mkcompile
154
+ config = mkcompiler
155
155
  top = config.topscope
156
156
 
157
157
  # Make a subscope
@@ -179,7 +179,7 @@ class TestScope < Test::Unit::TestCase
179
179
  end
180
180
 
181
181
  def test_parent
182
- config = mkcompile
182
+ config = mkcompiler
183
183
  top = config.topscope
184
184
 
185
185
  # Make a subscope
@@ -205,7 +205,7 @@ class TestScope < Test::Unit::TestCase
205
205
  %w{one one::two one::two::three}.each do |name|
206
206
  klass = parser.newclass(name)
207
207
  Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
208
- scopes[name] = scope.compile.class_scope(klass)
208
+ scopes[name] = scope.compiler.class_scope(klass)
209
209
  scopes[name].setvar("test", "value-%s" % name.sub(/.+::/,''))
210
210
  end
211
211
 
@@ -284,13 +284,13 @@ class TestScope < Test::Unit::TestCase
284
284
  )
285
285
 
286
286
  assert_nothing_raised do
287
- function.evaluate :scope => scope
287
+ function.evaluate scope
288
288
  end
289
289
 
290
- scope.compile.send(:evaluate_generators)
290
+ scope.compiler.send(:evaluate_generators)
291
291
 
292
292
  [myclass, otherclass].each do |klass|
293
- assert(scope.compile.class_scope(klass),
293
+ assert(scope.compiler.class_scope(klass),
294
294
  "%s was not set" % klass.classname)
295
295
  end
296
296
  end
@@ -328,18 +328,17 @@ class TestScope < Test::Unit::TestCase
328
328
  "undef considered true")
329
329
  end
330
330
 
331
- if defined? ActiveRecord
332
331
  # Verify that we recursively mark as exported the results of collectable
333
332
  # components.
334
- def test_exportedcomponents
335
- config = mkcompile
333
+ def test_virtual_definitions_do_not_get_evaluated
334
+ config = mkcompiler
336
335
  parser = config.parser
337
336
 
338
337
  # Create a default source
339
338
  config.topscope.source = parser.newclass "", ""
340
339
 
341
340
  # And a scope resource
342
- scope_res = stub 'scope_resource', :virtual? => true, :exported? => false, :tags => []
341
+ scope_res = stub 'scope_resource', :virtual? => true, :exported? => false, :tags => [], :builtin? => true, :type => "eh", :title => "bee"
343
342
  config.topscope.resource = scope_res
344
343
 
345
344
  args = AST::ASTArray.new(
@@ -348,7 +347,7 @@ class TestScope < Test::Unit::TestCase
348
347
  :children => [nameobj("arg")]
349
348
  )
350
349
 
351
- # Create a top-level component
350
+ # Create a top-level define
352
351
  parser.newdefine "one", :arguments => [%w{arg}],
353
352
  :code => AST::ASTArray.new(
354
353
  :children => [
@@ -356,41 +355,26 @@ class TestScope < Test::Unit::TestCase
356
355
  ]
357
356
  )
358
357
 
359
- # And a component that calls it
360
- parser.newdefine "two", :arguments => [%w{arg}],
361
- :code => AST::ASTArray.new(
362
- :children => [
363
- resourcedef("one", "ptest", {"arg" => varref("arg")})
364
- ]
365
- )
366
-
367
- # And then a third component that calls the second
368
- parser.newdefine "three", :arguments => [%w{arg}],
369
- :code => AST::ASTArray.new(
370
- :children => [
371
- resourcedef("two", "yay", {"arg" => varref("arg")})
372
- ]
373
- )
374
-
375
- # lastly, create an object that calls our third component
376
- obj = resourcedef("three", "boo", {"arg" => "parentfoo"})
358
+ # create a resource that calls our third define
359
+ obj = resourcedef("one", "boo", {"arg" => "parentfoo"})
377
360
 
378
- # And mark it as exported
379
- obj.exported = true
361
+ # And mark it as virtual
362
+ obj.virtual = true
380
363
 
381
364
  # And then evaluate it
382
- obj.evaluate :scope => config.topscope
365
+ obj.evaluate config.topscope
383
366
 
384
367
  # And run the loop.
385
368
  config.send(:evaluate_generators)
386
369
 
387
370
  %w{File}.each do |type|
388
- objects = config.resources.find_all { |r| r.type == type and r.exported }
371
+ objects = config.resources.find_all { |r| r.type == type and r.virtual }
389
372
 
390
- assert(!objects.empty?, "Did not get an exported %s" % type)
373
+ assert(objects.empty?, "Virtual define got evaluated")
391
374
  end
392
375
  end
393
376
 
377
+ if defined? ActiveRecord
394
378
  # Verify that we can both store and collect an object in the same
395
379
  # run, whether it's in the same scope as a collection or a different
396
380
  # scope.
@@ -15,6 +15,8 @@ class TestSnippets < Test::Unit::TestCase
15
15
  def setup
16
16
  super
17
17
  @file = Puppet::Type.type(:file)
18
+ Facter.stubs(:to_hash).returns({})
19
+ Facter.stubs(:value).returns("whatever")
18
20
  end
19
21
 
20
22
  def self.snippetdir
@@ -422,6 +424,11 @@ class TestSnippets < Test::Unit::TestCase
422
424
  assert_file("/tmp/realize_defined_test2")
423
425
  end
424
426
 
427
+ def snippet_collection_within_virtual_definitions
428
+ assert_file("/tmp/collection_within_virtual_definitions1_foo.txt")
429
+ assert_file("/tmp/collection_within_virtual_definitions2_foo2.txt")
430
+ end
431
+
425
432
  def snippet_fqparents
426
433
  assert_file("/tmp/fqparent1", "Did not make file from parent class")
427
434
  assert_file("/tmp/fqparent2", "Did not make file from subclass")
@@ -6,6 +6,17 @@ mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
6
6
  $LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib)
7
7
 
8
8
  require 'puppet'
9
+
10
+ # include any gems in vendor/gems
11
+ Dir["#{mainlib}/../vendor/gems/**"].each do |path|
12
+ libpath = File.join(path, "lib")
13
+ if File.directory?(libpath)
14
+ $LOAD_PATH.unshift(libpath)
15
+ else
16
+ $LOAD_PATH.unshift(path)
17
+ end
18
+ end
19
+
9
20
  require 'mocha'
10
21
 
11
22
  # Only load the test/unit class if we're not in the spec directory.
@@ -25,9 +36,9 @@ class Class
25
36
  def publicize_methods(*methods)
26
37
  saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
27
38
 
28
- self.class_eval { public *saved_private_instance_methods }
39
+ self.class_eval { public(*saved_private_instance_methods) }
29
40
  yield
30
- self.class_eval { private *saved_private_instance_methods }
41
+ self.class_eval { private(*saved_private_instance_methods) }
31
42
  end
32
43
  end
33
44
 
@@ -187,7 +198,7 @@ module PuppetTest
187
198
 
188
199
  # If we're running under rake, then disable debugging and such.
189
200
  #if rake? or ! Puppet[:debug]
190
- if defined?($puppet_debug) or ! rake?
201
+ #if defined?($puppet_debug) or ! rake?
191
202
  if textmate?
192
203
  Puppet[:color] = false
193
204
  end
@@ -199,11 +210,11 @@ module PuppetTest
199
210
  end
200
211
  Puppet::Util::Log.level = :debug
201
212
  #$VERBOSE = 1
202
- else
203
- Puppet::Util::Log.close
204
- Puppet::Util::Log.newdestination(@logs)
205
- Puppet[:httplog] = tempfile()
206
- end
213
+ #else
214
+ # Puppet::Util::Log.close
215
+ # Puppet::Util::Log.newdestination(@logs)
216
+ # Puppet[:httplog] = tempfile()
217
+ #end
207
218
 
208
219
  Puppet[:ignoreschedules] = true
209
220
 
@@ -256,11 +267,7 @@ module PuppetTest
256
267
  @tmpdir
257
268
  end
258
269
 
259
- def teardown
260
- #@stop = Time.now
261
- #File.open("/tmp/test_times.log", ::File::WRONLY|::File::CREAT|::File::APPEND) { |f| f.puts "%0.4f %s %s" % [@stop - @start, @method_name, self.class] }
262
- @@cleaners.each { |cleaner| cleaner.call() }
263
-
270
+ def remove_tmp_files
264
271
  @@tmpfiles.each { |file|
265
272
  unless file =~ /tmp/
266
273
  puts "Not deleting tmpfile %s" % file
@@ -272,6 +279,14 @@ module PuppetTest
272
279
  end
273
280
  }
274
281
  @@tmpfiles.clear
282
+ end
283
+
284
+ def teardown
285
+ #@stop = Time.now
286
+ #File.open("/tmp/test_times.log", ::File::WRONLY|::File::CREAT|::File::APPEND) { |f| f.puts "%0.4f %s %s" % [@stop - @start, @method_name, self.class] }
287
+ @@cleaners.each { |cleaner| cleaner.call() }
288
+
289
+ remove_tmp_files
275
290
 
276
291
  @@tmppids.each { |pid|
277
292
  %x{kill -INT #{pid} 2>/dev/null}
@@ -306,7 +321,6 @@ module PuppetTest
306
321
  rescue Timeout::Error
307
322
  # just move on
308
323
  end
309
- mocha_verify
310
324
  end
311
325
 
312
326
  def logstore
@@ -5,7 +5,7 @@ module PuppetTest::ParserTesting
5
5
  include PuppetTest
6
6
  AST = Puppet::Parser::AST
7
7
 
8
- Compile = Puppet::Parser::Compile
8
+ Compiler = Puppet::Parser::Compiler
9
9
 
10
10
  # A fake class that we can use for testing evaluation.
11
11
  class FakeAST
@@ -41,10 +41,10 @@ module PuppetTest::ParserTesting
41
41
  )
42
42
  end
43
43
 
44
- def mkcompile(parser = nil)
44
+ def mkcompiler(parser = nil)
45
45
  parser ||= mkparser
46
46
  node = mknode
47
- return Compile.new(node, parser)
47
+ return Compiler.new(node, parser)
48
48
  end
49
49
 
50
50
  def mknode(name = nil)
@@ -58,21 +58,21 @@ module PuppetTest::ParserTesting
58
58
  Puppet::Parser::Interpreter.new
59
59
  end
60
60
 
61
- def mkparser
62
- Puppet::Parser::Parser.new()
61
+ def mkparser(args = {})
62
+ Puppet::Parser::Parser.new(args)
63
63
  end
64
64
 
65
65
  def mkscope(hash = {})
66
66
  hash[:parser] ||= mkparser
67
- compile ||= mkcompile(hash[:parser])
68
- compile.topscope.source = (hash[:parser].findclass("", "") || hash[:parser].newclass(""))
67
+ compiler ||= mkcompiler(hash[:parser])
68
+ compiler.topscope.source = (hash[:parser].findclass("", "") || hash[:parser].newclass(""))
69
69
 
70
- unless compile.topscope.source
70
+ unless compiler.topscope.source
71
71
  raise "Could not find source for scope"
72
72
  end
73
73
  # Make the 'main' stuff
74
- compile.send(:evaluate_main)
75
- compile.topscope
74
+ compiler.send(:evaluate_main)
75
+ compiler.topscope
76
76
  end
77
77
 
78
78
  def classobj(name, hash = {})
@@ -18,7 +18,7 @@ module PuppetTest::Support::Resources
18
18
  if resource.is_a?(String)
19
19
  resource = tree_resource(resource)
20
20
  end
21
- config.add_edge!(comp, resource)
21
+ config.add_edge(comp, resource)
22
22
  config.add_resource resource unless config.resource(resource.ref)
23
23
  end
24
24
  return comp
@@ -211,6 +211,16 @@ end
211
211
  "Lost value to hostname")
212
212
  end
213
213
 
214
+ # Make sure that setting environment by fact takes precedence to configuration
215
+ def test_setenvironmentwithfact
216
+ name = "environment"
217
+ value = "test_environment"
218
+
219
+ Facter.stubs(:to_hash).returns(name => value)
220
+
221
+ assert_equal(value, Puppet::Network::Client.master.facts[name])
222
+ end
223
+
214
224
  # Make sure we load all facts on startup.
215
225
  def test_loadfacts
216
226
  dirs = [tempfile(), tempfile()]
@@ -109,13 +109,13 @@ class TestFileServer < Test::Unit::TestCase
109
109
  # and verify different iterations of 'root' return the same value
110
110
  list = nil
111
111
  assert_nothing_raised {
112
- list = server.list("/test/", :ignore, true, false)
112
+ list = server.list("/test/", :manage, true, false)
113
113
  }
114
114
 
115
115
  assert(list =~ pattern)
116
116
 
117
117
  assert_nothing_raised {
118
- list = server.list("/test", :ignore, true, false)
118
+ list = server.list("/test", :manage, true, false)
119
119
  }
120
120
  assert(list =~ pattern)
121
121
 
@@ -143,7 +143,7 @@ class TestFileServer < Test::Unit::TestCase
143
143
  list = nil
144
144
  sfile = "/test/tmpfile"
145
145
  assert_nothing_raised {
146
- list = server.list(sfile, :ignore, true, false)
146
+ list = server.list(sfile, :manage, true, false)
147
147
  }
148
148
 
149
149
  assert_nothing_raised {
@@ -200,7 +200,7 @@ class TestFileServer < Test::Unit::TestCase
200
200
  list = nil
201
201
  sfile = "/test/"
202
202
  assert_nothing_raised {
203
- list = server.list(sfile, :ignore, true, false)
203
+ list = server.list(sfile, :manage, true, false)
204
204
  }
205
205
 
206
206
  # create the new file
@@ -210,7 +210,7 @@ class TestFileServer < Test::Unit::TestCase
210
210
 
211
211
  newlist = nil
212
212
  assert_nothing_raised {
213
- newlist = server.list(sfile, :ignore, true, false)
213
+ newlist = server.list(sfile, :manage, true, false)
214
214
  }
215
215
 
216
216
  # verify the list has changed
@@ -239,12 +239,12 @@ class TestFileServer < Test::Unit::TestCase
239
239
 
240
240
  list = nil
241
241
  assert_nothing_raised {
242
- list = server.list("/root/" + testdir, :ignore, true, false)
242
+ list = server.list("/root/" + testdir, :manage, true, false)
243
243
  }
244
244
 
245
245
  assert(list =~ pattern)
246
246
  assert_nothing_raised {
247
- list = server.list("/root" + testdir, :ignore, true, false)
247
+ list = server.list("/root" + testdir, :manage, true, false)
248
248
  }
249
249
 
250
250
  assert(list =~ pattern)
@@ -279,7 +279,7 @@ class TestFileServer < Test::Unit::TestCase
279
279
  # get our list
280
280
  list = nil
281
281
  assert_nothing_raised {
282
- list = server.list("/test/with", :ignore, false, false)
282
+ list = server.list("/test/with", :manage, false, false)
283
283
  }
284
284
 
285
285
  # make sure we only got one line, since we're not recursing
@@ -288,7 +288,7 @@ class TestFileServer < Test::Unit::TestCase
288
288
  # for each level of recursion, make sure we get the right list
289
289
  [0, 1, 2].each { |num|
290
290
  assert_nothing_raised {
291
- list = server.list("/test/with", :ignore, num, false)
291
+ list = server.list("/test/with", :manage, num, false)
292
292
  }
293
293
 
294
294
  count = 0
@@ -332,13 +332,13 @@ class TestFileServer < Test::Unit::TestCase
332
332
  list = nil
333
333
  # and then check a few dirs
334
334
  assert_nothing_raised {
335
- list = server.list("/localhost/with", :ignore, false, false)
335
+ list = server.list("/localhost/with", :manage, false, false)
336
336
  }
337
337
 
338
338
  assert(list !~ /with/)
339
339
 
340
340
  assert_nothing_raised {
341
- list = server.list("/localhost/with/some/sub", :ignore, true, false)
341
+ list = server.list("/localhost/with/some/sub", :manage, true, false)
342
342
  }
343
343
 
344
344
  assert(list !~ /sub/)
@@ -370,7 +370,7 @@ class TestFileServer < Test::Unit::TestCase
370
370
 
371
371
  list = nil
372
372
  assert_nothing_raised {
373
- list = server.list("/localhost/", :ignore, 1, false)
373
+ list = server.list("/localhost/", :manage, 1, false)
374
374
  }
375
375
  assert_instance_of(String, list, "Server returned %s instead of string")
376
376
  list = list.split("\n")
@@ -402,7 +402,7 @@ class TestFileServer < Test::Unit::TestCase
402
402
  list = nil
403
403
  sfile = "/test/"
404
404
  assert_nothing_raised {
405
- list = server.list(sfile, :ignore, true, false)
405
+ list = server.list(sfile, :manage, true, false)
406
406
  }
407
407
 
408
408
  # and describe each file in the list
@@ -492,7 +492,7 @@ class TestFileServer < Test::Unit::TestCase
492
492
  mounts.each { |mount, files|
493
493
  mount = "/#{mount}/"
494
494
  assert_nothing_raised {
495
- list = server.list(mount, :ignore, true, false)
495
+ list = server.list(mount, :manage, true, false)
496
496
  }
497
497
 
498
498
  assert_nothing_raised {
@@ -544,12 +544,12 @@ class TestFileServer < Test::Unit::TestCase
544
544
  assert_raise(Puppet::AuthorizationError,
545
545
  "Host %s, ip %s, allowed %s" %
546
546
  [host, ip, mount]) {
547
- list = server.list(mount, :ignore, true, false, host, ip)
547
+ list = server.list(mount, :manage, true, false, host, ip)
548
548
  }
549
549
  when :allow:
550
550
  assert_nothing_raised("Host %s, ip %s, denied %s" %
551
551
  [host, ip, mount]) {
552
- list = server.list(mount, :ignore, true, false, host, ip)
552
+ list = server.list(mount, :manage, true, false, host, ip)
553
553
  }
554
554
  end
555
555
  }
@@ -602,7 +602,7 @@ class TestFileServer < Test::Unit::TestCase
602
602
 
603
603
  assert_raise(Puppet::Network::Handler::FileServerError,
604
604
  "Invalid mount was mounted") {
605
- server.list(mount, :ignore)
605
+ server.list(mount, :manage)
606
606
  }
607
607
  }
608
608
 
@@ -654,13 +654,13 @@ class TestFileServer < Test::Unit::TestCase
654
654
 
655
655
  list = nil
656
656
  assert_nothing_raised {
657
- list = server.list("/thing/", :ignore, false, false,
657
+ list = server.list("/thing/", :manage, false, false,
658
658
  "test1.domain.com", "127.0.0.1")
659
659
  }
660
660
  assert(list != "", "List returned nothing in rereard test")
661
661
 
662
662
  assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
663
- list = server.list("/thing/", :ignore, false, false,
663
+ list = server.list("/thing/", :manage, false, false,
664
664
  "test2.domain.com", "127.0.0.1")
665
665
  }
666
666
 
@@ -675,12 +675,12 @@ class TestFileServer < Test::Unit::TestCase
675
675
  }
676
676
 
677
677
  assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
678
- list = server.list("/thing/", :ignore, false, false,
678
+ list = server.list("/thing/", :manage, false, false,
679
679
  "test1.domain.com", "127.0.0.1")
680
680
  }
681
681
 
682
682
  assert_nothing_raised {
683
- list = server.list("/thing/", :ignore, false, false,
683
+ list = server.list("/thing/", :manage, false, false,
684
684
  "test2.domain.com", "127.0.0.1")
685
685
  }
686
686
 
@@ -735,7 +735,7 @@ class TestFileServer < Test::Unit::TestCase
735
735
  # Then not
736
736
  results = {}
737
737
  assert_nothing_raised {
738
- server.describe("/mount/link", :ignore).split("\t").zip(
738
+ server.describe("/mount/link", :manage).split("\t").zip(
739
739
  Puppet::Network::Handler.fileserver::CHECKPARAMS
740
740
  ).each { |v,p| results[p] = v }
741
741
  }
@@ -801,28 +801,28 @@ allow *
801
801
  list = nil
802
802
  sfile = "/host/file.txt"
803
803
  assert_nothing_raised {
804
- list = server.list(sfile, :ignore, true, false, client1, ip)
804
+ list = server.list(sfile, :manage, true, false, client1, ip)
805
805
  }
806
806
  assert_equal("/\tfile", list)
807
807
  assert_nothing_raised {
808
- list = server.list(sfile, :ignore, true, false, client2, ip)
808
+ list = server.list(sfile, :manage, true, false, client2, ip)
809
809
  }
810
810
  assert_equal("", list)
811
811
 
812
812
  sfile = "/fqdn/file.txt"
813
813
  assert_nothing_raised {
814
- list = server.list(sfile, :ignore, true, false, client1, ip)
814
+ list = server.list(sfile, :manage, true, false, client1, ip)
815
815
  }
816
816
  assert_equal("", list)
817
817
  assert_nothing_raised {
818
- list = server.list(sfile, :ignore, true, false, client2, ip)
818
+ list = server.list(sfile, :manage, true, false, client2, ip)
819
819
  }
820
820
  assert_equal("/\tfile", list)
821
821
 
822
822
  # check describe
823
823
  sfile = "/host/file.txt"
824
824
  assert_nothing_raised {
825
- list = server.describe(sfile, :ignore, client1, ip).split("\t")
825
+ list = server.describe(sfile, :manage, client1, ip).split("\t")
826
826
  }
827
827
  assert_equal(5, list.size)
828
828
  assert_equal("file", list[1])
@@ -830,18 +830,18 @@ allow *
830
830
  assert_equal("{md5}#{md5}", list[4])
831
831
 
832
832
  assert_nothing_raised {
833
- list = server.describe(sfile, :ignore, client2, ip).split("\t")
833
+ list = server.describe(sfile, :manage, client2, ip).split("\t")
834
834
  }
835
835
  assert_equal([], list)
836
836
 
837
837
  sfile = "/fqdn/file.txt"
838
838
  assert_nothing_raised {
839
- list = server.describe(sfile, :ignore, client1, ip).split("\t")
839
+ list = server.describe(sfile, :manage, client1, ip).split("\t")
840
840
  }
841
841
  assert_equal([], list)
842
842
 
843
843
  assert_nothing_raised {
844
- list = server.describe(sfile, :ignore, client2, ip).split("\t")
844
+ list = server.describe(sfile, :manage, client2, ip).split("\t")
845
845
  }
846
846
  assert_equal(5, list.size)
847
847
  assert_equal("file", list[1])
@@ -851,23 +851,23 @@ allow *
851
851
  # Check retrieve
852
852
  sfile = "/host/file.txt"
853
853
  assert_nothing_raised {
854
- list = server.retrieve(sfile, :ignore, client1, ip).chomp
854
+ list = server.retrieve(sfile, :manage, client1, ip).chomp
855
855
  }
856
856
  assert_equal(contents[client1_hostdir].chomp, list)
857
857
 
858
858
  assert_nothing_raised {
859
- list = server.retrieve(sfile, :ignore, client2, ip).chomp
859
+ list = server.retrieve(sfile, :manage, client2, ip).chomp
860
860
  }
861
861
  assert_equal("", list)
862
862
 
863
863
  sfile = "/fqdn/file.txt"
864
864
  assert_nothing_raised {
865
- list = server.retrieve(sfile, :ignore, client1, ip).chomp
865
+ list = server.retrieve(sfile, :manage, client1, ip).chomp
866
866
  }
867
867
  assert_equal("", list)
868
868
 
869
869
  assert_nothing_raised {
870
- list = server.retrieve(sfile, :ignore, client2, ip).chomp
870
+ list = server.retrieve(sfile, :manage, client2, ip).chomp
871
871
  }
872
872
  assert_equal(contents[client2_fqdndir].chomp, list)
873
873
  end
@@ -945,12 +945,14 @@ allow *
945
945
  # Now, check that they use Facter info
946
946
  Puppet.notice "The following messages are normal"
947
947
  client = nil
948
- local = Facter["hostname"].value
949
- domain = Facter["domain"].value
950
- fqdn = [local, domain].join(".")
951
- {"%h" => local, # Short name
952
- "%H" => fqdn, # Full name
953
- "%d" => domain, # domain
948
+ Facter.stubs(:value).with(:ipaddress).returns("127.0.0.1")
949
+ Facter.stubs(:value).with { |v| v.to_s == "hostname" }.returns("myhost")
950
+ Facter.stubs(:value).with { |v| v.to_s == "domain" }.returns("mydomain.com")
951
+ Facter.stubs(:value).with(:domain).returns("mydomain.com")
952
+
953
+ {"%h" => "myhost", # Short name
954
+ "%H" => "myhost.mydomain.com", # Full name
955
+ "%d" => "mydomain.com", # domain
954
956
  "%%" => "%", # escape
955
957
  "%o" => "%o" # other
956
958
  }.each do |pat, repl|
@@ -993,18 +995,18 @@ allow *
993
995
 
994
996
  ret = nil
995
997
  assert_nothing_raised do
996
- ret = server.list("/name", :ignore, false, false, host, ip)
998
+ ret = server.list("/name", :manage, false, false, host, ip)
997
999
  end
998
1000
 
999
1001
  assert_equal("/\tfile", ret)
1000
1002
 
1001
1003
  assert_nothing_raised do
1002
- ret = server.describe("/name", :ignore, host, ip)
1004
+ ret = server.describe("/name", :manage, host, ip)
1003
1005
  end
1004
- assert(ret =~ /\tfile\t/, "Did not get valid a description")
1006
+ assert(ret =~ /\tfile\t/, "Did not get valid a description (#{ret.inspect})")
1005
1007
 
1006
1008
  assert_nothing_raised do
1007
- ret = server.retrieve("/name", :ignore, host, ip)
1009
+ ret = server.retrieve("/name", :manage, host, ip)
1008
1010
  end
1009
1011
 
1010
1012
  assert_equal(ret, File.read(file))
@@ -1050,7 +1052,7 @@ allow *
1050
1052
  mount = "/#{mod.name}/"
1051
1053
  list = nil
1052
1054
  assert_nothing_raised {
1053
- list = server.list(mount, :ignore, true, false)
1055
+ list = server.list(mount, :manage, true, false)
1054
1056
  }
1055
1057
  list = list.split("\n")
1056
1058
  if mod.name == "green"
@@ -1063,7 +1065,7 @@ allow *
1063
1065
  end
1064
1066
 
1065
1067
  assert_nothing_raised("Host 'allow' denied #{mount}") {
1066
- server.list(mount, :ignore, true, false,
1068
+ server.list(mount, :manage, true, false,
1067
1069
  'allow.example.com', "192.168.0.1")
1068
1070
  }
1069
1071
  end
@@ -1106,7 +1108,7 @@ allow *
1106
1108
  list = nil
1107
1109
  mount = "/#{mod.name}/"
1108
1110
  assert_nothing_raised {
1109
- list = server.list(mount, :ignore, true, false)
1111
+ list = server.list(mount, :manage, true, false)
1110
1112
  }
1111
1113
 
1112
1114
  assert_nothing_raised {
@@ -1121,11 +1123,11 @@ allow *
1121
1123
  # now let's check that things are being correctly forbidden
1122
1124
  assert_raise(Puppet::AuthorizationError,
1123
1125
  "Host 'deny' allowed #{mount}") {
1124
- server.list(mount, :ignore, true, false,
1126
+ server.list(mount, :manage, true, false,
1125
1127
  'deny.example.com', "192.168.1.1")
1126
1128
  }
1127
1129
  assert_nothing_raised("Host 'allow' denied #{mount}") {
1128
- server.list(mount, :ignore, true, false,
1130
+ server.list(mount, :manage, true, false,
1129
1131
  'allow.example.com', "192.168.0.1")
1130
1132
  }
1131
1133
  end