defevaluate@count=0 # Start logging.Puppet::Util::Log.newdestination(@report)
prepare()
begin
allevents =@sorted_resources.collect {|resource|
if resource.is_a?(Puppet::Type::Component)
Puppet.warning"Somehow left a component in the relationship graph"nextend
ret =nil
seconds = thinmark dobeginTimeout::timeout(resource[:expire]) {
ret =eval_resource(resource)
}
rescue(Timeout::Error)
Puppet.err"#{resource.to_s} expired at #{resource[:expire]} seconds."@failures[resource] +=1endendifPuppet[:evaltrace] and@catalog.host_config?
resource.info"Evaluated in %0.2f seconds"% seconds
end
ret
}.flatten.reject {|e| e.nil? }
ensure # And then close the transaction log.Puppet::Util::Log.close(@report)
endPuppet.debug"Finishing transaction %s with %s changes"%
[self.object_id, @count]
@events= allevents
allevents
end
describe Puppet::Transaction, " when evaluating"do
before do@config=Puppet::Resource::Catalog.new@transaction=Puppet::Transaction.new(@config)
end
it "should timeout when the running time of the resource is greater than the 'expire' parameter"do
resource =Puppet::Type.type(:exec).new(:name => "/bin/sleep 3", :expire => "1")
@config.add_resource(resource)
Puppet.expects(:err).with(/.* expired at .*/)
#lambda { @transaction.evaluate }.should raise_error@transaction.evaluateend
it "should timeout with a useful message"
it "should not timeout when the running time of the resource is less than the 'expire' parameter" #it "should not timeout when the running time of the resource is less than the 'expire' parameter" do #resource = Puppet::Type.type(:exec).create(:name => "/bin/sleep 3", :expire => "5") #@config.add_resource(resource) #lambda { @transaction.evaluate }.should_not raise_error #endend