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? |
ChristianMurphy
left a comment
There was a problem hiding this comment.
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
additionalParametersinurlis a HashMap which does not preserve the order of the items causing the order ofactionandlistto 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
compareQueryParametersto 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.