@@ -329,6 +329,65 @@ def test_event_matches(self):
329
329
'type' : '_fake_' }))
330
330
331
331
332
+ class TestPortBindingUpdateVirtualPortsEvent (base .BaseTestCase ):
333
+ def setUp (self ):
334
+ super ().setUp ()
335
+ self .event = ovsdb_monitor .PortBindingUpdateVirtualPortsEvent (None )
336
+
337
+ self .pbtable = fakes .FakeOvsdbTable .create_one_ovsdb_table (
338
+ attrs = {'name' : 'Port_Binding' })
339
+ self .ovsdb_row = fakes .FakeOvsdbRow .create_one_ovsdb_row
340
+
341
+ self .row = self .ovsdb_row (
342
+ attrs = {'_table' : self .pbtable ,
343
+ 'chassis' : 'newchassis' ,
344
+ 'options' : {
345
+ 'virtual-parents' : 'uuid1,uuid2' }})
346
+
347
+ def test_delete_event_matches (self ):
348
+ # Delete event (only type virtual).
349
+ self .assertFalse (self .event .match_fn (
350
+ self .event .ROW_DELETE ,
351
+ self .ovsdb_row (attrs = {'_table' : self .pbtable , 'type' : '_fake_' }),
352
+ None ))
353
+ self .assertTrue (self .event .match_fn (
354
+ self .event .ROW_DELETE ,
355
+ self .ovsdb_row (attrs = {'_table' : self .pbtable , 'type' : 'virtual' }),
356
+ None ))
357
+
358
+ def test_event_no_match_no_options (self ):
359
+ # Unrelated portbind change (no options in old, so no virtual parents)
360
+ self .assertFalse (self .event .match_fn (
361
+ self .event .ROW_UPDATE , self .row ,
362
+ self .ovsdb_row (attrs = {'_table' : self .pbtable ,
363
+ 'name' : 'somename' })))
364
+
365
+ def test_event_no_match_other_options_change (self ):
366
+ # Non-virtual parent change, no chassis has changed
367
+ old = self .ovsdb_row (attrs = {'_table' : self .pbtable ,
368
+ 'options' : {
369
+ 'virtual-parents' : 'uuid1,uuid2' ,
370
+ 'other-opt' : '_fake_' }})
371
+
372
+ self .assertFalse (self .event .match_fn (self .event .ROW_UPDATE ,
373
+ self .row , old ))
374
+
375
+ def test_event_match_chassis_change (self ):
376
+ # Port binding change (chassis changed, and marked in old)
377
+ self .assertTrue (self .event .match_fn (
378
+ self .event .ROW_UPDATE , self .row ,
379
+ self .ovsdb_row (attrs = {'_table' : self .pbtable ,
380
+ 'chassis' : 'fakechassis' })))
381
+
382
+ def test_event_match_virtual_parent_change (self ):
383
+ # Virtual parent change
384
+ old = self .ovsdb_row (attrs = {'_table' : self .pbtable ,
385
+ 'options' : {
386
+ 'virtual-parents' : 'uuid1,uuid3' }})
387
+ self .assertTrue (self .event .match_fn (self .event .ROW_UPDATE ,
388
+ self .row , old ))
389
+
390
+
332
391
class TestOvnNbIdlNotifyHandler (test_mech_driver .OVNMechanismDriverTestCase ):
333
392
334
393
def setUp (self ):
0 commit comments