Add unit tests for AMQP dissector (#806)

* Add unit tests for AMQP dissector

* Always use UTC as the timezone in the timestamps

* Remove the dead code

* Remove more dead code

* Fix `dissector.Analyze` call

Co-authored-by: gadotroee <55343099+gadotroee@users.noreply.github.com>
This commit is contained in:
M. Mert Yıldıran
2022-02-16 12:07:37 +03:00
committed by GitHub
parent 83722f1a02
commit e8d2b7eb3c
11 changed files with 358 additions and 1932 deletions

View File

@@ -8,6 +8,7 @@ import (
"io"
"log"
"strconv"
"time"
"github.com/up9inc/mizu/tap/api"
)
@@ -85,7 +86,7 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
frame, err := r.ReadFrame()
if err == io.EOF {
// We must read until we see an EOF... very important!
return errors.New("AMQP EOF")
return nil
}
switch f := frame.(type) {
@@ -96,6 +97,12 @@ func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, co
// start content state
header = f
remaining = int(header.Size)
// Workaround for `Time.MarshalJSON: year outside of range [0,9999]` error
if header.Properties.Timestamp.Year() > 9999 {
header.Properties.Timestamp = time.Time{}.UTC()
}
switch lastMethodFrameMessage.(type) {
case *BasicPublish:
eventBasicPublish.Properties = header.Properties