@@ -75,12 +75,12 @@ func TestFlowFiltersYAML(t *testing.T) {
7575 // check yamls parts
7676 yamlStr := string (yamlBytes [:])
7777 yamls = strings .Split (yamlStr , "---" )
78- assert .Equal (t , 6 , len (yamls ))
78+ assert .Equal (t , 7 , len (yamls ))
7979
8080 // check yaml contents
8181 assert .Contains (t , yamls [0 ], "kind: Namespace" )
8282 assert .Contains (t , yamls [0 ], "name: \" netobserv-cli\" " )
83- assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels: app: netobserv pod- security.kubernetes.io/enforce: privileged pod -security.kubernetes.io/audit: privileged openshift .io/cluster-monitoring: \" true\" " ))
83+ assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels:app:netobserv-clipod- security.kubernetes.io/enforce:privilegedpod -security.kubernetes.io/audit:privilegedopenshift .io/cluster-monitoring:\" true\" " ))
8484
8585 assert .Contains (t , yamls [1 ], "kind: ServiceAccount" )
8686 assert .Contains (t , yamls [1 ], "name: netobserv-cli" )
@@ -100,16 +100,20 @@ func TestFlowFiltersYAML(t *testing.T) {
100100 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("subjects: - kind: ServiceAccount name: netobserv-cli namespace: \" netobserv-cli\" " ))
101101 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: netobserv-cli" ))
102102
103- assert .Contains (t , yamls [4 ], "kind: Service " )
104- assert .Contains (t , yamls [4 ], "name: collector " )
103+ assert .Contains (t , yamls [4 ], "kind: SecurityContextConstraints " )
104+ assert .Contains (t , yamls [4 ], "name: netobserv-cli " )
105105 assert .Contains (t , yamls [4 ], "namespace: \" netobserv-cli\" " )
106- assert .Contains (t , Normalize (yamls [4 ]), Normalize ("ports: - name: collector protocol: TCP port: 9999 targetPort: 9999" ))
107106
108- assert .Contains (t , yamls [5 ], "kind: DaemonSet " )
109- assert .Contains (t , yamls [5 ], "name: netobserv-cli " )
107+ assert .Contains (t , yamls [5 ], "kind: Service " )
108+ assert .Contains (t , yamls [5 ], "name: collector " )
110109 assert .Contains (t , yamls [5 ], "namespace: \" netobserv-cli\" " )
111- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("[{\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" TCP\" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 8080, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}, {\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" UDP\" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 0, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}]" ))
112- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("\" grpc\" : { \" targetHost\" : \" collector.netobserv-cli.svc.cluster.local\" , \" targetPort\" : 9999 }" ))
110+ assert .Contains (t , Normalize (yamls [5 ]), Normalize ("ports: - name: collector protocol: TCP port: 9999 targetPort: 9999" ))
111+
112+ assert .Contains (t , yamls [6 ], "kind: DaemonSet" )
113+ assert .Contains (t , yamls [6 ], "name: netobserv-cli" )
114+ assert .Contains (t , yamls [6 ], "namespace: \" netobserv-cli\" " )
115+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("[{\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" TCP\" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 8080, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}, {\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" UDP\" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 0, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}]" ))
116+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("\" grpc\" : { \" targetHost\" : \" collector.netobserv-cli.svc.cluster.local\" , \" targetPort\" : 9999 }" ))
113117
114118 return ctx
115119 },
@@ -169,12 +173,12 @@ func TestPacketFiltersYAML(t *testing.T) {
169173 // check yamls parts
170174 yamlStr := string (yamlBytes [:])
171175 yamls = strings .Split (yamlStr , "---" )
172- assert .Equal (t , 6 , len (yamls ))
176+ assert .Equal (t , 7 , len (yamls ))
173177
174178 // check yaml contents
175179 assert .Contains (t , yamls [0 ], "kind: Namespace" )
176180 assert .Contains (t , yamls [0 ], "name: \" netobserv-cli\" " )
177- assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels: app: netobserv pod- security.kubernetes.io/enforce: privileged pod -security.kubernetes.io/audit: privileged openshift .io/cluster-monitoring: \" true\" " ))
181+ assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels:app:netobserv-clipod- security.kubernetes.io/enforce:privilegedpod -security.kubernetes.io/audit:privilegedopenshift .io/cluster-monitoring:\" true\" " ))
178182
179183 assert .Contains (t , yamls [1 ], "kind: ServiceAccount" )
180184 assert .Contains (t , yamls [1 ], "name: netobserv-cli" )
@@ -194,16 +198,20 @@ func TestPacketFiltersYAML(t *testing.T) {
194198 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("subjects: - kind: ServiceAccount name: netobserv-cli namespace: \" netobserv-cli\" " ))
195199 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: netobserv-cli" ))
196200
197- assert .Contains (t , yamls [4 ], "kind: Service " )
198- assert .Contains (t , yamls [4 ], "name: collector " )
201+ assert .Contains (t , yamls [4 ], "kind: SecurityContextConstraints " )
202+ assert .Contains (t , yamls [4 ], "name: netobserv-cli " )
199203 assert .Contains (t , yamls [4 ], "namespace: \" netobserv-cli\" " )
200- assert .Contains (t , Normalize (yamls [4 ]), Normalize ("ports: - name: collector protocol: TCP port: 9999 targetPort: 9999" ))
201204
202- assert .Contains (t , yamls [5 ], "kind: DaemonSet " )
203- assert .Contains (t , yamls [5 ], "name: netobserv-cli " )
205+ assert .Contains (t , yamls [5 ], "kind: Service " )
206+ assert .Contains (t , yamls [5 ], "name: collector " )
204207 assert .Contains (t , yamls [5 ], "namespace: \" netobserv-cli\" " )
205- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("[{\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" \" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 80, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}]" ))
206- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("nodeSelector: netobserv: \" true\" " ))
208+ assert .Contains (t , Normalize (yamls [5 ]), Normalize ("ports: - name: collector protocol: TCP port: 9999 targetPort: 9999" ))
209+
210+ assert .Contains (t , yamls [6 ], "kind: DaemonSet" )
211+ assert .Contains (t , yamls [6 ], "name: netobserv-cli" )
212+ assert .Contains (t , yamls [6 ], "namespace: \" netobserv-cli\" " )
213+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("[{\" direction\" : \" \" , \" ip_cidr\" : \" 0.0.0.0/0\" , \" protocol\" : \" \" , \" source_port\" : 0, \" destination_port\" : 0, \" port\" : 80, \" source_port_range\" : \" \" , \" source_ports\" : \" \" , \" destination_port_range\" : \" \" , \" destination_ports\" : \" \" , \" port_range\" : \" \" , \" ports\" : \" \" , \" icmp_type\" : 0, \" icmp_code\" : 0, \" peer_ip\" : \" \" , \" peer_cidr\" : \" \" , \" action\" : \" Accept\" , \" tcp_flags\" : \" \" , \" drops\" : false}]" ))
214+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("nodeSelector: netobserv: \" true\" " ))
207215
208216 return ctx
209217 },
@@ -261,12 +269,12 @@ func TestMetricYAML(t *testing.T) {
261269 // check yamls parts
262270 yamlStr := string (yamlBytes [:])
263271 yamls = strings .Split (yamlStr , "---" )
264- assert .Equal (t , 10 , len (yamls ))
272+ assert .Equal (t , 11 , len (yamls ))
265273
266274 // check yaml contents
267275 assert .Contains (t , yamls [0 ], "kind: Namespace" )
268276 assert .Contains (t , yamls [0 ], "name: \" netobserv-cli\" " )
269- assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels: app: netobserv pod- security.kubernetes.io/enforce: privileged pod -security.kubernetes.io/audit: privileged openshift .io/cluster-monitoring: \" true\" " ))
277+ assert .Contains (t , Normalize (yamls [0 ]), Normalize ("labels:app:netobserv-clipod- security.kubernetes.io/enforce:privilegedpod -security.kubernetes.io/audit:privilegedopenshift .io/cluster-monitoring:\" true\" " ))
270278
271279 assert .Contains (t , yamls [1 ], "kind: ServiceAccount" )
272280 assert .Contains (t , yamls [1 ], "name: netobserv-cli" )
@@ -286,37 +294,41 @@ func TestMetricYAML(t *testing.T) {
286294 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("subjects: - kind: ServiceAccount name: netobserv-cli namespace: \" netobserv-cli\" " ))
287295 assert .Contains (t , Normalize (yamls [3 ]), Normalize ("roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: netobserv-cli" ))
288296
289- assert .Contains (t , yamls [4 ], "kind: ClusterRole " )
290- assert .Contains (t , yamls [4 ], "name: netobserv-cli-metrics " )
297+ assert .Contains (t , yamls [4 ], "kind: SecurityContextConstraints " )
298+ assert .Contains (t , yamls [4 ], "name: netobserv-cli" )
291299 assert .Contains (t , yamls [4 ], "namespace: \" netobserv-cli\" " )
292- assert .Contains (t , Normalize (yamls [4 ]), Normalize ("- apiGroups: - resources: - pods - services - endpoints verbs: - list - get - watch - nonResourceURLs: - /metrics verbs: - get" ))
293300
294- assert .Contains (t , yamls [5 ], "kind: ClusterRoleBinding " )
295- assert .Contains (t , yamls [5 ], "name: netobserv-cli" )
301+ assert .Contains (t , yamls [5 ], "kind: ClusterRole " )
302+ assert .Contains (t , yamls [5 ], "name: netobserv-cli-metrics " )
296303 assert .Contains (t , yamls [5 ], "namespace: \" netobserv-cli\" " )
297- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("subjects: - kind: ServiceAccount name: prometheus-k8s namespace: openshift-monitoring" ))
298- assert .Contains (t , Normalize (yamls [5 ]), Normalize ("roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: netobserv-cli-metrics" ))
304+ assert .Contains (t , Normalize (yamls [5 ]), Normalize ("- apiGroups: - resources: - pods - services - endpoints verbs: - list - get - watch - nonResourceURLs: - /metrics verbs: - get" ))
299305
300- assert .Contains (t , yamls [6 ], "kind: ServiceMonitor " )
306+ assert .Contains (t , yamls [6 ], "kind: ClusterRoleBinding " )
301307 assert .Contains (t , yamls [6 ], "name: netobserv-cli" )
302308 assert .Contains (t , yamls [6 ], "namespace: \" netobserv-cli\" " )
303- assert .Contains (t , Normalize (yamls [6 ]), Normalize ("namespaceSelector: matchNames: - \" netobserv-cli \" " ))
304- assert .Contains (t , Normalize (yamls [6 ]), Normalize ("selector: matchLabels: app: netobserv-cli" ))
309+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("subjects: - kind: ServiceAccount name: prometheus-k8s namespace: openshift-monitoring " ))
310+ assert .Contains (t , Normalize (yamls [6 ]), Normalize ("roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: netobserv-cli-metrics " ))
305311
306- assert .Contains (t , yamls [7 ], "kind: Service " )
312+ assert .Contains (t , yamls [7 ], "kind: ServiceMonitor " )
307313 assert .Contains (t , yamls [7 ], "name: netobserv-cli" )
308314 assert .Contains (t , yamls [7 ], "namespace: \" netobserv-cli\" " )
309- assert .Contains (t , Normalize (yamls [7 ]), Normalize ("ports: - name: prometheus protocol: TCP port: 9401 targetPort: 9401" ))
315+ assert .Contains (t , Normalize (yamls [7 ]), Normalize ("namespaceSelector: matchNames: - \" netobserv-cli\" " ))
316+ assert .Contains (t , Normalize (yamls [7 ]), Normalize ("selector: matchLabels: app: netobserv-cli" ))
310317
311- assert .Contains (t , yamls [8 ], "kind: ConfigMap " )
318+ assert .Contains (t , yamls [8 ], "kind: Service " )
312319 assert .Contains (t , yamls [8 ], "name: netobserv-cli" )
313- assert .Contains (t , yamls [8 ], "namespace: openshift-config-managed " )
314- assert .Contains (t , yamls [8 ], "console.openshift.io/dashboard: \" true \" " )
320+ assert .Contains (t , yamls [8 ], "namespace: \" netobserv-cli \" " )
321+ assert .Contains (t , Normalize ( yamls [8 ]), Normalize ( "ports: - name: prometheus protocol: TCP port: 9401 targetPort: 9401" ) )
315322
316- assert .Contains (t , yamls [9 ], "kind: DaemonSet " )
323+ assert .Contains (t , yamls [9 ], "kind: ConfigMap " )
317324 assert .Contains (t , yamls [9 ], "name: netobserv-cli" )
318- assert .Contains (t , yamls [9 ], "namespace: \" netobserv-cli\" " )
319- assert .Contains (t , Normalize (yamls [9 ]), Normalize ("ports: - name: prometheus containerPort: 9401 protocol: TCP" ))
325+ assert .Contains (t , yamls [9 ], "namespace: openshift-config-managed" )
326+ assert .Contains (t , yamls [9 ], "console.openshift.io/dashboard: \" true\" " )
327+
328+ assert .Contains (t , yamls [10 ], "kind: DaemonSet" )
329+ assert .Contains (t , yamls [10 ], "name: netobserv-cli" )
330+ assert .Contains (t , yamls [10 ], "namespace: \" netobserv-cli\" " )
331+ assert .Contains (t , Normalize (yamls [10 ]), Normalize ("ports: - name: prometheus containerPort: 9401 protocol: TCP" ))
320332
321333 return ctx
322334 },
0 commit comments