From 7888fafb5e07450281f55802ee5e94553654117e Mon Sep 17 00:00:00 2001 From: Sam Goldstein Date: Fri, 18 May 2012 00:58:27 -0700 Subject: [PATCH] Fix one more nondeterministic test --- test/new_relic/agent_test.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/new_relic/agent_test.rb b/test/new_relic/agent_test.rb index 857b25656e..a3049083b2 100644 --- a/test/new_relic/agent_test.rb +++ b/test/new_relic/agent_test.rb @@ -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)