@@ -222,3 +222,59 @@ func TestBpfmanConfig(t *testing.T) {
222222 "csi.bpfman.io/program" : "netobserv" ,
223223 }, ds .Spec .Template .Spec .Volumes [1 ].CSI .VolumeAttributes )
224224}
225+
226+ func TestNetworkEventsOVNMount (t * testing.T ) {
227+ fc := flowslatest.FlowCollector {
228+ Spec : flowslatest.FlowCollectorSpec {
229+ Agent : flowslatest.FlowCollectorAgent {
230+ EBPF : flowslatest.FlowCollectorEBPF {
231+ Privileged : true ,
232+ Features : []flowslatest.AgentFeature {flowslatest .NetworkEvents },
233+ },
234+ },
235+ },
236+ }
237+
238+ // Upstream OVN
239+ info := reconcilers.Common {Namespace : "netobserv" , ClusterInfo : & cluster.Info {}}
240+ inst := info .NewInstance (map [reconcilers.ImageRef ]string {reconcilers .MainImage : "ebpf-agent" }, status.Instance {})
241+ agent := NewAgentController (inst )
242+ ds , err := agent .desired (context .Background (), & fc )
243+ assert .NoError (t , err )
244+ assert .NotNil (t , ds )
245+
246+ assert .Equal (t , "var-run-ovn" , ds .Spec .Template .Spec .Volumes [2 ].Name )
247+ assert .Equal (t , "/var/run/openvswitch" , ds .Spec .Template .Spec .Volumes [2 ].HostPath .Path )
248+
249+ // OpenShift OVN
250+ info .ClusterInfo .Mock ("4.20.0" , cluster .OVNKubernetes )
251+ ds , err = agent .desired (context .Background (), & fc )
252+ assert .NoError (t , err )
253+ assert .NotNil (t , ds )
254+
255+ assert .Equal (t , "var-run-ovn" , ds .Spec .Template .Spec .Volumes [2 ].Name )
256+ assert .Equal (t , "/var/run/ovn-ic" , ds .Spec .Template .Spec .Volumes [2 ].HostPath .Path )
257+
258+ // Custom
259+ fc = flowslatest.FlowCollector {
260+ Spec : flowslatest.FlowCollectorSpec {
261+ Agent : flowslatest.FlowCollectorAgent {
262+ EBPF : flowslatest.FlowCollectorEBPF {
263+ Privileged : true ,
264+ Features : []flowslatest.AgentFeature {flowslatest .NetworkEvents },
265+ Advanced : & flowslatest.AdvancedAgentConfig {
266+ Env : map [string ]string {
267+ envOVNObservHostMountPath : "/foo/bar" ,
268+ },
269+ },
270+ },
271+ },
272+ },
273+ }
274+ ds , err = agent .desired (context .Background (), & fc )
275+ assert .NoError (t , err )
276+ assert .NotNil (t , ds )
277+
278+ assert .Equal (t , "var-run-ovn" , ds .Spec .Template .Spec .Volumes [2 ].Name )
279+ assert .Equal (t , "/foo/bar" , ds .Spec .Template .Spec .Volumes [2 ].HostPath .Path )
280+ }
0 commit comments