FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-84649: Fix unstable test_rollover_at_midnight by serhiy-storchaka · Pull Request #154463 · python/cpython · GitHub

Repository navigation

gh-84649: Fix unstable test_rollover_at_midnight - #154463

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:fix-test-rollover-tunneling
Jul 22, 2026
Merged

serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:fix-test-rollover-tunneling

Conversation

serhiy-storchaka commented Jul 22, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

The test was still unstable on Windows after GH-151813.

TimedRotatingFileHandler bases the rollover time on int(min(creation_time, modification_time)). The test unlinked the file created in setUp() and recreated it under the same name, and on Windows NTFS file tunneling restores the original creation time in that case. The rollover time was therefore earlier than the current time, and the first records were unexpectedly rolled over. This pre-created the rotated file, so the real rollover hit the if os.path.exists(dfn): return check in doRollover() and the following records were not rolled over.

Creating the log file in a fresh directory under a name which has never been used avoids tunneling.

On a Windows 11 VM the current test fails 6 times out of 40 runs, the fixed test 0 out of 120.

The test now also checks that the rollover does not happen before the specified time.

🤖 Generated with Claude Code

Create the log file in a fresh directory under a name which has never
been used.  On Windows, NTFS file tunneling restored the original
creation time of a file recreated with the same name, which made the
rollover time earlier than the current time and caused an unwanted
rollover.

Also check that the rollover does not happen before the specified time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka requested a review from vsajip as a code owner July 22, 2026 10:04
bedevere-app Bot added the tests Tests in the Lib/test dir label Jul 22, 2026
serhiy-storchaka enabled auto-merge (squash) July 22, 2026 10:09
serhiy-storchaka merged commit 7dc920a into python:main Jul 22, 2026
53 checks passed
serhiy-storchaka deleted the fix-test-rollover-tunneling branch July 22, 2026 12:52

Copy link
Copy Markdown
Member

The test unlinked the file created in setUp() and recreated it under the same name, and on Windows NTFS file tunneling restores the original creation time in that case.

Oh wow, that's a surprising issue! Using a temporary directory sounds like a reasonable fix for this issue.

Thanks for fixing it, it was failing randomly on CIs for a few weeks.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL