@@ -392,6 +392,65 @@ def test_event_matches(self):
392
392
'type' : '_fake_' }))
393
393
394
394
395
+ class TestPortBindingUpdateVirtualPortsEvent (base .BaseTestCase ):
396
+ def setUp (self ):
397
+ super ().setUp ()
398
+ self .event = ovsdb_monitor .PortBindingUpdateVirtualPortsEvent (None )
399
+
400
+ self .pbtable = fakes .FakeOvsdbTable .create_one_ovsdb_table (
401
+ attrs = {'name' : 'Port_Binding' })
402
+ self .ovsdb_row = fakes .FakeOvsdbRow .create_one_ovsdb_row
403
+
404
+ self .row = self .ovsdb_row (
405
+ attrs = {'_table' : self .pbtable ,
406
+ 'chassis' : 'newchassis' ,
407
+ 'options' : {
408
+ 'virtual-parents' : 'uuid1,uuid2' }})
409
+
410
+ def test_delete_event_matches (self ):
411
+ # Delete event (only type virtual).
412
+ self .assertFalse (self .event .match_fn (
413
+ self .event .ROW_DELETE ,
414
+ self .ovsdb_row (attrs = {'_table' : self .pbtable , 'type' : '_fake_' }),
415
+ None ))
416
+ self .assertTrue (self .event .match_fn (
417
+ self .event .ROW_DELETE ,
418
+ self .ovsdb_row (attrs = {'_table' : self .pbtable , 'type' : 'virtual' }),
419
+ None ))
420
+
421
+ def test_event_no_match_no_options (self ):
422
+ # Unrelated portbind change (no options in old, so no virtual parents)
423
+ self .assertFalse (self .event .match_fn (
424
+ self .event .ROW_UPDATE , self .row ,
425
+ self .ovsdb_row (attrs = {'_table' : self .pbtable ,
426
+ 'name' : 'somename' })))
427
+
428
+ def test_event_no_match_other_options_change (self ):
429
+ # Non-virtual parent change, no chassis has changed
430
+ old = self .ovsdb_row (attrs = {'_table' : self .pbtable ,
431
+ 'options' : {
432
+ 'virtual-parents' : 'uuid1,uuid2' ,
433
+ 'other-opt' : '_fake_' }})
434
+
435
+ self .assertFalse (self .event .match_fn (self .event .ROW_UPDATE ,
436
+ self .row , old ))
437
+
438
+ def test_event_match_chassis_change (self ):
439
+ # Port binding change (chassis changed, and marked in old)
440
+ self .assertTrue (self .event .match_fn (
441
+ self .event .ROW_UPDATE , self .row ,
442
+ self .ovsdb_row (attrs = {'_table' : self .pbtable ,
443
+ 'chassis' : 'fakechassis' })))
444
+
445
+ def test_event_match_virtual_parent_change (self ):
446
+ # Virtual parent change
447
+ old = self .ovsdb_row (attrs = {'_table' : self .pbtable ,
448
+ 'options' : {
449
+ 'virtual-parents' : 'uuid1,uuid3' }})
450
+ self .assertTrue (self .event .match_fn (self .event .ROW_UPDATE ,
451
+ self .row , old ))
452
+
453
+
395
454
class TestOvnNbIdlNotifyHandler (test_mech_driver .OVNMechanismDriverTestCase ):
396
455
397
456
def setUp (self ):
0 commit comments