run TestReOpen with both poll = true and false
this catches a bug with log rotation when using polling file watcher.
This commit is contained in:
parent
bf1dd37666
commit
e895d422e1
16
tail_test.go
16
tail_test.go
|
@ -80,10 +80,12 @@ func TestLocationEnd(_t *testing.T) {
|
||||||
tail.Stop()
|
tail.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReOpen(_t *testing.T) {
|
func _TestReOpen(_t *testing.T, poll bool) {
|
||||||
t := NewTailTest("reopen", _t)
|
t := NewTailTest("reopen", _t)
|
||||||
t.CreateFile("test.txt", "hello\nworld\n")
|
t.CreateFile("test.txt", "hello\nworld\n")
|
||||||
tail := t.StartTail("test.txt", Config{Follow: true, ReOpen: true, Location: -1})
|
tail := t.StartTail(
|
||||||
|
"test.txt",
|
||||||
|
Config{Follow: true, ReOpen: true, Poll: poll, Location: -1})
|
||||||
go t.VerifyTailOutput(tail, []string{"hello", "world", "more", "data", "endofworld"})
|
go t.VerifyTailOutput(tail, []string{"hello", "world", "more", "data", "endofworld"})
|
||||||
|
|
||||||
// deletion must trigger reopen
|
// deletion must trigger reopen
|
||||||
|
@ -106,6 +108,16 @@ func TestReOpen(_t *testing.T) {
|
||||||
tail.Stop()
|
tail.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The use of polling file watcher could affect file rotation
|
||||||
|
// (detected via renames), so test these explicitly.
|
||||||
|
|
||||||
|
func TestReOpenWithPoll(_t *testing.T) {
|
||||||
|
_TestReOpen(_t, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReOpenWithoutPoll(_t *testing.T) {
|
||||||
|
_TestReOpen(_t, false)
|
||||||
|
}
|
||||||
|
|
||||||
// Test library
|
// Test library
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue