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

flaky fixes #107

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

Conversation

njain2208
Copy link

@njain2208 njain2208 commented Nov 29, 2023

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.

[ERROR] testZonedDateTimeArray(com.zavtech.morpheus.array.ArraysBasicTests)  Time elapsed: 0.007 s  <<< FAILURE!
java.lang.AssertionError: Values match at 0 expected [2023-11-20T22:56:38.784+01:00[Africa/Luanda]] but found [2023-11-20T22:56:38.784642+01:00[Africa/Luanda]]
[ERROR] testLocalDateTimeArray(com.zavtech.morpheus.array.ArraysBasicTests)  Time elapsed: 0.003 s  <<< FAILURE! java.lang.AssertionError: Values match at 0 expected [2023-11-20T16:34:37.544] but found [2023-11-20T16:34:37.544299]
[ERROR] testWithLocalDateTimes(com.zavtech.morpheus.array.ArrayBuilderTests)  Time elapsed: 0.002 s  <<< FAILURE!
java.lang.AssertionError: The values match at 0 expected [2023-11-20T17:01:38.886042] but found [2023-11-20T17:01:38.886]
[ERROR] testWithMixedTypes(com.zavtech.morpheus.array.ArrayBuilderTests)  Time elapsed: 0.001 s  <<< FAILURE!
java.lang.AssertionError: The values match at 0 expected [2023-11-20T17:01:38.907444-06:00[America/Chicago]] but found [2023-11-20T17:01:38.907-06:00[America/Chicago]]
[ERROR] testFirstAndLast(com.zavtech.morpheus.array.ArraysBasicTests)  Time elapsed: 0.003 s  <<< FAILURE!
java.lang.AssertionError: First value matches expected [2023-11-20T17:01:37.470669-06:00[America/Chicago]] but found [2023-11-20T17:01:37.470-06:00[America/Chicago]]
testFill(com.zavtech.morpheus.array.ArraysBasicTests)  Time elapsed: 0.004 s  <<< FAILURE!
java.lang.AssertionError: Values match at 0 expected [2023-11-20T17:01:37.202986-06:00[America/Chicago]] but found [2023-11-20T17:01:37.202-06:00[America/Chicago]]

You can reproduce the issue by running the following commands (and substituting the test with the test you want to check):

mvn install -pl . -am -DskipTests
mvn test -pl .  -Dtest=com.zavtech.morpheus.array.ArraysBasicTests#testFirstAndLast
mvn -pl . edu.illinois:index-maven-plugin:2.1.1:nondex -Dtest=com.zavtech.morpheus.array.ArraysBasicTests#testFirstAndLast

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant