(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestBasicTail(t *testing.T) { |
| 18 | testutil.SkipIfShort(t) |
| 19 | if testing.Verbose() { |
| 20 | testutil.SetFlag(t, "vmodule", "tail=2,filestream=2") |
| 21 | } |
| 22 | logDir := testutil.TestTempDir(t) |
| 23 | |
| 24 | m, stopM := mtail.TestStartServer(t, 1, 1, mtail.LogPathPatterns(logDir+"/*"), mtail.ProgramPath("../../examples/linecount.mtail")) |
| 25 | defer stopM() |
| 26 | |
| 27 | logFile := filepath.Join(logDir, "log") |
| 28 | |
| 29 | lineCountCheck := m.ExpectMapExpvarDeltaWithDeadline("log_lines_total", logFile, 3) |
| 30 | logCountCheck := m.ExpectExpvarDeltaWithDeadline("log_count", 1) |
| 31 | |
| 32 | f := testutil.TestOpenFile(t, logFile) |
| 33 | defer f.Close() |
| 34 | m.AwakenPatternPollers(1, 1) // Find `logFile` |
| 35 | m.AwakenLogStreams(1, 1) // Force a sync to EOF |
| 36 | |
| 37 | for i := 1; i <= 3; i++ { |
| 38 | testutil.WriteString(t, f, fmt.Sprintf("%d\n", i)) |
| 39 | } |
| 40 | m.AwakenLogStreams(1, 1) // Expect to read 3 lines here. |
| 41 | |
| 42 | var wg sync.WaitGroup |
| 43 | wg.Add(2) |
| 44 | go func() { |
| 45 | defer wg.Done() |
| 46 | lineCountCheck() |
| 47 | }() |
| 48 | go func() { |
| 49 | defer wg.Done() |
| 50 | logCountCheck() |
| 51 | }() |
| 52 | wg.Wait() |
| 53 | } |
| 54 | |
| 55 | func TestNewLogDoesNotMatchIsIgnored(t *testing.T) { |
| 56 | testutil.SkipIfShort(t) |
nothing calls this directly
no test coverage detected