@@ -39,9 +39,9 @@ func TestFlowTableDefaultDisplay(t *testing.T) {
3939 rows := strings .Split (buf .String (), "\n " )
4040
4141 assert .Equal (t , 4 , len (rows ))
42- assert .Equal (t , `End Time Src Name Src Namespace Dst Name Dst Namespace Node Dir Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
43- assert .Equal (t , `17:25:28.703000 src-pod first-namespace dst -pod second-namespace Ingress f18b970c2ce8fdd TCP Standard 456B 5 ` , rows [1 ])
44- assert .Equal (t , `--------------- --------------- --------------- --------------- --------------- ---------- ---------- ---------- ---------- ----- ----- ` , rows [2 ])
42+ assert .Equal (t , `End Time Src Kind Dst Kind Src Name Dst Name Src Namespace Dst Namespace Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
43+ assert .Equal (t , `17:25:28.703000 Pod Pod src -pod dst-pod first-namespace second-namespace f18b970c2ce8fdd TCP Standard 456B 5 ` , rows [1 ])
44+ assert .Equal (t , `--------------- ---------- ---------- --------------- --------------- --------------- --------------- ---------- ---------- ---------- ----- ----- ` , rows [2 ])
4545 assert .Empty (t , rows [3 ])
4646}
4747
@@ -53,8 +53,8 @@ func TestFlowTableMultipleFlows(t *testing.T) {
5353 setOutputBuffer (& buf )
5454
5555 // set display to standard without enrichment
56- display = [] string { standardDisplay }
57- enrichment = [] string { noEnrichment }
56+ display . current = 1
57+ enrichment . current = 0
5858
5959 // set time and bytes per flow
6060 flowTime := 1704063600000
@@ -86,16 +86,16 @@ func TestFlowTableMultipleFlows(t *testing.T) {
8686 rows := strings .Split (buf .String (), "\n " )
8787 // table must display only 38 rows (35 flows + header + footer + empty line)
8888 assert .Equal (t , 38 , len (rows ))
89- assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Node Dir Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
89+ assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
9090 // first flow is the 6th one that came to the display
91- assert .Equal (t , `00:00:06.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 6KB 1 ` , rows [1 ])
92- assert .Equal (t , `00:00:07.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 7KB 1 ` , rows [2 ])
93- assert .Equal (t , `00:00:08.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 8KB 1 ` , rows [3 ])
94- assert .Equal (t , `00:00:09.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 9KB 1 ` , rows [4 ])
95- assert .Equal (t , `00:00:10.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 10KB 1 ` , rows [5 ])
91+ assert .Equal (t , `00:00:06.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 6KB 1 ` , rows [1 ])
92+ assert .Equal (t , `00:00:07.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 7KB 1 ` , rows [2 ])
93+ assert .Equal (t , `00:00:08.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 8KB 1 ` , rows [3 ])
94+ assert .Equal (t , `00:00:09.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 9KB 1 ` , rows [4 ])
95+ assert .Equal (t , `00:00:10.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 10KB 1 ` , rows [5 ])
9696 // last flow is the 40th one
97- assert .Equal (t , `00:00:40.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a n/a 40KB 1 ` , rows [35 ])
98- assert .Equal (t , `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ` , rows [36 ])
97+ assert .Equal (t , `00:00:40.000000 10.0.0.5 n/a 10.0.0.6 n/a n/a n/a n/a 40KB 1 ` , rows [35 ])
98+ assert .Equal (t , `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ` , rows [36 ])
9999 assert .Empty (t , rows [37 ])
100100
101101}
@@ -108,10 +108,21 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
108108 setOutputBuffer (& buf )
109109
110110 // getRows function cleanup everything and redraw table with sample flow
111- getRows := func (d []string , e []string ) []string {
111+ getRows := func (displayName string , displayIds []string , enrichmentName string , enrichmentIds []string ) []string {
112112 // prepare display options
113- display = d
114- enrichment = e
113+ display = option {
114+ all : []optionItem {
115+ {name : displayName , ids : displayIds },
116+ },
117+ current : 0 ,
118+ }
119+
120+ enrichment = option {
121+ all : []optionItem {
122+ {name : enrichmentName , ids : enrichmentIds },
123+ },
124+ current : 0 ,
125+ }
115126
116127 // clear filters and previous flows
117128 regexes = []string {}
@@ -127,24 +138,24 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
127138 }
128139
129140 // set display without enrichment
130- rows := getRows ([]string {pktDropDisplay , dnsDisplay , rttDisplay , networkEventsDisplay }, []string {noEnrichment })
141+ rows := getRows (allOptions , []string {pktDropFeature , dnsFeature , rttFeature , networkEventsDisplay }, noOptions , []string {})
131142 assert .Equal (t , 4 , len (rows ))
132143 assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Dropped Bytes Dropped Packets Drop State Drop Cause Drop Flags DNS Id DNS Latency DNS RCode DNS Error Flow RTT Network Events ` , rows [0 ])
133144 assert .Equal (t , `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 32B 1 TCP_INVALID_STATE SKB_DROP_REASON_TCP_INVALID_SEQUENCE 16 31319 1ms NoError 0 10µs hello ` , rows [1 ])
134145 assert .Equal (t , `--------------- ---------- ---------- ---------- ---------- ----- ----- ---------- ---------- ---------- ----- ----- ----- ----- ----- --------------- ` , rows [2 ])
135146 assert .Empty (t , rows [3 ])
136147
137148 // set display to standard
138- rows = getRows ([]string {standardDisplay }, []string {noEnrichment })
149+ rows = getRows (standardDisplay , []string {}, noOptions , []string {})
139150
140151 assert .Equal (t , 4 , len (rows ))
141- assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Node Dir Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
142- assert .Equal (t , `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 Ingress f18b970c2ce8fdd TCP Standard 456B 5 ` , rows [1 ])
143- assert .Equal (t , `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ` , rows [2 ])
152+ assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Interfaces L3 Layer Protocol L3 Layer DSCP Bytes Packets ` , rows [0 ])
153+ assert .Equal (t , `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fdd TCP Standard 456B 5 ` , rows [1 ])
154+ assert .Equal (t , `--------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----- ----- ` , rows [2 ])
144155 assert .Empty (t , rows [3 ])
145156
146157 // set display to pktDrop
147- rows = getRows ([]string {pktDropDisplay }, []string {noEnrichment })
158+ rows = getRows ("Packet drops" , []string {pktDropFeature }, noOptions , []string {})
148159
149160 assert .Equal (t , 4 , len (rows ))
150161 assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Dropped Bytes Dropped Packets Drop State Drop Cause Drop Flags ` , rows [0 ])
@@ -153,7 +164,7 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
153164 assert .Empty (t , rows [3 ])
154165
155166 // set display to DNS
156- rows = getRows ([]string {dnsDisplay }, []string {noEnrichment })
167+ rows = getRows ("DNS" , []string {dnsFeature }, noOptions , []string {})
157168
158169 assert .Equal (t , 4 , len (rows ))
159170 assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port DNS Id DNS Latency DNS RCode DNS Error ` , rows [0 ])
@@ -162,7 +173,7 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
162173 assert .Empty (t , rows [3 ])
163174
164175 // set display to RTT
165- rows = getRows ([]string {rttDisplay }, []string {noEnrichment })
176+ rows = getRows ("RTT" , []string {rttFeature }, noOptions , []string {})
166177
167178 assert .Equal (t , 4 , len (rows ))
168179 assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Flow RTT ` , rows [0 ])
@@ -171,7 +182,7 @@ func TestFlowTableAdvancedDisplay(t *testing.T) {
171182 assert .Empty (t , rows [3 ])
172183
173184 // set display to NetworkEvents
174- rows = getRows ([]string {networkEventsDisplay }, []string {noEnrichment })
185+ rows = getRows ("Network events" , []string {networkEventsDisplay }, noOptions , []string {})
175186 assert .Equal (t , 4 , len (rows ))
176187 assert .Equal (t , `End Time Src IP Src Port Dst IP Dst Port Network Events ` , rows [0 ])
177188 assert .Equal (t , `17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 hello ` , rows [1 ])
0 commit comments