Fix flakiness due to indeterminate HashMap orderings in unit test #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Several (11 in total) flaky tests are found using Nondex when running commands
mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex
underscimono-client
directory. All test flakinesses are due to the functionResourcePageQuery.apply()
, which uses the default iterator of aHashMap.entrySet()
when iterating through entries of the HashMapqueryParams
. However, an entry set for a normal HashMap is an unordered set, so it does not preserve element orders. As a result, the query parameters may not be retrieved in insertion order. This can lead to unexpected resultant URL, failure to get aPagedByIdentitySearchResult
from aSCIMResponse
, etc.For example, consider
testCreateCustomIdentityFilter()
inResourcePageQueryTest.java
, the StringresultRequestPath
can behttp://localhost:7070/idds/scim/v2/Users?startId=00000000-0000-1000-9000-000000000000&count=50
in one run and thenhttp://localhost:7070/idds/scim/v2/Users?count=50&startId=00000000-0000-1000-9000-000000000000
in another.For another example,
testReadGroupsWithIndexPagedResponse()
inGroupRequestTest.java
may occasionally throw anjavax.ws.rs.WebApplicationException
after executing line 214 for the same reason.Reasons for Fixing
These unit tests may fail nondeterministically when been run in a different OS or when using older / future versions of Java.
Fixes
Using
LinkedHashMap
instead ofHashMap
to ensure determinate iteration order.