@@ -293,6 +293,68 @@ var _ = Describe("ocicni operations", func() {
293
293
ocicni .Shutdown ()
294
294
})
295
295
296
+ It ("should monitor the net conf dir for changes when default network is not specified" , func () {
297
+ _ , _ , err := writeConfig (tmpDir , "5-notdefault.conf" , "notdefault" , "myplugin" , "0.3.1" )
298
+ Expect (err ).NotTo (HaveOccurred ())
299
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "test" , "myplugin" , "0.3.1" )
300
+ Expect (err ).NotTo (HaveOccurred ())
301
+
302
+ ocicni , err := initCNI (& fakeExec {}, "" , "" , tmpDir , true , "/opt/cni/bin" )
303
+ Expect (err ).NotTo (HaveOccurred ())
304
+ Expect (ocicni .Status ()).NotTo (HaveOccurred ())
305
+
306
+ // Ensure the default network is the one we expect
307
+ tmp := ocicni .(* cniNetworkPlugin )
308
+ net := tmp .getDefaultNetwork ()
309
+ Expect (net .name ).To (Equal ("test" ))
310
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
311
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("myplugin" ))
312
+
313
+ // If a CNI config file is updated, default network name should be reloaded real-time
314
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "secondary" , "testplugin" , "0.3.1" )
315
+ Expect (err ).NotTo (HaveOccurred ())
316
+
317
+ Consistently (ocicni .Status , 5 ).Should (Succeed ())
318
+
319
+ net = tmp .getDefaultNetwork ()
320
+ Expect (net .name ).To (Equal ("secondary" ))
321
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
322
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("testplugin" ))
323
+
324
+ ocicni .Shutdown ()
325
+ })
326
+
327
+ It ("should monitor the net conf dir for changes when default network is specified" , func () {
328
+ _ , _ , err := writeConfig (tmpDir , "5-notdefault.conf" , "notdefault" , "myplugin" , "0.3.1" )
329
+ Expect (err ).NotTo (HaveOccurred ())
330
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "test" , "myplugin" , "0.3.1" )
331
+ Expect (err ).NotTo (HaveOccurred ())
332
+
333
+ ocicni , err := initCNI (& fakeExec {}, "" , "test" , tmpDir , true , "/opt/cni/bin" )
334
+ Expect (err ).NotTo (HaveOccurred ())
335
+ Expect (ocicni .Status ()).NotTo (HaveOccurred ())
336
+
337
+ // Ensure the default network is the one we expect
338
+ tmp := ocicni .(* cniNetworkPlugin )
339
+ net := tmp .getDefaultNetwork ()
340
+ Expect (net .name ).To (Equal ("test" ))
341
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
342
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("myplugin" ))
343
+
344
+ // If a CNI config file is updated, default network name should be reloaded real-time
345
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "test" , "testplugin" , "0.3.1" )
346
+ Expect (err ).NotTo (HaveOccurred ())
347
+
348
+ Consistently (ocicni .Status , 5 ).Should (Succeed ())
349
+
350
+ net = tmp .getDefaultNetwork ()
351
+ Expect (net .name ).To (Equal ("test" ))
352
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
353
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("testplugin" ))
354
+
355
+ ocicni .Shutdown ()
356
+ })
357
+
296
358
It ("finds and refinds an asynchronously written default network configuration" , func () {
297
359
ocicni , err := initCNI (& fakeExec {}, "" , "test" , tmpDir , true , "/opt/cni/bin" )
298
360
Expect (err ).NotTo (HaveOccurred ())
0 commit comments