Skip to content

Commit 3090df5

Browse files
committed
NETOBSERV-2009: stringify network event
1 parent 8f0aeda commit 3090df5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

cmd/flow_capture_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
140140
// set display without enrichment
141141
rows := getRows(allOptions, []string{pktDropFeature, dnsFeature, rttFeature, networkEventsDisplay}, noOptions, []string{})
142142
assert.Equal(t, 4, len(rows))
143-
assert.Equal(t, `End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Dropped Bytes Dropped Packets Drop State Drop Cause Drop Flags DNS Id DNS Latency DNS RCode DNS Error Flow RTT Network Events `, rows[0])
144-
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fdd Egress 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 16 31319 1ms NoError 0 10µs hello `, rows[1])
145-
assert.Equal(t, `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ---------- ---------- ---------- ----- ----- ----- ----- ----- --------------- `, rows[2])
143+
assert.Equal(t, `End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Dropped Bytes Dropped Packets Drop State Drop Cause Drop Flags DNS Id DNS Latency DNS RCode DNS Error Flow RTT Network Events `, rows[0])
144+
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fdd Egress 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 16 31319 1ms NoError 0 10µs Allowed by default allow from local node policy, direction Ingress `, rows[1])
145+
assert.Equal(t, `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ---------- ---------- ---------- ----- ----- ----- ----- ----- --------------- `, rows[2])
146146
assert.Empty(t, rows[3])
147147

148148
// set display to standard
@@ -184,8 +184,8 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
184184
// set display to NetworkEvents
185185
rows = getRows("Network events", []string{networkEventsDisplay}, noOptions, []string{})
186186
assert.Equal(t, 4, len(rows))
187-
assert.Equal(t, `End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Network Events `, rows[0])
188-
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fdd Egress hello `, rows[1])
189-
assert.Equal(t, `--------------- ---------- ---------- ---------- ---------- ---------- ---------- --------------- `, rows[2])
187+
assert.Equal(t, `End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Network Events `, rows[0])
188+
assert.Equal(t, `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fdd Egress Allowed by default allow from local node policy, direction Ingress `, rows[1])
189+
assert.Equal(t, `--------------- ---------- ---------- ---------- ---------- ---------- ---------- --------------- `, rows[2])
190190
assert.Empty(t, rows[3])
191191
}

cmd/map_format.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/jpillora/sizestr"
1111
"github.com/netobserv/flowlogs-pipeline/pkg/config"
12+
ovnutils "github.com/netobserv/netobserv-ebpf-agent/pkg/utils"
1213
)
1314

1415
const (
@@ -512,6 +513,9 @@ func ToTableRow(genericMap config.GenericMap, colIDs []string) []interface{} {
512513
row = append(row, toDuration(genericMap, fieldName, time.Millisecond))
513514
case "TimeFlowRttMs":
514515
row = append(row, toDuration(genericMap, fieldName, time.Nanosecond))
516+
case "NetworkEvents":
517+
events := ovnutils.NetworkEventsToStrings(genericMap)
518+
row = append(row, strings.Join(events, ", "))
515519
default:
516520
// else simply pick field value as text from column name
517521
row = append(row, toValue(genericMap, fieldName))

cmd/root_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
"PktDropLatestFlags":16,
4545
"PktDropLatestState":"TCP_INVALID_STATE",
4646
"PktDropPackets":1,
47-
"NetworkEvents":["hello"],
47+
"NetworkEvents":[{"Feature":"acl","Type":"NetpolNode","Action":"allow","Direction":"Ingress"}],
4848
"Proto":6,
4949
"SrcAddr":"10.128.0.29",
5050
"SrcK8S_HostIP":"10.0.1.1",

0 commit comments

Comments
 (0)