[
https://issues.apache.org/jira/browse/HDFS-10284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15245332#comment-15245332
]
Walter Su commented on HDFS-10284:
----------------------------------
bq. I think it's due to mocking fsn while being concurrently accessed by
another thread (smmthread).
Good point.
bq. Stubbing or verification of a shared mock from different threads is NOT the
proper way of testing because it will always lead to intermittent behavior.
(quote from https://github.com/mockito/mockito/wiki/FAQ)
bq. feel free to use mocks concurrently, however prepare (stub) them before the
concurrency starts. (quote from
https://code.google.com/archive/p/mockito/issues/301)
So I think we should move the stubbing
{code}
doReturn(true).when(fsn).inTransitionToActive();
{code}
before test starts, at least before {{smmthread}} is started. The patch looks
really good.
bq. I found the BlockManagerSafeMode$SafeModeMonitor#canLeave is not checking
the namesystem#inTransitionToActive()
It make sense. Would you create another jira for this?
> o.a.h.hdfs.server.blockmanagement.TestBlockManagerSafeMode.testCheckSafeMode
> fails intermittently
> -------------------------------------------------------------------------------------------------
>
> Key: HDFS-10284
> URL: https://issues.apache.org/jira/browse/HDFS-10284
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: test
> Affects Versions: 2.9.0
> Reporter: Mingliang Liu
> Assignee: Mingliang Liu
> Priority: Minor
> Attachments: HDFS-10284.000.patch, HDFS-10284.001.patch
>
>
> *Stacktrace*
> {code}
> org.mockito.exceptions.misusing.UnfinishedStubbingException:
> Unfinished stubbing detected here:
> -> at
> org.apache.hadoop.hdfs.server.blockmanagement.TestBlockManagerSafeMode.testCheckSafeMode(TestBlockManagerSafeMode.java:169)
> E.g. thenReturn() may be missing.
> Examples of correct stubbing:
> when(mock.isOk()).thenReturn(true);
> when(mock.isOk()).thenThrow(exception);
> doThrow(exception).when(mock).someVoidMethod();
> Hints:
> 1. missing thenReturn()
> 2. although stubbed methods may return mocks, you cannot inline mock
> creation (mock()) call inside a thenReturn method (see issue 53)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.TestBlockManagerSafeMode.testCheckSafeMode(TestBlockManagerSafeMode.java:169)
> {code}
> Sample failing pre-commit UT:
> https://builds.apache.org/job/PreCommit-HDFS-Build/15153/testReport/org.apache.hadoop.hdfs.server.blockmanagement/TestBlockManagerSafeMode/testCheckSafeMode/
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)