@@ -446,6 +446,30 @@ def _check_port_host_set(self, port_id, host_id):
446
446
# Check that both neutron and ovn are the same as given host_id
447
447
return port [portbindings .HOST_ID ] == host_id == ovn_host_id
448
448
449
+ def _check_port_and_port_binding_revision_number (self , port_id ):
450
+
451
+ def is_port_and_port_binding_same_revision_number (port_id ):
452
+ # This function checks if given port matches the revision_number
453
+ # in the neutron DB as well as in the OVN DB for the port_binding
454
+ core_plugin = directory .get_plugin ()
455
+
456
+ # Get port from neutron DB
457
+ port = core_plugin .get_ports (
458
+ self .context , filters = {'id' : [port_id ]})[0 ]
459
+
460
+ # Get port binding from OVN DB
461
+ bp = self ._find_port_binding (port_id )
462
+ ovn_port_binding_revision_number = bp .external_ids .get (
463
+ ovn_const .OVN_REV_NUM_EXT_ID_KEY , ovn_const .INITIAL_REV_NUM )
464
+
465
+ # Check that both neutron and ovn are the same as given host_id
466
+ return port ['revision_number' ] == int (
467
+ ovn_port_binding_revision_number )
468
+
469
+ check = functools .partial (
470
+ is_port_and_port_binding_same_revision_number , port_id )
471
+ n_utils .wait_until_true (check , timeout = 10 )
472
+
449
473
def test_virtual_port_host_update_upon_failover (self ):
450
474
# NOTE: we can't simulate traffic, but we can simulate the event that
451
475
# would've been triggered by OVN, which is what we do.
@@ -465,6 +489,7 @@ def test_virtual_port_host_update_upon_failover(self):
465
489
vip_address = vip ['fixed_ips' ][0 ]['ip_address' ]
466
490
allowed_address_pairs = [{'ip_address' : vip_address }]
467
491
self ._check_port_binding_type (vip ['id' ], '' )
492
+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
468
493
469
494
# 3) Create two ports with the allowed address pairs set.
470
495
hosts = ('ovs-host1' , second_chassis_name )
@@ -481,25 +506,29 @@ def test_virtual_port_host_update_upon_failover(self):
481
506
# have been assigned to the port binding
482
507
self ._check_port_binding_type (vip ['id' ], ovn_const .LSP_TYPE_VIRTUAL )
483
508
self ._check_port_virtual_parents (vip ['id' ], ',' .join (port_ids ))
509
+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
484
510
485
511
# 5) Bind the ports to a host, so a chassis is bound, which is
486
512
# required for the update_virtual_port_host method. Without this
487
513
# chassis set, it will not set a hostname in the DB's
488
514
self ._test_port_binding_and_status (ports [0 ]['id' ], 'bind' , 'ACTIVE' )
489
515
self .chassis = second_chassis
490
516
self ._test_port_binding_and_status (ports [1 ]['id' ], 'bind' , 'ACTIVE' )
517
+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
491
518
492
519
# 6) For both ports, bind vip on parent and check hostname in DBs
493
520
for idx in range (len (ports )):
494
521
# Set port binding to the first port, and update the chassis
495
522
self ._set_port_binding_virtual_parent (vip ['id' ], ports [idx ]['id' ])
523
+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
496
524
497
525
# Check if the host_id has been updated in OVN and DB
498
526
# by the event that eventually calls for method
499
527
# OVNMechanismDriver.update_virtual_port_host
500
528
n_utils .wait_until_true (
501
529
lambda : self ._check_port_host_set (vip ['id' ], hosts [idx ]),
502
530
timeout = 10 )
531
+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
503
532
504
533
505
534
class TestNBDbMonitorOverTcp (TestNBDbMonitor ):
0 commit comments