diff --git a/README.md b/README.md index 586d4882..71ad2fa0 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@
- + - +
diff --git a/tests/testsdata/dnstap/dnstap.fstrm b/tests/testsdata/dnstap/dnstap.fstrm new file mode 100644 index 00000000..4e848421 Binary files /dev/null and b/tests/testsdata/dnstap/dnstap.fstrm differ diff --git a/workers/file_ingestor.go b/workers/file_ingestor.go index 0db8b2dc..d524be6c 100644 --- a/workers/file_ingestor.go +++ b/workers/file_ingestor.go @@ -318,7 +318,7 @@ func (w *FileIngestor) StartCollect() { dnstapProcessor := NewDNSTapProcessor(0, "", w.GetConfig(), w.GetLogger(), w.GetName(), w.GetConfig().Collectors.FileIngestor.ChannelBufferSize) dnstapProcessor.SetDefaultRoutes(w.GetDefaultRoutes()) dnstapProcessor.SetDefaultDropped(w.GetDroppedRoutes()) - go dnsProcessor.StartCollect() + go dnstapProcessor.StartCollect() w.dnstapProcessor = dnstapProcessor w.dnsProcessor = dnsProcessor diff --git a/workers/file_ingestor_test.go b/workers/file_ingestor_test.go index ed9972da..6ba7dcc1 100644 --- a/workers/file_ingestor_test.go +++ b/workers/file_ingestor_test.go @@ -8,25 +8,47 @@ import ( "github.com/dmachard/go-logger" ) -func Test_FileIngestor_Pcap(t *testing.T) { - g := GetWorkerForTest(pkgconfig.DefaultBufferSize) - config := pkgconfig.GetDefaultConfig() - - // watch tests data folder - config.Collectors.FileIngestor.WatchDir = "./../tests/testsdata/pcap/" - - // 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 - } +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 + } + } + }) } }