@@ -38,19 +38,19 @@ func TestLokiFiltering(t *testing.T) {
3838 inputPath : "?filters=" + url .QueryEscape ("Proto=6&SrcK8S_Name=test" ),
3939 outputQueryParts : []string {
4040 "?query={app=\" netobserv-flowcollector\" }" ,
41- "|~`Proto\" :6, `" ,
41+ "|~`Proto\" :6[,}] `" ,
4242 "|~`SrcK8S_Name\" :\" (?i)[^\" ]*test.*\" `" ,
4343 },
4444 }, {
4545 inputPath : "?filters=" + url .QueryEscape ("Proto=6|SrcK8S_Name=test" ),
4646 outputQueries : []string {
47- "?query={app=\" netobserv-flowcollector\" }|~`Proto\" :6, `" ,
47+ "?query={app=\" netobserv-flowcollector\" }|~`Proto\" :6[,}] `" ,
4848 "?query={app=\" netobserv-flowcollector\" }|~`SrcK8S_Name\" :\" (?i)[^\" ]*test.*\" `" ,
4949 },
5050 }, {
5151 inputPath : "?filters=" + url .QueryEscape ("Proto=6|SrcK8S_Name=test" ) + "&reporter=source" ,
5252 outputQueries : []string {
53- "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 1\" }|~`Proto\" :6, `" ,
53+ "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 1\" }|~`Proto\" :6[,}] `" ,
5454 "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 1\" }|~`SrcK8S_Name\" :\" (?i)[^\" ]*test.*\" `" ,
5555 },
5656 }, {
@@ -71,7 +71,7 @@ func TestLokiFiltering(t *testing.T) {
7171 }, {
7272 inputPath : "?filters=" + url .QueryEscape ("SrcPort=8080&SrcAddr=10.128.0.1&SrcK8S_Namespace=default" ),
7373 outputQueries : []string {
74- "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*default.*\" }|~`SrcPort\" :8080, `|json|SrcAddr=ip(\" 10.128.0.1\" )" ,
74+ "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*default.*\" }|~`SrcPort\" :8080[,}] `|json|SrcAddr=ip(\" 10.128.0.1\" )" ,
7575 },
7676 }, {
7777 inputPath : "?filters=" + url .QueryEscape ("SrcAddr=10.128.0.1&DstAddr=10.128.0.2" ),
@@ -90,14 +90,14 @@ func TestLokiFiltering(t *testing.T) {
9090 outputQueries : []string {
9191 "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*default.*\" }" ,
9292 "?query={app=\" netobserv-flowcollector\" }|json|SrcAddr=ip(\" 10.128.0.1\" )" ,
93- "?query={app=\" netobserv-flowcollector\" }|~`SrcPort\" :8080, `" ,
93+ "?query={app=\" netobserv-flowcollector\" }|~`SrcPort\" :8080[,}] `" ,
9494 },
9595 }, {
9696 inputPath : "?filters=" + url .QueryEscape ("SrcPort=8080|SrcAddr=10.128.0.1|SrcK8S_Namespace=default" ) + "&reporter=destination" ,
9797 outputQueries : []string {
9898 "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 0\" ,SrcK8S_Namespace=~\" (?i).*default.*\" }" ,
9999 "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 0\" }|json|SrcAddr=ip(\" 10.128.0.1\" )" ,
100- "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 0\" }|~`SrcPort\" :8080, `" ,
100+ "?query={app=\" netobserv-flowcollector\" ,FlowDirection=\" 0\" }|~`SrcPort\" :8080[,}] `" ,
101101 },
102102 }, {
103103 inputPath : "?startTime=1640991600" ,
@@ -125,27 +125,65 @@ func TestLokiFiltering(t *testing.T) {
125125 inputPath : "?filters=" + url .QueryEscape ("Port=8080&K8S_Name=test" ),
126126 outputQueryParts : []string {
127127 "?query={app=\" netobserv-flowcollector\" }" ,
128- "|~`Port\" :8080, `" ,
128+ "|~`Port\" :8080[,}] `" ,
129129 "|~`K8S_Name\" :\" (?i)[^\" ]*test.*\" `" ,
130130 },
131131 }, {
132132 inputPath : "?filters=" + url .QueryEscape ("Port=8080|K8S_Name=test" ),
133133 outputQueries : []string {
134134 "?query={app=\" netobserv-flowcollector\" }|~`K8S_Name\" :\" (?i)[^\" ]*test.*\" `" ,
135- "?query={app=\" netobserv-flowcollector\" }|~`Port\" :8080, `" ,
135+ "?query={app=\" netobserv-flowcollector\" }|~`Port\" :8080[,}] `" ,
136136 },
137137 }, {
138138 inputPath : "?filters=" + url .QueryEscape ("Port=8080&SrcK8S_Namespace=test|Port=8080&DstK8S_Namespace=test" ),
139139 outputQueries : []string {
140- "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*test.*\" }|~`Port\" :8080, `" ,
141- "?query={app=\" netobserv-flowcollector\" ,DstK8S_Namespace=~\" (?i).*test.*\" }|~`Port\" :8080, `" ,
140+ "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*test.*\" }|~`Port\" :8080[,}] `" ,
141+ "?query={app=\" netobserv-flowcollector\" ,DstK8S_Namespace=~\" (?i).*test.*\" }|~`Port\" :8080[,}] `" ,
142142 },
143143 }, {
144144 inputPath : "?filters=" + url .QueryEscape ("Port=8080|SrcK8S_Namespace=test|DstK8S_Namespace=test" ),
145145 outputQueries : []string {
146146 "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=~\" (?i).*test.*\" }" ,
147147 "?query={app=\" netobserv-flowcollector\" ,DstK8S_Namespace=~\" (?i).*test.*\" }" ,
148- "?query={app=\" netobserv-flowcollector\" }|~`Port\" :8080,`" ,
148+ "?query={app=\" netobserv-flowcollector\" }|~`Port\" :8080[,}]`" ,
149+ },
150+ }, {
151+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Namespace=""&DstPort=70` ),
152+ outputQueries : []string {
153+ "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=\" \" }|~`DstPort\" :70[,}]`" ,
154+ },
155+ }, {
156+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Name=""&DstPort=70` ),
157+ outputQueries : []string {
158+ "?query={app=\" netobserv-flowcollector\" }|~`DstPort\" :70[,}]`|json|SrcK8S_Name=\" \" " ,
159+ },
160+ }, {
161+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Name="",foo&DstK8S_Name="hello"` ),
162+ outputQueries : []string {
163+ "?query={app=\" netobserv-flowcollector\" }|~`DstK8S_Name\" :\" hello\" `|json|SrcK8S_Name=\" \" +or+SrcK8S_Name=~`(?i).*foo.*`" ,
164+ },
165+ }, {
166+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Namespace=""|DstPort=70` ),
167+ outputQueries : []string {
168+ "?query={app=\" netobserv-flowcollector\" ,SrcK8S_Namespace=\" \" }" ,
169+ "?query={app=\" netobserv-flowcollector\" }|~`DstPort\" :70[,}]`" ,
170+ },
171+ }, {
172+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Name=""|DstPort=70` ),
173+ outputQueries : []string {
174+ "?query={app=\" netobserv-flowcollector\" }|~`DstPort\" :70[,}]`" ,
175+ "?query={app=\" netobserv-flowcollector\" }|json|SrcK8S_Name=\" \" " ,
176+ },
177+ }, {
178+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Name="",foo|DstK8S_Name="hello"` ),
179+ outputQueries : []string {
180+ "?query={app=\" netobserv-flowcollector\" }|~`DstK8S_Name\" :\" hello\" `" ,
181+ "?query={app=\" netobserv-flowcollector\" }|json|SrcK8S_Name=\" \" +or+SrcK8S_Name=~`(?i).*foo.*`" ,
182+ },
183+ }, {
184+ inputPath : "?filters=" + url .QueryEscape (`SrcK8S_Type="","Pod"` ),
185+ outputQueries : []string {
186+ "?query={app=\" netobserv-flowcollector\" }|json|SrcK8S_Type=\" \" +or+SrcK8S_Type=\" Pod\" " ,
149187 },
150188 }}
151189
0 commit comments