MCPcopy Create free account
hub / github.com/hpcloud/tail / TestRateLimiting

Function TestRateLimiting

tail_test.go:233–259  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

231}
232
233func TestRateLimiting(t *testing.T) {
234 tailTest := NewTailTest("rate-limiting", t)
235 tailTest.CreateFile("test.txt", "hello\nworld\nagain\nextra\n")
236 config := Config{
237 Follow: true,
238 RateLimiter: ratelimiter.NewLeakyBucket(2, time.Second)}
239 leakybucketFull := "Too much log activity; waiting a second before resuming tailing"
240 tail := tailTest.StartTail("test.txt", config)
241
242 // TODO: also verify that tail resumes after the cooloff period.
243 go tailTest.VerifyTailOutput(tail, []string{
244 "hello", "world", "again",
245 leakybucketFull,
246 "more", "data",
247 leakybucketFull}, false)
248
249 // Add more data only after reasonable delay.
250 <-time.After(1200 * time.Millisecond)
251 tailTest.AppendFile("test.txt", "more\ndata\n")
252
253 // Delete after a reasonable delay, to give tail sufficient time
254 // to read all lines.
255 <-time.After(100 * time.Millisecond)
256 tailTest.RemoveFile("test.txt")
257
258 tailTest.Cleanup(tail, true)
259}
260
261func TestTell(t *testing.T) {
262 tailTest := NewTailTest("tell-position", t)

Callers

nothing calls this directly

Calls 7

CreateFileMethod · 0.95
StartTailMethod · 0.95
VerifyTailOutputMethod · 0.95
AppendFileMethod · 0.95
RemoveFileMethod · 0.95
CleanupMethod · 0.95
NewTailTestFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…