@@ -11,6 +11,7 @@ import (
11
11
"path/filepath"
12
12
"reflect"
13
13
"strings"
14
+ "time"
14
15
15
16
"github.com/vishvananda/netlink"
16
17
@@ -236,6 +237,36 @@ var _ = Describe("ocicni operations", func() {
236
237
ocicni .Shutdown ()
237
238
})
238
239
240
+ It ("should monitor the conf dir for changes" , func () {
241
+ _ , _ , err := writeConfig (tmpDir , "5-notdefault.conf" , "notdefault" , "myplugin" , "0.3.1" )
242
+ Expect (err ).NotTo (HaveOccurred ())
243
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "test" , "myplugin" , "0.3.1" )
244
+ Expect (err ).NotTo (HaveOccurred ())
245
+
246
+ ocicni , err := initCNI (& fakeExec {}, "" , "test" , tmpDir , false , "/opt/cni/bin" )
247
+ Expect (err ).NotTo (HaveOccurred ())
248
+ Expect (ocicni .Status ()).NotTo (HaveOccurred ())
249
+
250
+ // Ensure the default network is the one we expect
251
+ tmp := ocicni .(* cniNetworkPlugin )
252
+ net := tmp .getDefaultNetwork ()
253
+ Expect (net .name ).To (Equal ("test" ))
254
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
255
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("myplugin" ))
256
+
257
+ _ , _ , err = writeConfig (tmpDir , "10-test.conf" , "test" , "testplugin" , "0.3.1" )
258
+ Expect (err ).NotTo (HaveOccurred ())
259
+
260
+ time .Sleep (5 )
261
+
262
+ // Ensure the default network is the updated one
263
+ Expect (net .name ).To (Equal ("test" ))
264
+ Expect (len (net .config .Plugins )).To (BeNumerically (">" , 0 ))
265
+ Expect (net .config .Plugins [0 ].Network .Type ).To (Equal ("testplugin" ))
266
+
267
+ ocicni .Shutdown ()
268
+ })
269
+
239
270
It ("finds an asynchronously written default network configuration" , func () {
240
271
ocicni , err := initCNI (& fakeExec {}, "" , "test" , tmpDir , true , "/opt/cni/bin" )
241
272
Expect (err ).NotTo (HaveOccurred ())
0 commit comments