Page MenuHomeFreeBSD

tail: add test for tail -F against newsyslog rotation
AcceptedPublic

Authored by allanjude on Jan 8 2022, 5:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 11 2024, 11:07 AM
Unknown Object (File)
Apr 11 2024, 11:07 AM
Unknown Object (File)
Apr 11 2024, 11:07 AM
Unknown Object (File)
Apr 11 2024, 11:05 AM
Unknown Object (File)
Apr 11 2024, 11:05 AM
Unknown Object (File)
Apr 11 2024, 10:20 AM
Unknown Object (File)
Jan 12 2024, 9:11 AM
Unknown Object (File)
Dec 20 2023, 6:08 AM
Subscribers

Details

Summary

Newsyslog hardlinks the original file to the new name, then renames a
new file into place, so that no log entries can be missed.

The broken tail -F on 13.0 does not fail the current follow_rename test
but does fail this new follow_rotate test.

Reported by: ScaleEngine Inc.
Sponsored by: Klara Inc.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46010
Build 42898: arc lint + arc unit

Event Timeline

Fix commit message, broken tail -F is on 13.0 not 12.2

One possible optimization, but overall LGTM

usr.bin/tail/tests/tail_test.sh
408

What do you think about something like this, to avoid unnecessary dead time:

for i in `jot 20`; do
        if [ $(stat -f%z outfile) -ge 10 ]; then
                break
        fi
        sleep 0.1
done

Don't sleep longer than required

allanjude added inline comments.
usr.bin/tail/tests/tail_test.sh
408

Fixed here, and where I copied it from (forward_rename test)

This revision is now accepted and ready to land.Jan 9 2022, 3:07 AM
usr.bin/tail/tests/tail_test.sh
351

LGTM
Would it be worth replacing the constant 10 with $(stat -f%z expectfile) (and -ge with -eq) to ensure that the check is coupled with what's expected, in case at some point in the future somebody modified the test without changing the constant?

usr.bin/tail/tests/tail_test.sh
351

If we're going to do that we'd probably want expectsize=$(stat -f%z expectfile) rather than execing the expectfile stat each time through the loop.

I think -ge is preferable though, if the outfile is larger then there is no value in waiting the full 2s to report the failure.

allanjude marked an inline comment as done.

Update

This revision now requires review to proceed.Jun 16 2022, 8:01 PM
This revision is now accepted and ready to land.Jul 9 2022, 12:03 PM