HDDS-8082. Check for unnecessary newlines in config defaults#10840
HDDS-8082. Check for unnecessary newlines in config defaults#10840cychiu8 wants to merge 2 commits into
Conversation
|
@adoroszlai Regarding HDDS-8082 you created, here is the PR. Happy to have your feedback whenever you get a chance. |
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for picking this up! I left one question about properties filtered by xmlPropsToSkipCompare and xmlPrefixToSkipCompare, as they may unintentionally bypass the new check. The other comments are optional readability suggestions.
Overall, the approach looks good to me. Thanks!
| @Test | ||
| public void testXmlValuesHaveNoEmbeddedNewlines() { | ||
| Set<String> xmlValuesWithNewlines = new HashSet<>(); | ||
| for (Map.Entry<String, String> entry : xmlKeyValueMap.entrySet()) { |
There was a problem hiding this comment.
Would it make sense to check newlines before applying xmlPropsToSkipCompare and xmlPrefixToSkipCompare? therwise, properties excluded from field comparison also skip this check, even if they are not listed in xmlPropsAllowedToContainNewline.
There was a problem hiding this comment.
Thank you for reviewing. You mentioned a great point that I should decouple the newline check, which should not depend on the excluded properties.
|
|
||
| assertTrue(xmlValuesWithNewlines.isEmpty(), | ||
| "These properties in " + xmlFilename + " have an embedded line break in " | ||
| + "their <value>, which corrupts the runtime string: " + xmlValuesWithNewlines |
There was a problem hiding this comment.
nit: There is an extra space after runtime string:.
There was a problem hiding this comment.
Nice catch. Thank you!
| */ | ||
| @Test | ||
| public void testXmlValuesHaveNoEmbeddedNewlines() { | ||
| Set<String> xmlValuesWithNewlines = new HashSet<>(); |
There was a problem hiding this comment.
nit: Would a TreeSet be useful here to keep the failure output deterministic? The sibling checks in this class also use it.
There was a problem hiding this comment.
Thank you for the feedback. It makes sense! I have addressed it.
What changes were proposed in this pull request?
HDDS-8046 removed some unnecessary newlines embedded in default config values in ozone-default.xml. Ayush Saxena had a great suggestion for avoiding these in the future:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-8082
How was this patch tested?
Test locally with the following command:
Testing three scenarios:
Detailed results for case 1 (Modify a value to include a newline: should fail)
Detailed results for case 2(Add a test property with an intentional newline in its value: should pass)
log:
Detailed results for case 3(Validate the current ozone-default.xml: should pass)