diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-09 20:59:41 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-07-18 10:31:10 +1000 |
| commit | b2a008e30ea57f0c94d605de855c45c0fdf0e5ce (patch) | |
| tree | c64527d7d056c9d67e0ed78e44234b07e3082c36 /spec/unit/resource | |
| parent | 8f8240763b0a8ab74b5b78eeb2372a2aa7848049 (diff) | |
| download | puppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.tar.gz puppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.tar.xz puppet-b2a008e30ea57f0c94d605de855c45c0fdf0e5ce.zip | |
Fix #2391 - Exported resources never make to the storeconfigs db
The issue is that when we convert Puppet::Parser::Resource catalog
to a Puppet::Resource catalog before storing it to the database,
we don't allow virtual resource to be converted.
Unfortunately exported resources are virtual by design, and as
such aren't converted, and we lose them, so it isn't possible
to store them in the database.
Unfortunately, the client will get the exported resources too.
The fix is dual-fold:
* we make sure exported resource are skipped when the transaction is
applied as a last safeguard
* we filter-out the catalog through the catalog compiler terminus before
the catalog is returned to the client
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/resource')
| -rwxr-xr-x | spec/unit/resource/catalog.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb index 2f4476a2b..97b6ad7cc 100755 --- a/spec/unit/resource/catalog.rb +++ b/spec/unit/resource/catalog.rb @@ -295,6 +295,47 @@ describe Puppet::Resource::Catalog, "when compiling" do end end + describe "when filtering" do + before :each do + @original = Puppet::Resource::Catalog.new("mynode") + @original.tag(*%w{one two three}) + @original.add_class *%w{four five six} + + @r1 = stub_everything 'r1', :ref => "File[/a]" + @r1.stubs(:respond_to?).with(:ref).returns(true) + @r1.stubs(:dup).returns(@r1) + @r1.stubs(:is_a?).returns(Puppet::Resource).returns(true) + + @r2 = stub_everything 'r2', :ref => "File[/b]" + @r2.stubs(:respond_to?).with(:ref).returns(true) + @r2.stubs(:dup).returns(@r2) + @r2.stubs(:is_a?).returns(Puppet::Resource).returns(true) + + @resources = [@r1,@r2] + + @original.add_resource(@r1,@r2) + end + + it "should transform the catalog to a resource catalog" do + @original.expects(:to_catalog).with { |h,b| h == :to_resource } + + @original.filter + end + + it "should scan each catalog resource in turn and apply filtering block" do + @resources.each { |r| r.expects(:exported?) } + @original.filter do |r| + r.exported? + end + end + + it "should filter out resources which produce true when the filter block is evaluated" do + @original.filter do |r| + r == @r1 + end.resource("File[/a]").should be_nil + end + end + describe "when functioning as a resource container" do before do @catalog = Puppet::Resource::Catalog.new("host") |
