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

Szilard Nemeth commented on MAPREDUCE-7197:
-------------------------------------------

Hi [~adam.antal]! 
Thanks for this patch, it's quite extensive and precise.
However, I have some comments:

1. In 
org.apache.hadoop.mapreduce.jobhistory.TestJobHistoryEventHandler#testAMStartedEvent:
 
There are 2 code blocks you modified: 

a. 

{code:java}
assertThat(100).isEqualTo(mi.getJobIndexInfo().getSubmitTime());
assertThat(200).isEqualTo(mi.getJobIndexInfo().getJobStartTime());
assertThat(100).isEqualTo(mi.getJobSummary().getJobSubmitTime());
assertThat(200).isEqualTo(mi.getJobSummary().getJobLaunchTime());
{code}


b. 

{code:java}
assertThat(100).isEqualTo(mi.getJobIndexInfo().getSubmitTime());
assertThat(200).isEqualTo(mi.getJobIndexInfo().getJobStartTime());
assertThat(100).isEqualTo(mi.getJobSummary().getJobSubmitTime());
assertThat(200).isEqualTo(mi.getJobSummary().getJobLaunchTime());
{code}


Even though the original code had the expected and actual values interchanged, 
you should change the expected values with actual for these, for example: 

{code:java}
assertThat(mi.getJobIndexInfo().getSubmitTime()).isEqualTo(100); --> Expected 
value was 100.
{code}




2. In 
org.apache.hadoop.mapreduce.v2.app.TestRuntimeEstimators#coreTestEstimator: 
You removed one meaningful assertion with your patch: 
You have: 

{code:java}
assertThat(speculator.getProportionRunningTasksSpeculatable())
        .isCloseTo(0.1, offset(0.00001));
{code}


And we had: 

{code:java}
Assert.assertEquals(speculator.getProportionRunningTasksSpeculatable(),
        0.1, 0.00001);
Assert.assertEquals(speculator.getProportionTotalTasksSpeculatable(),
        0.001, 0.00001);

{code}

, so the assertion for speculator.getProportionTotalTasksSpeculatable() is 
missing.


3. In 
org.apache.hadoop.mapreduce.v2.app.job.impl.TestTaskAttempt#testContainerCleanedWhileRunning:
 
You have this change: 


{code:java}
assertThat(taImpl.getState())
        .withFailMessage("Task attempt is not in running state")
        .isEqualTo(TaskAttemptState.RUNNING);
{code}


I'd prefer to move the call to isEqualTo above withFailMessage. 
You have similar call structures throughout this class, please also change all 
of them!

4. In 
org.apache.hadoop.mapreduce.v2.app.job.impl.TestTaskAttempt#testFetchFailureAttemptFinishTime:
 
This assertion is weird, the message is not in line with the state type, please 
fix it! : 

{code:java}
assertThat(taImpl.getState())
        .withFailMessage("Task attempt is not in Too Many Fetch Failure state")
        .isEqualTo(TaskAttemptState.FAILED);
{code}


5. In 
org.apache.hadoop.mapreduce.v2.app.job.impl.TestTaskAttempt#testContainerKillAfterAssigned:
 
There's a typo (not introduced by you) in this assertion message: 

{code:java}
assertThat(taImpl.getInternalState())
        .withFailMessage("Task attempt is not in assinged state")
        .isEqualTo(TaskAttemptStateInternal.ASSIGNED);
{code}


6. In 
org.apache.hadoop.mapreduce.v2.app.job.impl.TestTaskAttempt#testTaskAttemptDiagnosticEventOnFinishing:
 
I like that you fixed some assertion message here: 

{code:java}
assertThat(taImpl.getState())
        .withFailMessage("Task attempt is not in succeeded state")
        .isEqualTo(TaskAttemptState.SUCCEEDED); 
{code}


However, please use the name of the state with uppercase letters. You have one 
more occurrence of this in the same method.

7. In org.apache.hadoop.mapred.TestJobConf: 
I can see some updates regarding enum fields (asserting them directly without 
using .name() ) but I can't see assertEquals rewritten to assertThat for a 
bunch of occurrences in the class, please fix this!

8. In org.apache.hadoop.mapreduce.task.reduce.TestMergeManager: 
Your 2 changes in this class are using assertNull. Can you please use 
assertThat + isNull instead? 

You have an occurrence of this in the following palces as well:

{code:java}
- org.apache.hadoop.mapred.TestTaskLog#testTaskLogWithoutTaskLogDir 
- In class org.apache.hadoop.mapreduce.security.TestTokenCache
- org.apache.hadoop.mapred.uploader.TestFrameworkUploader#testHelp
{code}


9. In 
org.apache.hadoop.mapreduce.v2.hs.TestJHSDelegationTokenSecretManager#stopAndCleanSecretManager:
 
You have this assertion: 

{code:java}
    assertThat(mgr.getAllTokens().size())
        .withFailMessage("Secret manager should not contain keys").isZero();
{code}


The original assertion was: 

{code:java}
Assert.assertEquals("Secret manager should not contain tokens",
        mgr.getAllTokens().size(), 0);
{code}


The assertion message should have the word "tokens" instead of "keys", I think.

10. In 
org.apache.hadoop.mapreduce.v2.hs.TestJobHistoryEntities#testCompletedJob: 
You rewritten one assertEquals to assertTrue. Can you use assertThat instead? 

11. In org.apache.hadoop.mapred.TestMultiFileSplit#testReadWrite: 
You started to use assertArrayEquals. Can you verify if assertJ has any method 
to test arrays / lists?

12. In org.apache.hadoop.mapreduce.v2.TestUberAM#testFailingMapper: 
You have one change that introduced Assert.assertFalse. Please use some assertJ 
method for this instead!

You have a similar ones in the following places (assertTrue / assertFalse): 

{code:java}
- 
org.apache.hadoop.mapred.nativetask.combinertest.CombinerTest#testWordCountCombiner
- org.apache.hadoop.mapred.nativetask.compresstest.CompressTest (throughout the 
class)
- org.apache.hadoop.mapred.nativetask.kvtest.KVTest#testKVCompability
- 
org.apache.hadoop.mapred.nativetask.combinertest.LargeKVCombinerTest#testLargeValueCombiner
- org.apache.hadoop.mapred.nativetask.nonsorttest.NonSortTest#nonSortTest
- 
org.apache.hadoop.mapred.nativetask.combinertest.OldAPICombinerTest#testWordCountCombinerWithOldAPI
- TestByteBufferReadWrite (throughout the class)
{code}


That's all I have!
Please fix these and upload a new patch. Obviously, I will only check the diff 
between the 2 patches :D 

> Fix order of actual and expected expression in assert statements
> ----------------------------------------------------------------
>
>                 Key: MAPREDUCE-7197
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-7197
>             Project: Hadoop Map/Reduce
>          Issue Type: Improvement
>    Affects Versions: 3.2.0
>            Reporter: Adam Antal
>            Assignee: Adam Antal
>            Priority: Major
>         Attachments: MAPREDUCE-7197.001.patch, MAPREDUCE-7197.002.patch, 
> MAPREDUCE-7197.003.patch, MAPREDUCE-7197.004.patch, MAPREDUCE-7197.004.patch, 
> old-approx-from-HADOOP-12693
>
>
> Fix order of actual and expected expression in assert statements which gives 
> misleading message when test case fails. Attached file has some of the places 
> where it is placed wrongly.
> {code:java}
> [ERROR] 
> testNodeRemovalGracefully(org.apache.hadoop.yarn.server.resourcemanager.TestResourceTrackerService)
>   Time elapsed: 3.385 s  <<< FAILURE!
> java.lang.AssertionError: Shutdown nodes should be 0 now expected:<1> but 
> was:<0>
> {code}
> For long term, [AssertJ|http://joel-costigliola.github.io/assertj/] can be 
> used for new test cases which avoids such mistakes.
> This is a follow-up Jira on the fix for the MR project.



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

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

Reply via email to