[ https://issues.apache.org/jira/browse/HADOOP-8981?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13504810#comment-13504810 ]
Xuan Gong commented on HADOOP-8981: ----------------------------------- For this test failure, I do not think our code has any problems. So, basically, how the testInitFirst function works like this: it will register three sinks, named "Test","Sink1" and "Sink2", each of them has its own blockingQueue, initially the queue is empty, and if there are any items in the queue, they will consume them. In the testInitFirst function, what the function ms.onTimerEvent() did is to put items to all of the queues that let the sinks can consume the items. Followed by this function is stop function. Basically it stops all the threads. Why the test is fail is because the sink does not finish to consume the items, it is stopped by calling the function stop(). If we add Thread.sleep(sometime) before the stop function, the test will be successful.Original I think maybe we can add the checking condition to check if the queue is empty before we actually do the stop. But I think that the purpose of this stop() function is when I call this functions, all the sink threads should stop no matter they are idle or they are doing something. If we actually add the checking condition or other synchronized mechnism to make sure all the items in queue is consumed before we stop the thread, does this violate the purpose of calling stop function ? And actually the test is fail, on the other side, it proved that our stop function is actually worked correctly. When we call the stop, everything is stopped no matter what they are doing right now. Based on that, I runned this test several times, I found that sometimes it will be successful, sometimes half rigth half wrong, sometimes all fails. If we try to make the testcase pass, what we need to do is to change the test case to : verify(sink1, atMost(2)).putMetrics(r1.capture()); List<MetricsRecord> mr1 = r1.getAllValues(); verify(sink2, atMost(2)).putMetrics(r2.capture()); List<MetricsRecord> mr2 = r2.getAllValues(); if(mr1.size() != 0 && mr2.size() != 0){ checkMetricsRecords(mr1); assertEquals("output", mr1, mr2); }else if(mr1.size() != 0){ checkMetricsRecords(mr1); }else if(mr2.size() != 0){ checkMetricsRecords(mr2); } > TestMetricsSystemImpl fails on Windows > -------------------------------------- > > Key: HADOOP-8981 > URL: https://issues.apache.org/jira/browse/HADOOP-8981 > Project: Hadoop Common > Issue Type: Bug > Components: metrics > Affects Versions: trunk-win > Reporter: Chris Nauroth > Assignee: Arpit Agarwal > > The test is failing on an expected mock interaction. -- 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