Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-11429

Improve updateTestDataAutomatically in TestRMWebServicesCapacitySched

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • yarn
    • Reviewed

    Description

      The updateTestDataAutomatically helper function should have a fix json format to be useful.

          String actual = json.toString(2);
          updateTestDataAutomatically(expectedResourceFilename, actual);
          assertEquals(
              prettyPrintJson(getResourceAsString(expectedResourceFilename)),
              prettyPrintJson(actual));
      

      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:

      String actual = prettyPrintJson(json.toString(2));
      updateTestDataAutomatically(expectedResourceFilename, actual);
      assertEquals(
          getResourceAsString(expectedResourceFilename),
          actual);
      

      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:

        private static String prettyPrintJson(String in) throws JsonProcessingException {
          ObjectMapper objectMapper = new ObjectMapper();
          return objectMapper
              .writerWithDefaultPrettyPrinter()
              .writeValueAsString(objectMapper.readTree(in));
        }
      

      Attachments

        Issue Links

          Activity

            People

              tdomok Tamas Domok
              tdomok Tamas Domok
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: