@@ -446,6 +446,30 @@ def _check_port_host_set(self, port_id, host_id):
446446 # Check that both neutron and ovn are the same as given host_id
447447 return port [portbindings .HOST_ID ] == host_id == ovn_host_id
448448
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+
449473 def test_virtual_port_host_update_upon_failover (self ):
450474 # NOTE: we can't simulate traffic, but we can simulate the event that
451475 # would've been triggered by OVN, which is what we do.
@@ -465,6 +489,7 @@ def test_virtual_port_host_update_upon_failover(self):
465489 vip_address = vip ['fixed_ips' ][0 ]['ip_address' ]
466490 allowed_address_pairs = [{'ip_address' : vip_address }]
467491 self ._check_port_binding_type (vip ['id' ], '' )
492+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
468493
469494 # 3) Create two ports with the allowed address pairs set.
470495 hosts = ('ovs-host1' , second_chassis_name )
@@ -481,25 +506,29 @@ def test_virtual_port_host_update_upon_failover(self):
481506 # have been assigned to the port binding
482507 self ._check_port_binding_type (vip ['id' ], ovn_const .LSP_TYPE_VIRTUAL )
483508 self ._check_port_virtual_parents (vip ['id' ], ',' .join (port_ids ))
509+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
484510
485511 # 5) Bind the ports to a host, so a chassis is bound, which is
486512 # required for the update_virtual_port_host method. Without this
487513 # chassis set, it will not set a hostname in the DB's
488514 self ._test_port_binding_and_status (ports [0 ]['id' ], 'bind' , 'ACTIVE' )
489515 self .chassis = second_chassis
490516 self ._test_port_binding_and_status (ports [1 ]['id' ], 'bind' , 'ACTIVE' )
517+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
491518
492519 # 6) For both ports, bind vip on parent and check hostname in DBs
493520 for idx in range (len (ports )):
494521 # Set port binding to the first port, and update the chassis
495522 self ._set_port_binding_virtual_parent (vip ['id' ], ports [idx ]['id' ])
523+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
496524
497525 # Check if the host_id has been updated in OVN and DB
498526 # by the event that eventually calls for method
499527 # OVNMechanismDriver.update_virtual_port_host
500528 n_utils .wait_until_true (
501529 lambda : self ._check_port_host_set (vip ['id' ], hosts [idx ]),
502530 timeout = 10 )
531+ self ._check_port_and_port_binding_revision_number (vip ['id' ])
503532
504533
505534class TestNBDbMonitorOverTcp (TestNBDbMonitor ):
0 commit comments