[ 
https://issues.apache.org/jira/browse/HADOOP-9057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503933#comment-13503933
 ] 

Mostafa Elhemali commented on HADOOP-9057:
------------------------------------------

Ah good point about needing to do it before the close. Would something like 
this work?

{{
try {
  verify(sink1, timeout(1000).times(2)).putMetrics(r1.capture());
} finally {
  ms.close();
}
}}

The reason I'm pushing for timeout() instead of straight-up sleep() is that 
timeout() is smart enough to finish early (it will wake up when it gets the 
required two calls), whereas with the sleep() approach we unnecessarily waste a 
second in this one test. A second may not seem like much, but it adds up in 
thousands of tests.

Another approach is to use latches in the sinks, but that seems too involved 
for no reason. Anyway, my votes/comments here are non-binding - just my 2 cents.
                
> TestMetricsSystemImpl.testInitFirst fails intermittently
> --------------------------------------------------------
>
>                 Key: HADOOP-9057
>                 URL: https://issues.apache.org/jira/browse/HADOOP-9057
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 1-win
>            Reporter: Ivan Mitic
>            Assignee: Ivan Mitic
>         Attachments: HADOOP-9057.branch-1-win.metricsrace.patch
>
>
> Error Message
>  Wanted but not invoked: metricsSink.putMetrics(<Capturing argument>); -> at 
> org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.testInitFirst(TestMetricsSystemImpl.java:80)
>  Actually, there were zero interactions with this mock. 
> Stacktrace
> Wanted but not invoked:
> metricsSink.putMetrics(<Capturing argument>);
> -> at 
> org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.testInitFirst(TestMetricsSystemImpl.java:80)
> Actually, there were zero interactions with this mock.
>       at 
> org.apache.hadoop.metrics2.impl.TestMetricsSystemImpl.testInitFirst(TestMetricsSystemImpl.java:80)
>       at 
> org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
>       at 
> org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
> Standard Output
> 2012-10-04 11:43:55,641 INFO  impl.MetricsConfig 
> (MetricsConfig.java:loadFirst(99)) - loaded properties from 
> hadoop-metrics2-test.properties

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to