def evaluate
@count = 0
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"
next
end
ret = nil
seconds = thinmark do
begin
Timeout::timeout(resource[:expire]) {
ret = eval_resource(resource)
}
rescue(Timeout::Error)
Puppet.err "#{resource.to_s} expired at #{resource[:expire]} seconds."
@failures[resource] += 1
end
end
if Puppet[:evaltrace] and @catalog.host_config?
resource.info "Evaluated in %0.2f seconds" % seconds
end
ret
}.flatten.reject { |e| e.nil? }
ensure
Puppet::Util::Log.close(@report)
end
Puppet.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 .*/)
@transaction.evaluate
end
it "should timeout with a useful message"
it "should not timeout when the running time of the resource is less than the 'expire' parameter"
end