You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Adam Antal (JIRA)" <ji...@apache.org> on 2019/08/12 15:41:00 UTC

[jira] [Comment Edited] (HADOOP-16503) [JDK11] TestLeafQueue tests are failing due to WrongTypeOfReturnValue

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

Adam Antal edited comment on HADOOP-16503 at 8/12/19 3:40 PM:
--------------------------------------------------------------

Uploaded patchset v1.

Changes:
- prefering doReturn(...).when(...).method(..) over when(...).thenReturn() statements to mitigate the actual calls on the spies and mocks
- moved the mocking of the method {{getScheduler}} of the {{cs}} spy object to a few lines above. An org.mockito.exceptions.misusing.UnfinishedStubbingException is thrown otherwise. I am not sure about the root cause, because in this form mocking should have been finished, presumably there can be something inside {{cs.start()}} (starting some threads in the background) that can be a problem.

Pls review.


was (Author: adam.antal):
Uploaded patchset v1.

Changes:
- prefering doReturn(...).when(...).method(..) over when(...).thenReturn() statements to mitigate the actual calls on the spies and mocks
- moved the mocking of the method {{getScheduler}} of the {{cs}} spy object to a few lines above. An org.mockito.exceptions.misusing.UnfinishedStubbingException is thrown otherwise. I am not sure about the root cause, because this form is finished in this way, but there can be something inside {{cs.start()}} that can be a problem.

Pls review.

> [JDK11] TestLeafQueue tests are failing due to WrongTypeOfReturnValue
> ---------------------------------------------------------------------
>
>                 Key: HADOOP-16503
>                 URL: https://issues.apache.org/jira/browse/HADOOP-16503
>             Project: Hadoop Common
>          Issue Type: Sub-task
>    Affects Versions: 3.2.0
>            Reporter: Adam Antal
>            Assignee: Adam Antal
>            Priority: Major
>
> Many of the tests in {{org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestLeafQueue}} fails with the following error message running on JDK11:
> {noformat}
> [ERROR] testSingleQueueWithOneUser(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestLeafQueue)  Time elapsed: 0.204 s  <<< ERROR!
> org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
> YarnConfiguration cannot be returned by getRMNodes()
> getRMNodes() should return ConcurrentMap
> ***
> If you're unsure why you're getting above error read on.
> Due to the nature of the syntax above problem might occur because:
> 1. This exception *might* occur in wrongly written multi-threaded tests.
>    Please refer to Mockito FAQ on limitations of concurrency testing.
> 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies -
>    - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
> 	at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestLeafQueue.setUpInternal(TestLeafQueue.java:221)
> 	at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestLeafQueue.setUp(TestLeafQueue.java:144)
>        ...
> {noformat}
> This is due to the actual execution of the call, while we need to record only the invocation of it. According to the javadocs and other folks.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org