-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathfile_ingestor_test.go
54 lines (46 loc) · 1.12 KB
/
file_ingestor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package workers
import (
"testing"
"github.com/dmachard/go-dnscollector/dnsutils"
"github.com/dmachard/go-dnscollector/pkgconfig"
"github.com/dmachard/go-logger"
)
func Test_FileIngestor(t *testing.T) {
tests := []struct {
name string
watchMode string
watchDir string
}{
{
name: "Pcap",
watchMode: "pcap",
watchDir: "./../tests/testsdata/pcap/",
},
{
name: "Dnstap",
watchMode: "dnstap",
watchDir: "./../tests/testsdata/dnstap/",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := GetWorkerForTest(pkgconfig.DefaultBufferSize)
config := pkgconfig.GetDefaultConfig()
// watch tests data folder
config.Collectors.FileIngestor.WatchMode = tt.watchMode
config.Collectors.FileIngestor.WatchDir = tt.watchDir
// init collector
c := NewFileIngestor([]Worker{g}, config, logger.New(false), "test")
go c.StartCollect()
// waiting message in channel
for {
// read dns message from channel
msg := <-g.GetInputChannel()
// check qname
if msg.DNSTap.Operation == dnsutils.DNSTapClientQuery {
break
}
}
})
}
}