Fixed Flaky Test: CustomDataParametersTest#440
Fixed Flaky Test: CustomDataParametersTest#440deekshacheruku wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @deekshacheruku! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
de7e9aa to
064dd57
Compare
Fixed the flaky test CustomDataParametersTest inside src/test/java/com/facebook/ads/ServerSideTest class.
Root Cause
The test CustomDataParametersTest has been reported as flaky when ran with the NonDex tool. The test failed because it is trying to check if it contains a string or not which is actually nothing but a String Values of List, Hash Map. The HashMap/List in Java is implemented in such a way that it does not store the order in which the keys and/or values are inserted. As a result, when the expected string (which is hard-coded) is compared with the actual one, it failed.
Fix
The simplest fix is to check if all the patterns of expected String in actual String serialisedPayload. Since there were only two possible order changes, it was easy to hardcode the expected patterns and fix the flakiness.
How this has been tested?
Java: openjdk version "11.0.20.1"
Maven: Apache Maven 3.6.3
Module build: Successful
Command used: mvn install -am -DskipTests
Regular test: Successful
Command used: mvn test -Dtest=com.facebook.ads.ServerSideTest#CustomDataParametersTest
NonDex test: Failed
Command used:
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.facebook.ads.ServerSideTest#CustomDataParametersTest
NonDex test passed after the fix.
Let me know if you have any further questions