-
Notifications
You must be signed in to change notification settings - Fork 275
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
Fix flaky test testExternalUrl using LinkedHashMap #2719
Fix flaky test testExternalUrl using LinkedHashMap #2719
Conversation
Thanks @KiruthikaJanakiraman! |
Hi, If the test is meant to be order insensitive, an alternative fix could be to assert for both possible orders, i.e., If you prefer the latter fix, kindly let me know and I could update the PR. |
You are right, the test in is current form is indeed order sensitive. |
I think the test should be changed to account for any order. |
That makes sense. If the test is meant to be order insensitive, I would suggest 2 alternative fixes:
Could you kindly let me know the preferred fix? |
47cf0f4
to
409d1c5
Compare
I have updated the commit with a custom function that compares two urls two urls irrespective of the order of the query parameters. Could you kindly review the same? |
uPortal-webapp/src/test/java/org/apereo/portal/redirect/PortletRedirectionControllerTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KiruthikaJanakiraman!
@KiruthikaJanakiraman could you run |
Checklist
Description of change
This PR aims to fix the flaky test: org.apereo.portal.redirect.PortletRedirectionControllerTest.testExternalUrl similar to a previously raised PR #2718.
I found and confirmed the flaky behaviour of the tests using an open-source research tool NonDex, which shuffles implementations of nondeterminism operations.
Problem
The test case org.apereo.portal.redirect.PortletRedirectionControllerTest.testExternalUrl fails due to the below assertion.
uPortal/uPortal-webapp/src/test/java/org/apereo/portal/redirect/PortletRedirectionControllerTest.java
Lines 57 to 60 in 989ba28
This is because
additionalParameters
inurl
is a HashMap which does not preserve the order of the items causing the order ofaction
andlist
to vary.uPortal/uPortal-webapp/src/test/java/org/apereo/portal/redirect/PortletRedirectionControllerTest.java
Line 48 in 989ba28
Solution
This PR fixes the test by using a custom function
compareQueryParameters
to compare two urls irrespective of the order of the query parameters.Steps to reproduce
The following command can be used to reproduce the assertion errors and verify the fix.
Integrate NonDex:
Add the following snippet to the top of the build.gradle in $PROJ_DIR:
Append to build.gradle in $PROJ_DIR:
Execute Test with Gradle:
Run NonDex:
Test Environment:
Please let me know if you have any concerns or questions.