Fixing Flaky Test. Changes in CachingDateFormatter.java file. #742
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 zone in the DateTimeFormatter.
ch.qos.logback.core.rolling.helper.SizeAndTimeBasedArchiveRemoverTest
Test Overview:
The test above uses the SizeAndTimeBasedArchiveRemover object, which uses the descendingSort method, this method makes an internal call to the Format method in the CachingDateFormatter.java file where the problem lies.
You can reproduce the issue by running the following commands:
Within the format class, the zone is initially set to null. However, when I ran the rest on the nondex tool software it introduced variability in the test seed, causing the zone to deviate from UTC. Consequently, the date value shifts from "smoke-1970-01-01-1.gz" to "smoke-1969-12-31-(\d+).gz," resulting in test failures.
This flakiness was identified by the nondex tool created by the researchers of UIUC.
Fix:
To fix the issue I decided to explicitly set the zone to UTC to DateTimeFormatter in the format() method in the CachingDateFormatter.java file.
https://github.com/njain2208/logback/blob/5cc0d2faa62443b14272485822aace48a765b824/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java#L71-L78
Failures:
Nondex error: