diff --git a/tests/port_dpb.py b/tests/port_dpb.py index 55fbb6cc9c..5a5217ca60 100644 --- a/tests/port_dpb.py +++ b/tests/port_dpb.py @@ -27,6 +27,7 @@ def __init__(self, dvs, name = None): self._asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) self._asic_db_ptbl = swsscommon.Table(self._asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_PORT") self._counters_db = redis.Redis(unix_socket_path=self._dvs.redis_sock, db=swsscommon.COUNTERS_DB) + self._dvs_asic_db = dvs.get_asic_db() def set_name(self, name): self._name = name @@ -173,6 +174,9 @@ def exists_in_app_db(self): def sync_oid(self): self._oid = self._counters_db.hget("COUNTERS_PORT_NAME_MAP", self.get_name()) + """ + Expectation of the caller is that the port does exist in ASIC DB. + """ def exists_in_asic_db(self): self.sync_oid() if self._oid is None: @@ -180,6 +184,17 @@ def exists_in_asic_db(self): (status, _) = self._asic_db_ptbl.get(self._oid) return status + """ + Expectation of the caller is that the port does NOT exists in ASIC DB. + """ + def not_exists_in_asic_db(self): + self.sync_oid() + if self._oid is None: + return True + + result = self._dvs_asic_db.wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_PORT", self._oid) + return (not bool(result)) + def verify_config_db(self): (status, fvs) = self._cfg_db_ptbl.get(self.get_name()) assert(status == True) diff --git a/tests/test_fdb_update.py b/tests/test_fdb_update.py index 65409bb9f6..59e6cb9add 100644 --- a/tests/test_fdb_update.py +++ b/tests/test_fdb_update.py @@ -251,7 +251,7 @@ def test_FDBLearnedAndUpdated(self, dvs, testlog): dvs.set_interface_status("Ethernet72", "down") # remove vlan ip - self.remove_entry_tbl(dvs.cdb, "VLAN_INTERFACE", key) + dvs.remove_ip_address("Vlan6", "6.6.6.1/24") # bring down vlan dvs.set_interface_status("Vlan6", "down") @@ -298,7 +298,7 @@ def test_FDBLearnedAndFlushed(self, dvs, testlog): time.sleep(2) # check that the FDB entries were inserted into ASIC DB - mac = get_mac_by_bridge_id(dvs, iface_2_bridge_port_id[PORT]) + mac = self.get_mac_by_bridge_id(dvs, iface_2_bridge_port_id[PORT]) assert server_mac in mac # bring down port @@ -307,7 +307,7 @@ def test_FDBLearnedAndFlushed(self, dvs, testlog): time.sleep(2) # fdb should be flushed - mac = get_mac_by_bridge_id(dvs, iface_2_bridge_port_id[PORT]) + mac = self.get_mac_by_bridge_id(dvs, iface_2_bridge_port_id[PORT]) assert not mac # remove vlan ip diff --git a/tests/test_port_dpb_vlan.py b/tests/test_port_dpb_vlan.py index e24c29586c..1d08017eff 100644 --- a/tests/test_port_dpb_vlan.py +++ b/tests/test_port_dpb_vlan.py @@ -30,9 +30,8 @@ def test_dependency(self, dvs): assert(p.exists_in_asic_db() == True) self.dvs_vlan.remove_vlan_member(vlan, p.get_name()) - time.sleep(1) # Verify that port is deleted - assert(p.exists_in_asic_db() == False) + assert(p.not_exists_in_asic_db() == True) #Create the port back and delete the VLAN p.write_to_config_db() @@ -70,7 +69,7 @@ def test_one_port_one_vlan(self, dvs): self.dvs_vlan.remove_vlan_member(vlan, "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(0) - assert(p.exists_in_asic_db() == False) + assert(p.not_exists_in_asic_db() == True) #print "Ethernet0 removed from VLAN and also from ASIC DB" dpb.create_child_ports(dvs, p, 4) @@ -99,7 +98,7 @@ def test_one_port_one_vlan(self, dvs): self.dvs_vlan.remove_vlan_member(vlan, cp.get_name()) vlan_member_count = vlan_member_count - 1 self.dvs_vlan.get_and_verify_vlan_member_ids(vlan_member_count) - assert(cp.exists_in_asic_db() == False) + assert(cp.not_exists_in_asic_db() == True) #print "Deleted %s from VLAN"%port_names p.write_to_config_db() @@ -149,7 +148,7 @@ def test_one_port_multiple_vlan(self, dvs): self.dvs_vlan.remove_vlan_member(vlans[2], "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(0) - assert(p.exists_in_asic_db() == False) + assert(p.not_exists_in_asic_db() == True) #print "Ethernet0 removed from VLAN102 and also from ASIC DB" dpb.create_child_ports(dvs, p, 4) @@ -163,7 +162,7 @@ def test_one_port_multiple_vlan(self, dvs): cp.delete_from_config_db() assert(cp.exists_in_config_db() == False) assert(cp.exists_in_app_db() == False) - assert(cp.exists_in_asic_db() == False) + assert(cp.not_exists_in_asic_db() == True) #print "Deleted %s and verified all DBs"%port_names #Add back Ethernet0 @@ -220,7 +219,7 @@ def test_all_port_10_vlans(self, dvs): self.dvs_vlan.remove_vlan_member(vlan_name, port_name) self.dvs_vlan.get_and_verify_vlan_member_ids((num_ports*num_vlans)-(len(ports)*num_vlans)) - assert(p.exists_in_asic_db() == False) + assert(p.not_exists_in_asic_db() == True) #print "All %d ports are removed from all %d VLANs and deleted"%(num_ports,num_vlans) for p in ports: