Tamas Domok created YARN-11429:
----------------------------------
Summary: 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
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]