Fix racy tail from beginning test
This commit is contained in:
parent
c991b579d2
commit
30dbfd9af8
|
@ -17,6 +17,8 @@ func TestTailFromBeginning(t *testing.T) {
|
||||||
tmpfile, err := ioutil.TempFile("", "")
|
tmpfile, err := ioutil.TempFile("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.Remove(tmpfile.Name())
|
defer os.Remove(tmpfile.Name())
|
||||||
|
_, err = tmpfile.WriteString("cpu,mytag=foo usage_idle=100\n")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
tt := NewTail()
|
tt := NewTail()
|
||||||
tt.FromBeginning = true
|
tt.FromBeginning = true
|
||||||
|
@ -28,12 +30,10 @@ func TestTailFromBeginning(t *testing.T) {
|
||||||
|
|
||||||
acc := testutil.Accumulator{}
|
acc := testutil.Accumulator{}
|
||||||
require.NoError(t, tt.Start(&acc))
|
require.NoError(t, tt.Start(&acc))
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
_, err = tmpfile.WriteString("cpu,mytag=foo usage_idle=100\n")
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NoError(t, tt.Gather(&acc))
|
require.NoError(t, tt.Gather(&acc))
|
||||||
// arbitrary sleep to wait for message to show up
|
// arbitrary sleep to wait for message to show up
|
||||||
time.Sleep(time.Millisecond * 250)
|
time.Sleep(time.Millisecond * 150)
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "cpu",
|
acc.AssertContainsTaggedFields(t, "cpu",
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|
Loading…
Reference in New Issue