Sha256: cfb320e9044435a51f5f510f7710ed0efa8dc1718099e319328570f8d42b0a0a

Contents?: true

Size: 1.81 KB

Versions: 42

Compression:

Stored size: 1.81 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))

class NewRelic::Agent::Transaction
  class SlowestSampleBufferTest < Minitest::Test
    def setup
      @buffer = SlowestSampleBuffer.new
    end

    def test_store_sample
      sample = stub(:duration => 2.0, :threshold => 1.0)
      @buffer.store(sample)
      assert_equal([sample], @buffer.samples)
    end

    def test_store_new_is_slowest
      old_sample = stub(:duration => 3.0, :threshold => 1.0)
      new_sample = stub(:duration => 4.0, :threshold => 1.0)

      @buffer.store(old_sample)
      @buffer.store(new_sample)

      assert_equal([new_sample], @buffer.samples)
    end

    def test_store_new_is_faster
      old_sample = stub(:duration => 4.0, :threshold => 1.0)
      new_sample = stub(:duration => 3.0, :threshold => 1.0)

      @buffer.store(old_sample)
      @buffer.store(new_sample)

      assert_equal([old_sample], @buffer.samples)
    end

    def test_store_does_not_store_if_faster_than_threshold
      old_sample = stub('old', :duration => 1.0, :threshold => 0.5)
      new_sample = stub('new', :duration => 2.0, :threshold => 4.0)

      @buffer.store(old_sample)
      @buffer.store(new_sample)

      assert_equal([old_sample], @buffer.samples)
    end

    def test_harvest_samples
      sample = stub(:duration => 1.0, :threshold => 1.0)
      @buffer.store(sample)

      harvested = @buffer.harvest_samples

      assert_equal([sample], harvested)
    end

    def test_harvest_samples_resets
      sample = stub(:duration => 1.0, :threshold => 1.0)
      @buffer.store(sample)

      @buffer.harvest_samples

      assert(@buffer.samples.empty?)
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
newrelic_rpm-4.1.0.333 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-4.0.0.332 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.18.1.330 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.18.0.329 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.17.2.327 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.17.1.326 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.17.0.325 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.16.3.323 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.16.2.321 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.16.1.320 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.16.0.318 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.15.2.317 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.15.1.316 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.15.0.314 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.14.3.313 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.14.2.312 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.14.1.311 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/agent/transaction/slowest_sample_buffer_test.rb