From 0b3cd365f2b322445328607e6d1a77caabe8413a Mon Sep 17 00:00:00 2001 From: Sam Goldstein Date: Fri, 18 May 2012 01:28:01 -0700 Subject: [PATCH] Make time based tests less likely to fail non-deterministically These tests deal with real durations of time, and can fail due to GC or other performance impacting events. Increase the time scales slightly to make them less prone for sporadic failure. --- test/new_relic/agent/transaction_sampler_test.rb | 6 +++--- test/new_relic/agent/worker_loop_test.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/new_relic/agent/transaction_sampler_test.rb b/test/new_relic/agent/transaction_sampler_test.rb index 7a3f807ffa..174c6f88c8 100644 --- a/test/new_relic/agent/transaction_sampler_test.rb +++ b/test/new_relic/agent/transaction_sampler_test.rb @@ -756,17 +756,17 @@ def test_harvest_slowest slowest = @sampler.harvest(nil, 0)[0] assert((slowest.duration >= 0.09), "expected sample duration >= 0.09, but was: #{slowest.duration.inspect}") # this assert is here to make sure the test remains valid - assert((slowest.duration <= 0.15), "expected sample duration <= 0.15, but was: #{slowest.duration.inspect}") + assert((slowest.duration <= 0.2), "expected sample duration <= 0.15, but was: #{slowest.duration.inspect}") run_sample_trace { sleep 0.0001 } not_as_slow = @sampler.harvest(slowest, 0)[0] assert((not_as_slow == slowest), "Should re-harvest the same transaction since it should be slower than the new transaction - expected #{slowest.inspect} but got #{not_as_slow.inspect}") - run_sample_trace { sleep 0.16 } + run_sample_trace { sleep 0.25 } new_slowest = @sampler.harvest(slowest, 0)[0] assert((new_slowest != slowest), "Should not harvest the same trace since the new one should be slower") - assert((new_slowest.duration >= 0.15), "Slowest duration must be >= 0.15, but was: #{new_slowest.duration.inspect}") + assert((new_slowest.duration >= 0.2), "Slowest duration must be >= 0.15, but was: #{new_slowest.duration.inspect}") end def test_prepare_to_send diff --git a/test/new_relic/agent/worker_loop_test.rb b/test/new_relic/agent/worker_loop_test.rb index 6a055520ae..d5bffd4d98 100644 --- a/test/new_relic/agent/worker_loop_test.rb +++ b/test/new_relic/agent/worker_loop_test.rb @@ -23,7 +23,7 @@ def test_density # This shows how the tasks stay aligned with the period and don't drift. count = 0 start = Time.now - @worker_loop.run(0.01) do + @worker_loop.run(0.03) do count +=1 if count == 3 @worker_loop.stop @@ -31,7 +31,7 @@ def test_density end end elapsed = Time.now - start - assert_in_delta 0.03, elapsed, 0.02 + assert_in_delta 0.09, elapsed, 0.02 end def test_task_error__standard @logger.expects(:debug)