mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 10:31:59 +00:00
logtail/filch: limit buffer file size to 50MB
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -57,6 +57,39 @@ func (f *filchTest) close(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDropOldLogs(t *testing.T) {
|
||||
const line1 = "123456789" // 10 bytes (9+newline)
|
||||
tests := []struct {
|
||||
write, read int
|
||||
}{
|
||||
{10, 10},
|
||||
{100, 100},
|
||||
{200, 200},
|
||||
{250, 150},
|
||||
{500, 200},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(fmt.Sprintf("w%d-r%d", tc.write, tc.read), func(t *testing.T) {
|
||||
filePrefix := t.TempDir()
|
||||
f := newFilchTest(t, filePrefix, Options{ReplaceStderr: false, MaxFileSize: 1000})
|
||||
defer f.close(t)
|
||||
// Make filch rotate the logs 3 times
|
||||
for i := 0; i < tc.write; i++ {
|
||||
f.write(t, line1)
|
||||
}
|
||||
// We should only be able to read the last 150 lines
|
||||
for i := 0; i < tc.read; i++ {
|
||||
f.read(t, line1)
|
||||
if t.Failed() {
|
||||
t.Logf("could only read %d lines", i)
|
||||
break
|
||||
}
|
||||
}
|
||||
f.readEOF(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueue(t *testing.T) {
|
||||
filePrefix := t.TempDir()
|
||||
f := newFilchTest(t, filePrefix, Options{ReplaceStderr: false})
|
||||
|
||||
Reference in New Issue
Block a user