krishnanand5 opened a new pull request, #15207: URL: https://github.com/apache/druid/pull/15207
<!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. --> <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. --> <!-- If you are a committer, follow the PR action item checklist for committers: https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. --> ### Description In this PR, I am proposing a fix for a flaky test identified in `org.apache.druid.storage.s3.S3DataSegmentPusherConfigTest.testSerialization`. <!-- Describe the goal of this PR, and what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. --> The mentioned test compares two strings. An `ObjectMapper` variable is being leveraged to carry out the serialization and deserialization process. The serialization process internally leverages a `getDeclaredFields()` function. As per [Javadoc](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--), > The elements in the returned array are not sorted and are not in any particular order. Because of the elements being returned in inconsistent orders, the toString() generates a string that might not adhere to the expected pattern during multiple executions. <!-- Describe your patch: what did you change in code? How did you fix the problem? --> The test is intended to evaluate the serialization of the concerned class. The value generated after the serialization process is a JSON string. When comparing two JSON strings, precedence should be given to evaluating the correctness of key:value pairs rather than the hardcoded strings. In order to overcome this problem, I am proposing to use a HashMap to deserialize the strings before they are compared. The usage of HashMap before the comparison occurs shifts the focus of test validation to evaluating the key-value pairs rather than the order in which they are serialized. The current lines of code are shown below: https://github.com/krishnanand5/druid/blob/ad32f8458670339808a3136a9578a10a52b8394f/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherConfigTest.java#L44-L45 The following lines of code, if replaced, help in addressing the flakiness seen in this test: https://github.com/krishnanand5/druid/blob/864bb43f73cb06488c6dd62cc5df462643168770/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherConfigTest.java#L47-L50 <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: --> I used an open-source tool called [NonDex](https://github.com/TestingResearchIllinois/NonDex) to detect the flaky test. After checking in my changes, I executed the nondex tool on the particular test to confirm that the flakiness was indeed resolved. Error that was seen on Nondex: ``` [ERROR] Failures: [ERROR] orgpw.apache.druid.storage.s3.S3DataSegmentPusherConfigTest.testSerialization [ERROR] Run 1: S3DataSegmentPusherConfigTest.testSerialization:45 expected:<{"[bucket":"bucket1","baseKey":"dataSource1","disableAcl":false],"maxListingLength":...> but was:<{"[disableAcl":false,"baseKey":"dataSource1","bucket":"bucket1"],"maxListingLength":...> [ERROR] Run 2: S3DataSegmentPusherConfigTest.testSerialization:45 expected:<{"[bucket":"bucket1","baseKey":"dataSource1","disableAcl":false],"maxListingLength":...> but was:<{"[disableAcl":false,"baseKey":"dataSource1","bucket":"bucket1"],"maxListingLength":...> [ERROR] Run 3: S3DataSegmentPusherConfigTest.testSerialization:45 expected:<{"[bucket":"bucket1","baseKey":"dataSource1","disableAcl":false],"maxListingLength":...> but was:<{"[disableAcl":false,"baseKey":"dataSource1","bucket":"bucket1"],"maxListingLength":...> [ERROR] Run 4: S3DataSegmentPusherConfigTest.testSerialization:45 expected:<{"[bucket":"bucket1","baseKey":"dataSource1","disableAcl":false],"maxListingLength":...> but was:<{"[disableAcl":false,"baseKey":"dataSource1","bucket":"bucket1"],"maxListingLength":...> ``` Steps to verify the patch: 1. `git clone https://github.com/apache/druid.git`. 2. Inside the project directory, execute `mvn install -pl extensions-core/s3-extensions -am -DskipTests`. 3. Execute the test, `mvn -pl extensions-core/s3-extensions test -Dtest=S3DataSegmentPusherConfigTest#testSerialization`. 4. Nondex can be executed to verify the fix for flakiness `mvn -pl extensions-core/s3-extensions edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=S3DataSegmentPusherConfigTest#testSerialization`. <!-- In each section, please describe design decisions made, including: - Choice of algorithms - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources? - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns) - Method organization and design (how the logic is split between methods, parameters and return types) - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics) --> <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. --> <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. --> <!-- Some of the aspects mentioned above may be omitted for simple and small changes. --> #### Release note <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. If your change doesn't have end-user impact, you can skip this section. For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes). --> Addressed flakiness that was observed in `testSerialization`. <hr> <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. --> This PR has: - [x] been self-reviewed. - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.) - [x] added documentation for new or modified features or behaviors. - [x] a release note entry in the PR description. - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links. - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md) - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader. - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met. - [ ] added integration tests. - [ ] been tested in a test Druid cluster. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
