puppet 0.16.0 → 0.18.4

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 (185) hide show
  1. data/CHANGELOG +98 -0
  2. data/Rakefile +5 -1
  3. data/bin/puppet +1 -1
  4. data/bin/puppetca +25 -11
  5. data/bin/puppetd +189 -66
  6. data/bin/puppetdoc +79 -62
  7. data/bin/puppetmasterd +93 -49
  8. data/bin/puppetrun +385 -0
  9. data/conf/redhat/client.init +5 -2
  10. data/conf/redhat/fileserver.conf +1 -1
  11. data/conf/redhat/lsb-config.patch +51 -0
  12. data/conf/redhat/puppet.spec +45 -18
  13. data/conf/redhat/puppetd.conf +32 -4
  14. data/conf/redhat/server.init +5 -2
  15. data/conf/solaris/pkginfo +7 -0
  16. data/conf/solaris/smf/puppetd.xml +77 -0
  17. data/conf/solaris/smf/puppetmasterd.xml +77 -0
  18. data/conf/solaris/smf/svc-puppetd +66 -0
  19. data/conf/solaris/smf/svc-puppetmasterd +62 -0
  20. data/examples/code/failers/noobjectrvalue +1 -0
  21. data/examples/code/snippets/deepclassheirarchy.pp +23 -0
  22. data/examples/code/snippets/defineoverrides.pp +17 -0
  23. data/examples/code/snippets/emptyexec.pp +3 -0
  24. data/examples/code/snippets/selectorvalues.pp +6 -1
  25. data/examples/code/snippets/tagged.pp +35 -0
  26. data/ext/ldap/puppet.schema +2 -2
  27. data/install.rb +4 -2
  28. data/lib/puppet.rb +206 -15
  29. data/lib/puppet/client.rb +30 -20
  30. data/lib/puppet/client/ca.rb +2 -2
  31. data/lib/puppet/client/dipper.rb +5 -9
  32. data/lib/puppet/client/master.rb +224 -44
  33. data/lib/puppet/client/pelement.rb +54 -9
  34. data/lib/puppet/client/proxy.rb +3 -2
  35. data/lib/puppet/client/reporter.rb +34 -0
  36. data/lib/puppet/client/runner.rb +17 -0
  37. data/lib/puppet/config.rb +136 -55
  38. data/lib/puppet/daemon.rb +59 -37
  39. data/lib/puppet/element.rb +2 -1
  40. data/lib/puppet/event.rb +14 -3
  41. data/lib/puppet/filetype.rb +28 -19
  42. data/lib/puppet/log.rb +297 -132
  43. data/lib/puppet/metric.rb +31 -131
  44. data/lib/puppet/networkclient.rb +73 -46
  45. data/lib/puppet/parameter.rb +49 -1
  46. data/lib/puppet/parsedfile.rb +32 -12
  47. data/lib/puppet/parser/ast.rb +6 -1
  48. data/lib/puppet/parser/ast/astarray.rb +32 -6
  49. data/lib/puppet/parser/ast/collection.rb +91 -0
  50. data/lib/puppet/parser/ast/compdef.rb +2 -2
  51. data/lib/puppet/parser/ast/component.rb +24 -11
  52. data/lib/puppet/parser/ast/function.rb +50 -0
  53. data/lib/puppet/parser/ast/hostclass.rb +70 -22
  54. data/lib/puppet/parser/ast/node.rb +17 -8
  55. data/lib/puppet/parser/ast/nodedef.rb +1 -1
  56. data/lib/puppet/parser/ast/objectdef.rb +28 -10
  57. data/lib/puppet/parser/ast/selector.rb +4 -1
  58. data/lib/puppet/parser/functions.rb +145 -0
  59. data/lib/puppet/parser/interpreter.rb +243 -86
  60. data/lib/puppet/parser/lexer.rb +5 -4
  61. data/lib/puppet/parser/parser.rb +586 -505
  62. data/lib/puppet/parser/scope.rb +337 -187
  63. data/lib/puppet/rails.rb +115 -0
  64. data/lib/puppet/rails/database.rb +40 -0
  65. data/lib/puppet/rails/host.rb +83 -0
  66. data/lib/puppet/rails/rails_object.rb +42 -0
  67. data/lib/puppet/rails/rails_parameter.rb +5 -0
  68. data/lib/puppet/reports/rrdgraph.rb +20 -0
  69. data/lib/puppet/reports/tagmail.rb +94 -0
  70. data/lib/puppet/server.rb +20 -4
  71. data/lib/puppet/server/authconfig.rb +14 -3
  72. data/lib/puppet/server/authstore.rb +2 -2
  73. data/lib/puppet/server/ca.rb +23 -11
  74. data/lib/puppet/server/filebucket.rb +10 -10
  75. data/lib/puppet/server/fileserver.rb +4 -8
  76. data/lib/puppet/server/master.rb +19 -22
  77. data/lib/puppet/server/pelement.rb +28 -16
  78. data/lib/puppet/server/report.rb +184 -0
  79. data/lib/puppet/server/runner.rb +62 -0
  80. data/lib/puppet/server/servlet.rb +23 -9
  81. data/lib/puppet/sslcertificates/ca.rb +25 -1
  82. data/lib/puppet/statechange.rb +34 -53
  83. data/lib/puppet/storage.rb +1 -2
  84. data/lib/puppet/transaction.rb +305 -133
  85. data/lib/puppet/transaction/report.rb +42 -0
  86. data/lib/puppet/transportable.rb +57 -33
  87. data/lib/puppet/type.rb +260 -127
  88. data/lib/puppet/type/component.rb +9 -21
  89. data/lib/puppet/type/cron.rb +367 -116
  90. data/lib/puppet/type/exec.rb +15 -16
  91. data/lib/puppet/type/group.rb +9 -1
  92. data/lib/puppet/type/nameservice.rb +2 -5
  93. data/lib/puppet/type/nameservice/netinfo.rb +3 -0
  94. data/lib/puppet/type/nameservice/objectadd.rb +23 -10
  95. data/lib/puppet/type/nameservice/pw.rb +16 -3
  96. data/lib/puppet/type/package.rb +25 -75
  97. data/lib/puppet/type/package/apple.rb +15 -1
  98. data/lib/puppet/type/package/apt.rb +37 -2
  99. data/lib/puppet/type/package/blastwave.rb +136 -0
  100. data/lib/puppet/type/package/dpkg.rb +4 -4
  101. data/lib/puppet/type/package/gem.rb +119 -0
  102. data/lib/puppet/type/package/openbsd.rb +7 -6
  103. data/lib/puppet/type/package/ports.rb +7 -2
  104. data/lib/puppet/type/package/rpm.rb +1 -1
  105. data/lib/puppet/type/package/sun.rb +23 -9
  106. data/lib/puppet/type/package/sunfreeware.rb +7 -0
  107. data/lib/puppet/type/package/yum.rb +16 -9
  108. data/lib/puppet/type/parsedtype.rb +7 -5
  109. data/lib/puppet/type/parsedtype/mount.rb +55 -34
  110. data/lib/puppet/type/parsedtype/port.rb +7 -1
  111. data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
  112. data/lib/puppet/type/pfile.rb +115 -23
  113. data/lib/puppet/type/pfile/checksum.rb +18 -5
  114. data/lib/puppet/type/pfile/content.rb +2 -2
  115. data/lib/puppet/type/pfile/ensure.rb +3 -3
  116. data/lib/puppet/type/pfile/group.rb +2 -2
  117. data/lib/puppet/type/pfile/source.rb +28 -17
  118. data/lib/puppet/type/pfile/target.rb +25 -17
  119. data/lib/puppet/type/pfilebucket.rb +25 -6
  120. data/lib/puppet/type/schedule.rb +6 -6
  121. data/lib/puppet/type/service.rb +24 -14
  122. data/lib/puppet/type/service/debian.rb +1 -1
  123. data/lib/puppet/type/service/redhat.rb +13 -10
  124. data/lib/puppet/type/service/smf.rb +3 -3
  125. data/lib/puppet/type/state.rb +1 -2
  126. data/lib/puppet/type/symlink.rb +3 -4
  127. data/lib/puppet/type/user.rb +22 -10
  128. data/lib/puppet/type/yumrepo.rb +6 -1
  129. data/lib/puppet/type/zone.rb +595 -0
  130. data/lib/puppet/util.rb +58 -12
  131. data/test/client/client.rb +2 -2
  132. data/test/client/master.rb +92 -3
  133. data/test/client/pelement.rb +99 -0
  134. data/test/executables/puppetbin.rb +3 -4
  135. data/test/executables/puppetca.rb +3 -3
  136. data/test/executables/puppetd.rb +3 -3
  137. data/test/executables/puppetmasterd.rb +1 -5
  138. data/test/executables/puppetmodule.rb +2 -2
  139. data/test/language/ast.rb +200 -11
  140. data/test/language/functions.rb +245 -0
  141. data/test/language/interpreter.rb +155 -6
  142. data/test/language/lexer.rb +35 -2
  143. data/test/language/node.rb +48 -1
  144. data/test/language/parser.rb +250 -1
  145. data/test/language/rails.rb +105 -0
  146. data/test/language/scope.rb +304 -10
  147. data/test/language/snippets.rb +54 -5
  148. data/test/language/transportable.rb +60 -28
  149. data/test/other/config.rb +214 -1
  150. data/test/other/events.rb +67 -9
  151. data/test/other/log.rb +31 -5
  152. data/test/other/metrics.rb +23 -21
  153. data/test/other/parsedfile.rb +29 -2
  154. data/test/other/puppet.rb +79 -0
  155. data/test/other/report.rb +106 -0
  156. data/test/other/storage.rb +2 -2
  157. data/test/other/transactions.rb +128 -2
  158. data/test/puppet/utiltest.rb +10 -5
  159. data/test/puppettest.rb +193 -21
  160. data/test/server/authstore.rb +13 -4
  161. data/test/server/bucket.rb +33 -8
  162. data/test/server/ca.rb +44 -6
  163. data/test/server/master.rb +6 -7
  164. data/test/server/pelement.rb +15 -5
  165. data/test/server/report.rb +93 -0
  166. data/test/server/runner.rb +107 -0
  167. data/test/server/server.rb +28 -1
  168. data/test/types/cron.rb +339 -31
  169. data/test/types/file.rb +256 -24
  170. data/test/types/filebucket.rb +6 -2
  171. data/test/types/filesources.rb +41 -92
  172. data/test/types/group.rb +31 -1
  173. data/test/types/host.rb +2 -1
  174. data/test/types/mount.rb +18 -1
  175. data/test/types/package.rb +200 -18
  176. data/test/types/service.rb +5 -1
  177. data/test/types/sshkey.rb +2 -1
  178. data/test/types/symlink.rb +3 -2
  179. data/test/types/type.rb +180 -1
  180. data/test/types/user.rb +65 -27
  181. data/test/types/yumrepo.rb +15 -0
  182. data/test/types/zone.rb +437 -0
  183. metadata +43 -4
  184. data/bin/cf2puppet +0 -186
  185. data/conf/redhat/puppetmasterd.conf +0 -5
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/ruby
2
+
3
+ if __FILE__ == $0
4
+ $:.unshift '../../lib'
5
+ $:.unshift '..'
6
+ $puppetbase = "../.."
7
+ end
8
+
9
+ require 'puppet'
10
+ require 'puppet/rails'
11
+ require 'puppet/parser/interpreter'
12
+ require 'puppet/parser/parser'
13
+ require 'puppet/client'
14
+ require 'test/unit'
15
+ require 'puppettest'
16
+
17
+ class TestRails < Test::Unit::TestCase
18
+ include ParserTesting
19
+
20
+ def test_includerails
21
+ assert_nothing_raised {
22
+ require 'puppet/rails'
23
+ }
24
+ end
25
+
26
+ # Don't do any tests w/out this class
27
+ if defined? ActiveRecord::Base
28
+ def test_hostcache
29
+ # First make some objects
30
+ bucket = mk_transtree do |object, depth, width|
31
+ # and mark some of them collectable
32
+ if width % 2 == 1
33
+ object.collectable = true
34
+ end
35
+ end
36
+
37
+ # Now collect our facts
38
+ facts = {}
39
+ Facter.each do |fact, value| facts[fact] = value end
40
+
41
+ assert_nothing_raised {
42
+ Puppet::Rails.init
43
+ }
44
+
45
+ # Now try storing our crap
46
+ host = nil
47
+ assert_nothing_raised {
48
+ host = Puppet::Rails::Host.store(
49
+ :objects => bucket,
50
+ :facts => facts,
51
+ :host => facts["hostname"]
52
+ )
53
+ }
54
+
55
+ assert(host, "Did not create host")
56
+
57
+ host = nil
58
+ assert_nothing_raised {
59
+ host = Puppet::Rails::Host.find_by_name(facts["hostname"])
60
+ }
61
+ assert(host, "Could not find host object")
62
+
63
+ assert(host.rails_objects, "No objects on host")
64
+
65
+ assert_equal(facts["hostname"], host.facts["hostname"],
66
+ "Did not retrieve facts")
67
+
68
+ inline_test_objectcollection(host)
69
+ end
70
+
71
+ # This is called from another test, it just makes sense to split it out some
72
+ def inline_test_objectcollection(host)
73
+ # XXX For some reason, find_all doesn't work here at all.
74
+ collectable = []
75
+ host.rails_objects.each do |obj|
76
+ if obj.collectable?
77
+ collectable << obj
78
+ end
79
+ end
80
+
81
+ assert(collectable.length > 0, "Found no collectable objects")
82
+
83
+ collectable.each do |obj|
84
+ trans = nil
85
+ assert_nothing_raised {
86
+ trans = obj.to_trans
87
+ }
88
+ # Make sure that the objects do not retain their collectable
89
+ # nature.
90
+ assert(!trans.collectable, "Object from db was collectable")
91
+ end
92
+
93
+ # Now find all collectable objects directly through database APIs
94
+
95
+ list = Puppet::Rails::RailsObject.find_all_by_collectable(true)
96
+
97
+ assert_equal(collectable.length, list.length,
98
+ "Did not get the right number of objects")
99
+ end
100
+ else
101
+ $stderr.puts "Install Rails for Rails and Caching tests"
102
+ end
103
+ end
104
+
105
+ # $Id: rails.rb 1192 2006-05-14 02:42:21Z luke $
@@ -259,6 +259,16 @@ class TestScope < Test::Unit::TestCase
259
259
  val = scope.strinterp("string $test ${test} $test")
260
260
  }
261
261
  assert_equal("string value value value", val)
262
+
263
+ assert_nothing_raised {
264
+ val = scope.strinterp("string \\$test")
265
+ }
266
+ assert_equal("string $test", val)
267
+
268
+ assert_nothing_raised {
269
+ val = scope.strinterp("\\$test string")
270
+ }
271
+ assert_equal("$test string", val)
262
272
  end
263
273
 
264
274
  # Test some of the host manipulations
@@ -430,18 +440,17 @@ class TestScope < Test::Unit::TestCase
430
440
  scope = nil
431
441
  assert_nothing_raised("Could not evaluate") {
432
442
  scope = Puppet::Parser::Scope.new()
433
- #scope.name = "topscope"
434
- #scope.type = "topscope"
435
443
  objects = scope.evaluate(:ast => top)
436
444
  }
437
445
 
438
446
  assert_equal(1, objects.length, "Returned too many objects: %s" %
439
447
  objects.inspect)
448
+
440
449
  assert_equal(1, objects[0].length, "Returned too many objects: %s" %
441
450
  objects[0].inspect)
451
+
442
452
  assert_nothing_raised {
443
453
  file = objects[0][0]
444
-
445
454
  assert_equal("bin", file["owner"], "Value did not override correctly")
446
455
  }
447
456
  end
@@ -530,13 +539,9 @@ class TestScope < Test::Unit::TestCase
530
539
  :children => stats
531
540
  )
532
541
  scope = Puppet::Parser::Scope.new()
533
- assert_nothing_raised {
534
- scope.evaluate(:ast => top)
535
- }
536
-
537
542
  trans = nil
538
543
  assert_nothing_raised {
539
- trans = scope.to_trans
544
+ trans = scope.evaluate(:ast => top)
540
545
  }
541
546
 
542
547
  obj = trans.find do |obj| obj.is_a? Puppet::TransObject end
@@ -550,17 +555,306 @@ class TestScope < Test::Unit::TestCase
550
555
  def test_validclassnames
551
556
  scope = Puppet::Parser::Scope.new()
552
557
 
553
- ["a-class", "a class", "Class", "a.class"].each do |bad|
558
+ ["a class", "Class", "a.class"].each do |bad|
554
559
  assert_raise(Puppet::ParseError, "Incorrectly allowed %s" % bad.inspect) do
555
560
  scope.setclass(object_id, bad)
556
561
  end
557
562
  end
558
563
 
559
- ["a_class", "class", "yayNess"].each do |good|
564
+ ["a-class", "a_class", "class", "yayNess"].each do |good|
560
565
  assert_nothing_raised("Incorrectly banned %s" % good.inspect) do
561
566
  scope.setclass(object_id, good)
562
567
  end
563
568
  end
564
569
 
565
570
  end
571
+
572
+ def test_tagfunction
573
+ scope = Puppet::Parser::Scope.new()
574
+
575
+ assert_nothing_raised {
576
+ scope.function_tag(["yayness", "booness"])
577
+ }
578
+
579
+ assert(scope.classlist.include?("yayness"), "tag 'yayness' did not get set")
580
+ assert(scope.classlist.include?("booness"), "tag 'booness' did not get set")
581
+
582
+ # Now verify that the 'tagged' function works correctly
583
+ assert(scope.function_tagged("yayness"),
584
+ "tagged function incorrectly returned false")
585
+ assert(scope.function_tagged("booness"),
586
+ "tagged function incorrectly returned false")
587
+
588
+ assert(! scope.function_tagged("funtest"),
589
+ "tagged function incorrectly returned true")
590
+ end
591
+
592
+ def test_includefunction
593
+ scope = Puppet::Parser::Scope.new()
594
+
595
+ one = tempfile()
596
+ two = tempfile()
597
+
598
+ children = []
599
+
600
+ children << classobj("one", :code => AST::ASTArray.new(
601
+ :children => [
602
+ fileobj(one, "owner" => "root")
603
+ ]
604
+ ))
605
+
606
+ children << classobj("two", :code => AST::ASTArray.new(
607
+ :children => [
608
+ fileobj(two, "owner" => "root")
609
+ ]
610
+ ))
611
+
612
+ children << Puppet::Parser::AST::Function.new(
613
+ :name => "include",
614
+ :ftype => :statement,
615
+ :arguments => AST::ASTArray.new(
616
+ :children => [nameobj("one"), nameobj("two")]
617
+ )
618
+ )
619
+
620
+ top = AST::ASTArray.new(:children => children)
621
+
622
+ #assert_nothing_raised {
623
+ # scope.function_include(["one", "two"])
624
+ #}
625
+
626
+ assert_nothing_raised {
627
+ scope.evaluate(:ast => top)
628
+ }
629
+
630
+
631
+ assert(scope.classlist.include?("one"), "tag 'one' did not get set")
632
+ assert(scope.classlist.include?("two"), "tag 'two' did not get set")
633
+
634
+ # Now verify that the 'tagged' function works correctly
635
+ assert(scope.function_tagged("one"),
636
+ "tagged function incorrectly returned false")
637
+ assert(scope.function_tagged("two"),
638
+ "tagged function incorrectly returned false")
639
+ end
640
+
641
+ def test_definedfunction
642
+ scope = Puppet::Parser::Scope.new()
643
+
644
+ one = tempfile()
645
+ two = tempfile()
646
+
647
+ children = []
648
+
649
+ children << classobj("one", :code => AST::ASTArray.new(
650
+ :children => [
651
+ fileobj(one, "owner" => "root")
652
+ ]
653
+ ))
654
+
655
+ children << classobj("two", :code => AST::ASTArray.new(
656
+ :children => [
657
+ fileobj(two, "owner" => "root")
658
+ ]
659
+ ))
660
+
661
+ top = AST::ASTArray.new(:children => children)
662
+
663
+ top.evaluate(:scope => scope)
664
+
665
+ assert_nothing_raised {
666
+ %w{one two file user}.each do |type|
667
+ assert(scope.function_defined([type]),
668
+ "Class #{type} was not considered defined")
669
+ end
670
+
671
+ assert(!scope.function_defined(["nopeness"]),
672
+ "Class 'nopeness' was incorrectly considered defined")
673
+ }
674
+
675
+
676
+ end
677
+
678
+ # Make sure components acquire defaults.
679
+ def test_defaultswithcomponents
680
+ children = []
681
+
682
+ # Create a component
683
+ filename = tempfile()
684
+ args = AST::ASTArray.new(
685
+ :file => tempfile(),
686
+ :line => rand(100),
687
+ :children => [nameobj("argument")]
688
+ )
689
+ children << compobj("comp", :args => args, :code => AST::ASTArray.new(
690
+ :children => [
691
+ fileobj(filename, "owner" => varref("argument") )
692
+ ]
693
+ ))
694
+
695
+ # Create a default
696
+ children << defaultobj("comp", "argument" => "yayness")
697
+
698
+ # lastly, create an object that calls our third component
699
+ children << objectdef("comp", "boo", {"argument" => "parentfoo"})
700
+
701
+ trans = assert_evaluate(children)
702
+
703
+ flat = trans.flatten
704
+
705
+ assert(!flat.empty?, "Got no objects back")
706
+
707
+ assert_equal("parentfoo", flat[0]["owner"], "default did not take")
708
+ end
709
+
710
+ if defined? ActiveRecord
711
+ # Verify that we recursively mark as collectable the results of collectable
712
+ # components.
713
+ def test_collectablecomponents
714
+ children = []
715
+
716
+ args = AST::ASTArray.new(
717
+ :file => tempfile(),
718
+ :line => rand(100),
719
+ :children => [nameobj("arg")]
720
+ )
721
+ # Create a top-level component
722
+ children << compobj("one", :args => args)
723
+
724
+ # And a component that calls it
725
+ children << compobj("two", :args => args, :code => AST::ASTArray.new(
726
+ :children => [
727
+ objectdef("one", "ptest", {"arg" => "parentfoo"})
728
+ ]
729
+ ))
730
+
731
+ # And then a third component that calls the second
732
+ children << compobj("three", :args => args, :code => AST::ASTArray.new(
733
+ :children => [
734
+ objectdef("two", "yay", {"arg" => "parentfoo"})
735
+ ]
736
+ ))
737
+
738
+ # lastly, create an object that calls our third component
739
+ obj = objectdef("three", "boo", {"arg" => "parentfoo"})
740
+
741
+ # And mark it as collectable
742
+ obj.collectable = true
743
+
744
+ children << obj
745
+
746
+ top = nil
747
+ assert_nothing_raised("Could not create top object") {
748
+ top = AST::ASTArray.new(
749
+ :children => children
750
+ )
751
+ }
752
+
753
+ trans = nil
754
+ scope = nil
755
+ assert_nothing_raised {
756
+ scope = Puppet::Parser::Scope.new()
757
+ trans = scope.evaluate(:ast => top)
758
+ }
759
+
760
+ %w{file}.each do |type|
761
+ objects = scope.exported(type)
762
+
763
+ assert(!objects.empty?, "Did not get an exported %s" % type)
764
+ end
765
+ end
766
+
767
+ # Verify that we can both store and collect an object in the same
768
+ # run, whether it's in the same scope as a collection or a different
769
+ # scope.
770
+ def test_storeandcollect
771
+ Puppet[:storeconfigs] = true
772
+ Puppet::Rails.clear
773
+ Puppet::Rails.init
774
+ sleep 1
775
+ children = []
776
+ file = tempfile()
777
+ File.open(file, "w") { |f|
778
+ f.puts "
779
+ class yay {
780
+ @host { myhost: ip => \"192.168.0.2\" }
781
+ }
782
+ include yay
783
+ @host { puppet: ip => \"192.168.0.3\" }
784
+ host <||>"
785
+ }
786
+
787
+ interp = nil
788
+ assert_nothing_raised {
789
+ interp = Puppet::Parser::Interpreter.new(
790
+ :Manifest => file,
791
+ :UseNodes => false,
792
+ :ForkSave => false
793
+ )
794
+ }
795
+
796
+ objects = nil
797
+ # We run it twice because we want to make sure there's no conflict
798
+ # if we pull it up from the database.
799
+ 2.times { |i|
800
+ assert_nothing_raised {
801
+ objects = interp.run("localhost", {})
802
+ }
803
+
804
+ flat = objects.flatten
805
+
806
+ %w{puppet myhost}.each do |name|
807
+ assert(flat.find{|o| o.name == name }, "Did not find #{name}")
808
+ end
809
+ }
810
+ end
811
+
812
+ # Verify that we cannot override differently exported objects
813
+ def test_exportedoverrides
814
+ filename = tempfile()
815
+ children = []
816
+
817
+ obj = fileobj(filename, "owner" => "root")
818
+ obj.collectable = true
819
+ # create the parent class
820
+ children << classobj("parent", :code => AST::ASTArray.new(
821
+ :children => [
822
+ obj
823
+ ]
824
+ ))
825
+
826
+ # now create a child class with differ values
827
+ children << classobj("child", :parentclass => nameobj("parent"),
828
+ :code => AST::ASTArray.new(
829
+ :children => [
830
+ fileobj(filename, "owner" => "bin")
831
+ ]
832
+ ))
833
+
834
+ # Now call the child class
835
+ assert_nothing_raised("Could not add AST nodes for calling") {
836
+ children << AST::ObjectDef.new(
837
+ :type => nameobj("child"),
838
+ :name => nameobj("yayness"),
839
+ :params => astarray()
840
+ )
841
+ }
842
+
843
+ top = nil
844
+ assert_nothing_raised("Could not create top object") {
845
+ top = AST::ASTArray.new(
846
+ :children => children
847
+ )
848
+ }
849
+
850
+ objects = nil
851
+ scope = nil
852
+ assert_raise(Puppet::ParseError, "Incorrectly allowed override") {
853
+ scope = Puppet::Parser::Scope.new()
854
+ objects = scope.evaluate(:ast => top)
855
+ }
856
+ end
857
+ else
858
+ $stderr.puts "No ActiveRecord -- skipping collection tests"
859
+ end
566
860
  end