Sha256: 0161f38969aeca113caeca6880d627c039e2743d59b50887307b265892dac59f
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
ENV['SKIP_RAILS'] = 'true' require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper')) class NewRelic::Agent::WorkerLoopTest < Test::Unit::TestCase def setup @log = "" @logger = Logger.new(StringIO.new(@log)) @worker_loop = NewRelic::Agent::WorkerLoop.new @worker_loop.stubs(:log).returns(@logger) @test_start_time = Time.now end def test_add_task @x = false @worker_loop.run(0) do @worker_loop.stop @x = true end assert @x end 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.002) do count +=1 if count == 10 @worker_loop.stop next end end elapsed = Time.now - start assert_in_delta 0.019, elapsed, 0.02 end def test_task_error__standard @logger.expects(:debug) @logger.expects(:error) # This loop task will run twice done = false @worker_loop.run(0) do @worker_loop.stop done = true raise "Standard Error Test" end assert done end class BadBoy < Exception; end def test_task_error__exception @logger.expects(:error).once @logger.expects(:debug).once @worker_loop.run(0) do @worker_loop.stop raise BadBoy, "oops" end end def test_task_error__server @logger.expects(:error).never @logger.expects(:debug).once @worker_loop.run(0) do @worker_loop.stop raise NewRelic::Agent::ServerError, "Runtime Error Test" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
newrelic_rpm-3.1.0.beta2 | test/new_relic/agent/worker_loop_test.rb |
newrelic_rpm-3.1.0.beta1 | test/new_relic/agent/worker_loop_test.rb |