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

ASF GitHub Bot commented on YARN-11404:
---------------------------------------

susheel-gupta commented on code in PR #5295:
URL: https://github.com/apache/hadoop/pull/5295#discussion_r1068597901


##########
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java:
##########
@@ -257,12 +260,6 @@ public void testGetMapCompletionEvents() throws 
IOException {
         createTce(3, false, TaskAttemptCompletionEventStatus.FAILED) };
     TaskAttemptCompletionEvent[] mapEvents = { taskEvents[0], taskEvents[2] };
     Job mockJob = mock(Job.class);
-    when(mockJob.getTaskAttemptCompletionEvents(0, 100))
-      .thenReturn(taskEvents);
-    when(mockJob.getTaskAttemptCompletionEvents(0, 2))
-      .thenReturn(Arrays.copyOfRange(taskEvents, 0, 2));
-    when(mockJob.getTaskAttemptCompletionEvents(2, 100))
-      .thenReturn(Arrays.copyOfRange(taskEvents, 2, 4));

Review Comment:
   Encountered with this error:
   
   ```
   org.mockito.exceptions.misusing.UnnecessaryStubbingException: 
   Unnecessary stubbings detected.
   Clean & maintainable test code requires zero unnecessary code.
   Following stubbings are unnecessary (click to navigate to relevant line of 
code):
     1. -> at 
org.apache.hadoop.mapred.TestTaskAttemptListenerImpl.lambda$testGetMapCompletionEvents$2(TestTaskAttemptListenerImpl.java:267)
     2. -> at 
org.apache.hadoop.mapred.TestTaskAttemptListenerImpl.lambda$testGetMapCompletionEvents$2(TestTaskAttemptListenerImpl.java:269)
     3. -> at 
org.apache.hadoop.mapred.TestTaskAttemptListenerImpl.lambda$testGetMapCompletionEvents$2(TestTaskAttemptListenerImpl.java:271)
   ```
   It was a  unnecessary stubbed call that was never realized during test 
execution.So either I have to remove it or use use 'lenient' strictness like 
this:
   ```
       lenient().when(mockJob.getTaskAttemptCompletionEvents(0, 100))
           .thenReturn(taskEvents);
       lenient().when(mockJob.getTaskAttemptCompletionEvents(0, 2))
           .thenReturn(Arrays.copyOfRange(taskEvents, 0, 2));
       lenient().when(mockJob.getTaskAttemptCompletionEvents(2, 100))
           .thenReturn(Arrays.copyOfRange(taskEvents, 2, 4));
   ```
   I think it is better to use 'lenient' strictness





> Add junit5 dependency to hadoop-mapreduce-client-app to fix few unit test 
> failure
> ---------------------------------------------------------------------------------
>
>                 Key: YARN-11404
>                 URL: https://issues.apache.org/jira/browse/YARN-11404
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: yarn
>            Reporter: Susheel Gupta
>            Assignee: Susheel Gupta
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: 
> patch-unit-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-app.txt
>
>
> We need to add Junit 5 dependency in
> {code:java}
> /hadoop/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml{code}
> as the testcase TestAMWebServicesJobConf, TestAMWebServicesJobs, 
> TestAMWebServices, TestAMWebServicesAttempts, TestAMWebServicesTasks were 
> passing locally but failed at jenkins build in this 
> [link|https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5119/7/artifact/out/patch-unit-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-app.txt]
>  for YARN-5607



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to