remove sleep from tests (#2555)
This commit is contained in:
committed by
Daniel Nelson
parent
616b66f5cb
commit
1402c158b7
@@ -3,6 +3,7 @@ package tail
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -30,11 +31,9 @@ func TestTailFromBeginning(t *testing.T) {
|
||||
|
||||
acc := testutil.Accumulator{}
|
||||
require.NoError(t, tt.Start(&acc))
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
require.NoError(t, tt.Gather(&acc))
|
||||
// arbitrary sleep to wait for message to show up
|
||||
time.Sleep(time.Millisecond * 150)
|
||||
|
||||
acc.Wait(1)
|
||||
acc.AssertContainsTaggedFields(t, "cpu",
|
||||
map[string]interface{}{
|
||||
"usage_idle": float64(100),
|
||||
@@ -60,13 +59,19 @@ func TestTailFromEnd(t *testing.T) {
|
||||
|
||||
acc := testutil.Accumulator{}
|
||||
require.NoError(t, tt.Start(&acc))
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
time.Sleep(time.Millisecond * 200) //TODO remove once https://github.com/hpcloud/tail/pull/114 is merged & added to Godeps
|
||||
for _, tailer := range tt.tailers {
|
||||
for n, err := tailer.Tell(); err == nil && n == 0; n, err = tailer.Tell() {
|
||||
// wait for tailer to jump to end
|
||||
runtime.Gosched()
|
||||
}
|
||||
}
|
||||
|
||||
_, err = tmpfile.WriteString("cpu,othertag=foo usage_idle=100\n")
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, tt.Gather(&acc))
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
|
||||
acc.Wait(1)
|
||||
acc.AssertContainsTaggedFields(t, "cpu",
|
||||
map[string]interface{}{
|
||||
"usage_idle": float64(100),
|
||||
@@ -96,7 +101,7 @@ func TestTailBadLine(t *testing.T) {
|
||||
_, err = tmpfile.WriteString("cpu mytag= foo usage_idle= 100\n")
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, tt.Gather(&acc))
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
|
||||
assert.Len(t, acc.Metrics, 0)
|
||||
acc.WaitError(1)
|
||||
assert.Contains(t, acc.Errors[0].Error(), "E! Malformed log line")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user