diff --git a/pkg/event_processor/processor_test.go b/pkg/event_processor/processor_test.go index de69604c1..5e547c7c2 100644 --- a/pkg/event_processor/processor_test.go +++ b/pkg/event_processor/processor_test.go @@ -1,6 +1,7 @@ package event_processor import ( + "bytes" "encoding/json" "fmt" "log" @@ -30,6 +31,8 @@ type SSLDataEventTmp struct { func TestEventProcessor_Serve(t *testing.T) { logger := log.Default() + var buf bytes.Buffer + logger.SetOutput(&buf) /* f, e := os.Create("./output.log") if e != nil { @@ -68,12 +71,23 @@ func TestEventProcessor_Serve(t *testing.T) { } tick := time.NewTicker(time.Second * 3) - select { - case <-tick.C: - } + <-tick.C + err = ep.Close() + lines = strings.Split(buf.String(), "\n") + ok := true + for _, line := range lines { + if strings.Contains(strings.ToLower(line), "dump") { + t.Log(line) + ok = false + } + } if err != nil { t.Fatalf("close error: %s", err.Error()) } + if !ok { + t.Fatalf("some errors occurred") + } + t.Log(buf.String()) t.Log("done") } diff --git a/pkg/event_processor/testdata/952253698000000.bin b/pkg/event_processor/testdata/952253698000000.bin new file mode 100644 index 000000000..a470d3a06 --- /dev/null +++ b/pkg/event_processor/testdata/952253698000000.bin @@ -0,0 +1,7 @@ +GET / HTTP/1.1 +Host: www.baidu.com +User-Agent: Wget/1.21.2 +Accept: */* +Accept-Encoding: gzip +Connection: Keep-Alive + diff --git a/pkg/event_processor/testdata/952253698001000.bin b/pkg/event_processor/testdata/952253698001000.bin new file mode 100644 index 000000000..17a1fc650 --- /dev/null +++ b/pkg/event_processor/testdata/952253698001000.bin @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Content-Encoding: gzip +Content-Length: 1145 +Server: bfe +Date: Fri, 01 Mar 2024 08:24:27 GMT +Content-Type: text/html;charset=UTF-8 + diff --git a/pkg/event_processor/testdata/952253698002000.bin b/pkg/event_processor/testdata/952253698002000.bin new file mode 100644 index 000000000..67748e329 Binary files /dev/null and b/pkg/event_processor/testdata/952253698002000.bin differ diff --git a/pkg/event_processor/testdata/952282712204824.bin b/pkg/event_processor/testdata/952282712204824.bin index 541c9f58d..4f617d461 100755 --- a/pkg/event_processor/testdata/952282712204824.bin +++ b/pkg/event_processor/testdata/952282712204824.bin @@ -2,7 +2,7 @@ HTTP/1.1 200 OK Server: nginx/1.14.0 (Ubuntu) Date: Wed, 29 Jun 2022 09:44:35 GMT Content-Type: text/html; charset=UTF-8 -Content-Length: 74332 +Content-Length: 20124 Connection: keep-alive Vary: Accept-Encoding, Cookie Cache-Control: max-age=3, must-revalidate diff --git a/pkg/event_processor/testdata/all.json b/pkg/event_processor/testdata/all.json index 7245fa2c5..affe41487 100755 --- a/pkg/event_processor/testdata/all.json +++ b/pkg/event_processor/testdata/all.json @@ -1,6 +1,9 @@ {"DataType":1,"Timestamp":952253291192473,"Pid":469929,"Tid":469929,"DataLen":240,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} {"DataType":0,"Timestamp":952253597324253,"Pid":469929,"Tid":469929,"DataLen":308,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} {"DataType":0,"Timestamp":952253597628796,"Pid":469929,"Tid":469929,"DataLen":191,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} +{"DataType":1,"Timestamp":952253698000000,"Pid":469930,"Tid":469930,"DataLen":124,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} +{"DataType":0,"Timestamp":952253698001000,"Pid":469930,"Tid":469930,"DataLen":154,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} +{"DataType":0,"Timestamp":952253698002000,"Pid":469930,"Tid":469930,"DataLen":1145,"Comm":[119,103,101,116,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":3,"Version":771} {"DataType":1,"Timestamp":952282673103459,"Pid":469953,"Tid":469953,"DataLen":77,"Comm":[99,117,114,108,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":5,"Version":771} {"DataType":0,"Timestamp":952282712204824,"Pid":469953,"Tid":469953,"DataLen":4096,"Comm":[99,117,114,108,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":5,"Version":771} {"DataType":0,"Timestamp":952282715334491,"Pid":469953,"Tid":469953,"DataLen":4096,"Comm":[99,117,114,108,0,0,0,0,0,0,0,0,0,0,0,0],"Fd":5,"Version":771}