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

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

tomicooler opened a new pull request, #5736:
URL: https://github.com/apache/hadoop/pull/5736

   
   ### Description of PR
   
   The goal is to have the same json formatting options when using the 
`updateTestDataAutomatically` helper function.
   
   ### How was this patch tested?
   
   I verified that the updated JSON content is the same as before:
   ```shell
   # before
   ➜  
/Users/tdomok/Work/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/resources/webapp
 git:(YARN-11429) for f in *.json; do echo -n "$f "; cat $f | jq | md5sum; done
   scheduler-response-AbsoluteMode.json 3cd84395f2864bbfcab55d1f81be5f44  -
   scheduler-response-AbsoluteModeLegacyAutoCreation.json 
4dbd90be628a52fa16eac0bde3774d6d  -
   scheduler-response-PerUserResources.json eda777af4bf2f6cbfd3dc4b1a0ac945a  -
   scheduler-response-PercentageMode.json 9a1dbd77cb034390092a553bfb04c078  -
   scheduler-response-PercentageModeLegacyAutoCreation.json 
9ca117ab46a4eb8be261650d26b17ae4  -
   scheduler-response-WeightMode.json b87bc438cc66619e16edec4acef1dafb  -
   scheduler-response-WeightModeWithAutoCreatedQueues-After.json 
4265fb1c65813a44989f9f77cbd5e862  -
   scheduler-response-WeightModeWithAutoCreatedQueues-Before.json 
a239664f30b71478991b0504a66dc4a5  -
   scheduler-response.json 6e5b607d133ddf4e00eda23842b274db  -
   
   # after
   ➜  
/Users/tdomok/Work/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/resources/webapp
 git:(YARN-11429) for f in *.json; do echo -n "$f "; cat $f | jq | md5sum; done
   scheduler-response-AbsoluteMode.json 3cd84395f2864bbfcab55d1f81be5f44  -
   scheduler-response-AbsoluteModeLegacyAutoCreation.json 
4dbd90be628a52fa16eac0bde3774d6d  -
   scheduler-response-PerUserResources.json eda777af4bf2f6cbfd3dc4b1a0ac945a  -
   scheduler-response-PercentageMode.json 9a1dbd77cb034390092a553bfb04c078  -
   scheduler-response-PercentageModeLegacyAutoCreation.json 
9ca117ab46a4eb8be261650d26b17ae4  -
   scheduler-response-WeightMode.json b87bc438cc66619e16edec4acef1dafb  -
   scheduler-response-WeightModeWithAutoCreatedQueues-After.json 
4265fb1c65813a44989f9f77cbd5e862  -
   scheduler-response-WeightModeWithAutoCreatedQueues-Before.json 
a239664f30b71478991b0504a66dc4a5  -
   scheduler-response.json 6e5b607d133ddf4e00eda23842b274db  -
   ```
   
   ### For code changes:
   
   - [x] Does the title or this PR starts with the corresponding JIRA issue id 
(e.g. 'YARN-11429. Your PR title ...')?
   - [ ] Object storage: have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   




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