Skip to content

Commit

Permalink
Fix one more nondeterministic test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Goldstein committed May 18, 2012
1 parent 7184b45 commit 7888faf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/new_relic/agent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,19 @@ def test_timeslice_harvest_with_after_fork_report_to_channel
.record_data_point(2.0)
exit
end
Process.wait(pid)
# Just because the forked child has exited doesn't mean that the pipes have
# been flushed and the parent process has completed merging the data. Wait
# for the pipe to close before continuing (but timeout after 10 seconds).
Timeout.timeout(10) do
Process.wait(pid)
listener = NewRelic::Agent::PipeChannelManager.listener
loop do
break if ! listener.pipes[:test]
break if listener.pipes[:test].out.closed?
puts "waiting for pipe to be closed and data to be merged"
sleep 0.1
end
end

engine = NewRelic::Agent.agent.stats_engine
assert_equal(3.0, engine.lookup_stats(metric).total_call_time)
Expand Down

0 comments on commit 7888faf

Please sign in to comment.