@@ -276,6 +276,48 @@ func TestOvsDriverDeinit(t *testing.T) {
276
276
277
277
}
278
278
279
+ func TestOvsDriverStateUpgrade (t * testing.T ) {
280
+ driver := & OvsDriver {}
281
+ fMode := "bridge"
282
+ stateDriver := & state.FakeStateDriver {}
283
+ stateDriver .Init (nil )
284
+ instInfo := & core.InstanceInfo {HostLabel : testHostLabelStateful ,
285
+ StateDriver : stateDriver , FwdMode : fMode }
286
+
287
+ operOvs := & OvsDriverOperState {CurrPortNum : testCurrPortNum }
288
+ operOvs .StateDriver = stateDriver
289
+ operOvs .ID = testHostLabelStateful
290
+ err := operOvs .Write ()
291
+ if err != nil {
292
+ t .Fatalf ("writing driver oper state failed. Error: %s" , err )
293
+ }
294
+
295
+ err = driver .Init (instInfo )
296
+ if err != nil {
297
+ t .Fatalf ("driver init failed. Error: %s" , err )
298
+ }
299
+
300
+ if driver .oper .CurrPortNum != testCurrPortNum {
301
+ t .Fatalf ("Unexpected driver oper state. Expected port num: %d, rcvd port number: %d" ,
302
+ testCurrPortNum , driver .oper .CurrPortNum )
303
+ }
304
+
305
+ // Try to save local endpoint info
306
+ driver .oper .localEpInfoMutex .Lock ()
307
+ driver .oper .LocalEpInfo ["testID" ] = & EpInfo {
308
+ Ovsportname : "testVport" ,
309
+ EpgKey : "testTen:testEpg" ,
310
+ BridgeType : "vlan" ,
311
+ }
312
+ driver .oper .localEpInfoMutex .Unlock ()
313
+ err = driver .oper .Write ()
314
+ if err != nil {
315
+ t .Fatalf ("driver opern write failed. Error: %s" , err )
316
+ }
317
+
318
+ defer func () { driver .Deinit () }()
319
+ }
320
+
279
321
func TestOvsDriverCreateEndpoint (t * testing.T ) {
280
322
driver := initOvsDriver (t )
281
323
defer func () { driver .Deinit () }()
0 commit comments