MCPcopy
hub / github.com/google/mtail / TestBasicTail

Function TestBasicTail

internal/mtail/basic_tail_integration_test.go:17–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func 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
55func TestNewLogDoesNotMatchIsIgnored(t *testing.T) {
56 testutil.SkipIfShort(t)

Callers

nothing calls this directly

Calls 11

SkipIfShortFunction · 0.92
SetFlagFunction · 0.92
TestTempDirFunction · 0.92
TestStartServerFunction · 0.92
LogPathPatternsFunction · 0.92
ProgramPathTypeAlias · 0.92
TestOpenFileFunction · 0.92
WriteStringFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected