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

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

brumi1024 commented on PR #5736:
URL: https://github.com/apache/hadoop/pull/5736#issuecomment-1591114150

   Thanks @tomicooler for the update, looks good to me, and improves the 
readability.
   
   It's not strictly related to this patch, and probably not in its scope, but 
I don't really get why are we doing the following flow for a simple JSON pretty 
print: string -> JSON POJO (lib#1) -> string -> create an ObjectMapper per 
pretty print (it's a really heavyweight object, it should be reused) -> JSON 
POJO (lib#2) -> string again. This is much-much slower than necessary. Probably 
this should be refactored later.
   
   Regardless I'll merge this now, and create a followup ticket.




> Improve updateTestDataAutomatically in TestRMWebServicesCapacitySched
> ---------------------------------------------------------------------
>
>                 Key: YARN-11429
>                 URL: https://issues.apache.org/jira/browse/YARN-11429
>             Project: Hadoop YARN
>          Issue Type: Improvement
>          Components: yarn
>            Reporter: Tamas Domok
>            Assignee: Tamas Domok
>            Priority: Major
>              Labels: pull-request-available
>
> The 
> [updateTestDataAutomatically|https://github.com/apache/hadoop/blob/bfce21ee08f2faef795354ac3615eb2a393bd158/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java#L340]
>  helper function should have a fix json format to be useful.
> {code:java}
>     String actual = json.toString(2);
>     updateTestDataAutomatically(expectedResourceFilename, actual);
>     assertEquals(
>         prettyPrintJson(getResourceAsString(expectedResourceFilename)),
>         prettyPrintJson(actual));
> {code}
> The comparison is working with different json formats which is all right, but 
> updating the test data should be easy, and the git diff should be easily 
> readable by humans.
> Something like this could work:
> {code}
> String actual = prettyPrintJson(json.toString(2));
> updateTestDataAutomatically(expectedResourceFilename, actual);
> assertEquals(
>     getResourceAsString(expectedResourceFilename),
>     actual);
> {code}
> The json's must be updated unfortunately with the new format.
> The defaults shouldn't change here. Maybe we should be even more explicit 
> with the format options:
> {code}
>   private static String prettyPrintJson(String in) throws 
> JsonProcessingException {
>     ObjectMapper objectMapper = new ObjectMapper();
>     return objectMapper
>         .writerWithDefaultPrettyPrinter()
>         .writeValueAsString(objectMapper.readTree(in));
>   }
> {code}



--
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