Sha256: 820554aa129e576df1b40dcbf28de3712a2d0d9d5a64f9502d392d45e4015f78

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'
require 'puppet/util/instrumentation'

Puppet::Util::Instrumentation.init
performance = Puppet::Util::Instrumentation.listener(:performance)

describe performance do
  before(:each) do
    @performance = performance.new
  end

  it "should have a notify method" do
    @performance.should respond_to(:notify)
  end

  it "should have a data method" do
    @performance.should respond_to(:data)
  end

  it "should keep data for stop event" do
    @performance.notify(:test, :stop, { :started => Time.at(123456789), :finished => Time.at(123456790)})
    @performance.data.should == {:test=>{:average=>1.0, :count=>1, :min=>1.0, :max=>1.0, :sum=>1.0}}
  end

  it "should accumulate performance statistics" do
    @performance.notify(:test, :stop, { :started => Time.at(123456789), :finished => Time.at(123456790)})
    @performance.notify(:test, :stop, { :started => Time.at(123456789), :finished => Time.at(123456791)})

    @performance.data.should == {:test=>{:average=>1.5, :count=>2, :min=>1.0, :max=>2.0, :sum=>3.0}}
  end

  it "should not keep data for start event" do
    @performance.notify(:test, :start, { :started => Time.at(123456789)})
    @performance.data.should be_empty
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-2.7.13 spec/unit/util/instrumentation/listeners/performance_spec.rb
puppet-2.7.12 spec/unit/util/instrumentation/listeners/performance_spec.rb
puppet-2.7.11 spec/unit/util/instrumentation/listeners/performance_spec.rb