python / python/cpython

test_rollover_based_on_st_birthtime_only fails on slow CI: rotated file is outside the fixed 5-second search window

Aberta
#157,161 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

tests
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

test_rollover_based_on_st_birthtime_only failed again on main, on the "Windows / Build and test (x64, tail-call)" CI job of 532b9dbd67 (2026-09-01): https://github.com/python/cpython/actions/runs/33523218872/job/99907492032

FAIL: test_rollover_based_on_st_birthtime_only (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_based_on_st_birthtime_only)
AssertionError: False is not true : No rotated files found, went back 5 seconds

This is the test that gh-150960 (fixed by GH-150954, which widened the search from 5 to 6 timestamps) was about. The diagnostics the test prints show why it still fails on a slow machine:

Test time: 2026-09-01 15-10-51
The only matching files are: ['test_logging-2-p8i89g4b.log', 'test_logging-2-p8i89g4b.log.2026-09-01_15-10-45']
Contents of test_logging-2-p8i89g4b.log:
2026-09-01 15:10:51,079 testing - new record supposedly in the new file after rollover
Contents of test_logging-2-p8i89g4b.log.2026-09-01_15-10-45:
2026-09-01 15:10:45,004 testing - initial
2026-09-01 15:10:47,105 testing - update before rollover to renew the st_mtime

The rollover happened and is correct. The rotated file is named after the start of the interval, which is the creation time of the log file (TimedRotatingFileHandler.__init__() computes rolloverAt from min(creation_time, modification_time), and doRollover() uses rolloverAt - interval for the suffix), so its suffix is 15-10-45. The test then looks for a rotated file with a timestamp between now and now - 5 s. now was 15:10:51, six seconds after the file was created, because the third add_record() came 3.97 s after the second one instead of about 2.1 s. So the file with suffix 15-10-45 was one second outside the window.

The test's timing (two time.sleep(2.1) calls plus three handler set-ups and emits) is nominally 4.2 s, and any slowdown of more than 0.8 s pushes the rotated file out of the fixed 5-second window. The window should be derived from the time the test actually took, since the suffix can never be older than the moment the log file was created.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows (CI)

Linked PRs
  • gh-157162

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com test_rollover_based_on_st_birthtime_only em test.test_logging.TimedRotatingFileHandlerTest e reproduza-o na configuração de CI do Windows. Revise como o teste procura arquivos rotacionados em relação ao horário registrado e verifique o comportamento de rollover existente. O trabalho estará concluído quando o teste continuar confiável se a configuração e as emissões demorarem mais do que o esperado, mas ainda detectar o arquivo rotacionado corretamente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
testing-qa
Tipo de issue
Bug
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Estagnada
Clareza
Claramente especificada
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.