From d5abdfba8a88afda8085992a4abbe1d90bbd0084 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Thu, 5 Feb 2009 23:15:59 +0100 Subject: Fix #1933 - Inconsistent resource evaluation order in subsequent evaluation runs While evaluating the AST, catalog vertices are not always ordered the same way on different run, leading to some tags (which should have been applied in evaluation order) to not be associated with some underlying resources. This changeset change all accesses to resources inside the compiler to always use an ordered (in evaluation order) list of added resources. Signed-off-by: Brice Figureau --- spec/unit/parser/compiler.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'spec/unit') diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index f36b6fd4f..855a8c723 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -239,6 +239,31 @@ describe Puppet::Parser::Compiler do @compiler.send(:finish) end + it "should call finish() in add_resource order" do + resources = sequence('resources') + + resource1 = Puppet::Parser::Resource.new :scope => @scope, :type => "file", :title => "finish1" + resource1.expects(:finish).in_sequence(resources) + + @compiler.add_resource(@scope, resource1) + + resource2 = Puppet::Parser::Resource.new :scope => @scope, :type => "file", :title => "finish2" + resource2.expects(:finish).in_sequence(resources) + + @compiler.add_resource(@scope, resource2) + + @compiler.send(:finish) + end + + it "should return added resources in add order" do + resource1 = stub "1", :ref => "File[yay]" + @compiler.add_resource(@scope, resource1) + resource2 = stub "2", :ref => "File[youpi]" + @compiler.add_resource(@scope, resource2) + + @compiler.resources.should == [resource1, resource2] + end + it "should add resources that do not conflict with existing resources" do resource = stub "noconflict", :ref => "File[yay]" @compiler.add_resource(@scope, resource) @@ -484,7 +509,7 @@ describe Puppet::Parser::Compiler do Puppet.features.expects(:rails?).returns(true) Puppet::Rails.expects(:connect) - @compiler.catalog.expects(:vertices).returns(:resources) + @compiler.expects(:resources).returns(:resources) @compiler.expects(:store_to_active_record).with(@node, :resources) @compiler.send(:store) -- cgit