bryancall opened a new pull request, #13758:
URL: https://github.com/apache/trafficserver/pull/13758

   Adds `test_LogRolling`, a Catch2 test for automatic time-based log rolling, 
as suggested in review of #13749.
   
   With #13749, the AuTest harness turns log rolling off so that a test running 
across 00:00 UTC is not rolled under its own content checks. The rolling 
AuTests do not cover automatic rolling either: `log_retention` is skipped 
unconditionally and `sigusr2` rotates externally with rolling off. So nothing 
in a normal suite run exercised it.
   
   `LogObject::roll_files()` takes the current time as an argument, so the test 
drives it across a synthetic midnight instead of waiting out a real rolling 
interval (at least 30 seconds, plus the boundary alignment). It checks that:
   
   - a daily log does not roll at 23:59:59, rolls at 00:00:01 into a `*.old` 
file named for the interval, and leaves a fresh empty file behind;
   - it does not roll a second time within the same boundary window, and rolls 
again at the next midnight;
   - `rolling_enabled` 0 never rolls, even at midnight;
   - a record written after a roll lands in the reopened file, while the one 
written before it stays in `*.old`.
   
   The times are built in local time, as `LogUtils::seconds_to_next_roll()` 
computes them, so the test holds in any time zone.
   
   ## Testing
   
   Built with the `ci-fedora-autest` preset in 
`ci.trafficserver.apache.org/ats/fedora:44`:
   
   - All 3 test cases (25 assertions) pass under `TZ=UTC`, 
`America/Los_Angeles` and `Asia/Kolkata`, and under `ctest -R test_LogRolling`. 
The whole run takes a few hundredths of a second.
   - Breaking the boundary check in `roll_files()` fails the test, and so does 
removing the guard against rolling twice within the same boundary window.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to