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.
PR Overview:
This PR fixes the flaky/non-deterministic behavior of the following test because it assumes the ordering.
com.zavtech.morpheus.array.ArrayMappedTests#testZonedDateTime
com.zavtech.morpheus.array.ArrayBuilderTests#testWithLocalDateTimes
com.zavtech.morpheus.array.ArrayBuilderTests#testWithZonedDateTimes
com.zavtech.morpheus.array.ArraysBasicTests#testFill
com.zavtech.morpheus.array.ArraysBasicTests#testFirstAndLast
com.zavtech.morpheus.array.ArraysBasicTests#testLocalDateTimeArray
com.zavtech.morpheus.array.ArraysBasicTests#testZonedDateTimeArray
Test Overview:
In the above tests, the error originates from the implementation of the underlying map, specifically within the MappedArrayOfZonedDateTimes class. Within this class, the utilization of Instant.ofEpochMilli(value) is employed to handle milliseconds and nanoseconds. However, it is important to note that this method is flaky in nature and sometimes it accommodates both milliseconds and nanoseconds, while sometimes discarding the nanoseconds information. Consequently, this discrepancy in handling leads to differences in values, exemplified by instances such as [2023-11-20T17:01:38.907444-06:00[America/Chicago]] and [2023-11-20T17:01:38.907-06:00[America/Chicago]].
This flakiness was identified by the nondex tool created by the researchers of UIUC.
You can reproduce the issue by running the following commands (and substituting the test with the test you want to check):
Fix:
In order to fix this test error I have truncated the current ZonedDateTime to milliseconds precision so that the test can pass.
https://github.com/njain2208/morpheus-core/blob/bc7acf1bf6b020a69f1106e38646d018d1b6bb99/src/test/java/com/zavtech/morpheus/array/ArrayMappedTests.java#L95-L98