@@ -231,62 +231,59 @@ var _ = g.Describe("NetObserv CLI e2e integration test suite", g.Ordered, func()
231231 g .Describe ("OCP-84801: Verify CLI runs under correct privileges" , g .Label ("Privileges" ), func () {
232232
233233 tests := []struct {
234- desc string
234+ when string
235+ it string
235236 cliArgs []string
236237 matcher types.GomegaMatcher
237238 }{
238239 {
239- desc : "Verifying `oc netobserv flows` does not run as privileged" ,
240+ when : "Executing `oc netobserv flows`" ,
241+ it : "does not run as privileged" ,
240242 cliArgs : []string {"flows" },
241243 matcher : o .BeFalse (),
242244 },
243245 {
244- desc : "Verifying `oc netobserv flows --privileged=true` runs as privileged" ,
246+ when : "Executing `oc netobserv flows --privileged=true`" ,
247+ it : "runs as privileged" ,
245248 cliArgs : []string {"flows" , "--privileged=true" },
246249 matcher : o .BeTrue (),
247250 },
248251
249252 {
250- desc : "Verifying `oc netobserv flows --drops` runs as privileged" ,
253+ when : "Executing `oc netobserv flows --drops`" ,
254+ it : "runs as privileged" ,
251255 cliArgs : []string {"flows" , "--drops" },
252256 matcher : o .BeTrue (),
253257 },
254258
255- {
256- desc : "Verifying `oc netobserv flows --enable_network_events=true` runs as privileged" ,
257- cliArgs : []string {"flows" , "--enable_network_events=true" },
258- matcher : o .BeTrue (),
259- },
260- {
261- desc : "Verifying `oc netobserv flows --enable_network_events=true --privileged=false` is overwritten and runs as privileged" ,
262- cliArgs : []string {"flows" , "--enable_network_events=true" , "--privileged=false" },
263- matcher : o .BeTrue (),
264- },
259+
265260 }
266261
267262 for _ , t := range tests {
268- g .It (t .desc , g .Label ("Privileges" ), func () {
269- g .DeferCleanup (func () {
270- cleanup ()
263+ g .When (t .when , func () {
264+ g .It (t .it , func () {
265+ g .DeferCleanup (func () {
266+ cleanup ()
267+ })
268+ // run command async until done
269+ out , err := e2e .StartCommand (ilog , ocNetObservBinPath , t .cliArgs ... )
270+ writeOutput (StartupDate + "-flowOutput" , out )
271+ o .Expect (err ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error starting command %v" , err ))
272+
273+ // Wait for CLI to be ready
274+ daemonsetReady , err := isDaemonsetReady (clientset , "netobserv-cli" , cliNS )
275+ o .Expect (err ).NotTo (o .HaveOccurred (), "agent daemonset didn't come ready" )
276+ o .Expect (daemonsetReady ).To (o .BeTrue (), "agent daemonset didn't come ready" )
277+
278+ // Verify correct privilege setting
279+ ds , err := getDaemonSet (clientset , "netobserv-cli" , cliNS )
280+ o .Expect (err ).NotTo (o .HaveOccurred (), "DeamonSet should be created in CLI namespace" )
281+ containers := ds .Spec .Template .Spec .Containers
282+ o .Expect (len (containers )).To (o .Equal (1 ), "The number of containers specified in the template is != 1" )
283+ o .Expect (containers [0 ].SecurityContext .Privileged ).To (o .HaveValue (t .matcher ), "Priviledged is not set to true" )
284+ })
271285 })
272286
273- // run command async until done
274- out , err := e2e .StartCommand (ilog , ocNetObservBinPath , t .cliArgs ... )
275- writeOutput (StartupDate + "-flowOutput" , out )
276- o .Expect (err ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error starting command %v" , err ))
277-
278- // Wait for CLI to be ready
279- daemonsetReady , err := isDaemonsetReady (clientset , "netobserv-cli" , cliNS )
280- o .Expect (err ).NotTo (o .HaveOccurred (), "agent daemonset didn't come ready" )
281- o .Expect (daemonsetReady ).To (o .BeTrue (), "agent daemonset didn't come ready" )
282-
283- // Verify correct privilege setting
284- ds , err := getDaemonSet (clientset , "netobserv-cli" , cliNS )
285- o .Expect (err ).NotTo (o .HaveOccurred (), "DeamonSet should be created in CLI namespace" )
286- containers := ds .Spec .Template .Spec .Containers
287- o .Expect (len (containers )).To (o .Equal (1 ), "The number of containers specified in the template is != 1" )
288- o .Expect (containers [0 ].SecurityContext .Privileged ).To (o .HaveValue (t .matcher ), "Priviledged is not set to true" )
289- })
290287 }
291288 })
292289})
0 commit comments