Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Flaky Test: CustomDataParametersTest #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deekshacheruku
Copy link

@deekshacheruku deekshacheruku commented Nov 2, 2023

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

@facebook-github-bot
Copy link

Hi @deekshacheruku!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@deekshacheruku deekshacheruku force-pushed the fix_flaky_CustomDataParametersTest branch from de7e9aa to 064dd57 Compare November 20, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants