Skip to content

Commit

Permalink
Adding a few more tests to flush situations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jqr committed Feb 17, 2012
1 parent 5dcbdfe commit d50e5f9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions spec/agent_spec.rb
Expand Up @@ -27,13 +27,19 @@ def wait
@server.connect_count.should == 0
end

it "should no op on flush" do
it "should no op on flush without reconnect" do
1.upto(100) { @agent.gauge('disabled_test', 1) }
@agent.flush
@agent.flush(false)
wait
@server.commands.should be_empty
end

it "should no op on flush with reconnect" do
1.upto(100) { @agent.gauge('disabled_test', 1) }
@agent.flush(true)
wait
@server.commands.should be_empty
end
end

describe Instrumental::Agent, "enabled in test_mode" do
Expand Down Expand Up @@ -371,6 +377,15 @@ def wait
@agent.queue.pop(true).should include("increment reconnect_test 1 1234\n")
end

it "should send commands in a short-lived process" do
@server = TestServer.new
@agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => false)
if pid = fork { @agent.increment('foo', 1, 1234) }
Process.wait(pid)
@server.commands.last.should == "increment foo 1 1234"
end
end

it "should not wait longer than EXIT_FLUSH_TIMEOUT seconds to exit a process" do
@server = TestServer.new
@agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => false)
Expand Down

0 comments on commit d50e5f9

Please sign in to comment.