MCPcopy Create free account
hub / github.com/Edgio/vflow / TestSFHeaderDecode

Function TestSFHeaderDecode

sflow/decoder_test.go:105–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103 0xd3, 0x16, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x15}
104
105func TestSFHeaderDecode(t *testing.T) {
106 filter := []uint32{DataCounterSample}
107 reader := bytes.NewReader(TestsFlowRawPacket)
108 d := NewSFDecoder(reader, filter)
109 datagram, err := d.sfHeaderDecode()
110
111 if err != nil {
112 t.Error("unexpected error", err)
113 }
114
115 if datagram.Version != 5 {
116 t.Error("expected version: 5, got",
117 datagram.Version)
118 }
119
120 if datagram.SysUpTime != 370955401 {
121 t.Error("expected SysUpTime: 370955401, got",
122 datagram.SysUpTime)
123 }
124
125 if datagram.SamplesNo != 5 {
126 t.Error("expected SamplesNo: 5, got",
127 datagram.SamplesNo)
128 }
129
130 if datagram.SequenceNo != 36195 {
131 t.Error("expected SequenceNo: 36195, got",
132 datagram.SequenceNo)
133 }
134
135 if datagram.IPVersion != 1 {
136 t.Error("expected IPVersion: 1, got",
137 datagram.IPVersion)
138 }
139
140 if datagram.IPAddress.String() != "24.3.64.33" {
141 t.Error("expected agent ip address: 24.3.64.33, got",
142 datagram.IPAddress.String())
143 }
144}
145
146func TestGetSampleInfo(t *testing.T) {
147 filter := []uint32{DataCounterSample}

Callers

nothing calls this directly

Calls 3

sfHeaderDecodeMethod · 0.95
NewSFDecoderFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected