Skip to content

Commit

Permalink
Fixed DPB system test cases to bring stability
Browse files Browse the repository at this point in the history
Signed-off-by: Sangita Maity <samaity@linkedin.com>
  • Loading branch information
Sangita Maity committed Jun 21, 2021
1 parent b8b2df2 commit 85dfbc3
Showing 1 changed file with 24 additions and 33 deletions.
57 changes: 24 additions & 33 deletions tests/test_port_dpb_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
@pytest.mark.usefixtures('dvs_vlan_manager')
class TestPortDPBSystem(object):

def create_l3_intf(self, dvs, interface, vrf_name):
dvs_asic_db = dvs.get_asic_db()
initial_entries = set(dvs_asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE"))
def setup_db(self, dvs):
self.pdb = dvs.get_app_db()
self.adb = dvs.get_asic_db()
self.cdb = dvs.get_config_db()

def create_l3_intf(self, dvs, interface, vrf_name):
if interface.startswith("PortChannel"):
tbl_name = "PORTCHANNEL_INTERFACE"
elif interface.startswith("Vlan"):
Expand All @@ -34,12 +36,8 @@ def create_l3_intf(self, dvs, interface, vrf_name):
fvs = {'NULL':'NULL'}
else:
fvs = {'vrf_name':vrf_name}
dvs.get_config_db().create_entry(tbl_name, interface, fvs)
self.cdb.create_entry(tbl_name, interface, fvs)

dvs_asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", len(initial_entries)+1)
current_entries = set(dvs_asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE"))
assert len(current_entries - initial_entries) == 1
return list(current_entries - initial_entries)[0]

def remove_l3_intf(self, dvs, interface):
if interface.startswith("PortChannel"):
Expand All @@ -51,7 +49,7 @@ def remove_l3_intf(self, dvs, interface):
else:
tbl_name = "INTERFACE"

dvs.get_config_db().delete_entry(tbl_name, interface)
self.cdb.delete_entry(tbl_name, interface)

def add_ip_address(self, dvs, interface, ip):
if interface.startswith("PortChannel"):
Expand All @@ -63,7 +61,7 @@ def add_ip_address(self, dvs, interface, ip):
else:
tbl_name = "INTERFACE"

dvs.get_config_db().create_entry(tbl_name, interface+'|'+ip, {'NULL':'NULL'})
self.cdb.create_entry(tbl_name, interface+'|'+ip, {'NULL':'NULL'})

def remove_ip_address(self, dvs, interface, ip):
if interface.startswith("PortChannel"):
Expand All @@ -75,7 +73,7 @@ def remove_ip_address(self, dvs, interface, ip):
else:
tbl_name = "INTERFACE"

dvs.get_config_db().delete_entry(tbl_name, interface+'|'+ip)
self.cdb.delete_entry(tbl_name, interface+'|'+ip)

def clear_srv_config(self, dvs):
dvs.servers[0].runcmd("ip address flush dev eth0")
Expand All @@ -84,7 +82,7 @@ def clear_srv_config(self, dvs):
dvs.servers[3].runcmd("ip address flush dev eth0")

def set_admin_status(self, dvs, interface, status):
dvs_cfg_db = dvs.get_config_db()
dvs_cfg_db = self.cdb
if interface.startswith("PortChannel"):
tbl_name = "PORTCHANNEL"
elif interface.startswith("Vlan"):
Expand Down Expand Up @@ -124,7 +122,6 @@ def verify_only_ports_exist(self, dvs, port_names):
|-----------------------------------------------------------------------------------------------------
| 1x50G(2)+2x25G(2) | | P | | P | P | P | NA |
|-----------------------------------------------------------------------------------------------------
NA --> Not Applicable
P --> Pass
F --> Fail
Expand Down Expand Up @@ -205,7 +202,6 @@ def test_port_breakout_with_vlan(self, dvs):
# Verify DPB is successful
dpb.verify_port_breakout_mode(dvs, "Ethernet0", breakoutMode1)

@pytest.mark.skip(reason="This test is not stable enough")
def test_port_breakout_with_acl(self, dvs, dvs_acl):
dvs.setup_db()
dpb = DPB()
Expand Down Expand Up @@ -327,16 +323,16 @@ def test_cli_command_with_force_option(self, dvs, dvs_acl):
self.set_admin_status(dvs, "Ethernet8", "up")

# Create L3 interface
self.create_l3_intf(dvs, "Ethernet8", "");
self.create_l3_intf(dvs, "Ethernet8", "")

# Configure IPv4 address on Ethernet8
self.add_ip_address(dvs, "Ethernet8", Ethernet8_IP)

# one loopback router interface and one port based router interface
dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2)

def _check_route_present():
routes = dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
routes = self.adb.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
subnet_found = False
ip2me_found = False
for route in routes:
Expand All @@ -358,10 +354,10 @@ def _check_route_present():

# check ASIC router interface database
# one loopback router interface
dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)

def _check_route_absent():
routes = dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
routes = self.adb.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
for route in routes:
rt = json.loads(route)
if rt["dest"] == Ethernet8_IP or \
Expand Down Expand Up @@ -493,7 +489,7 @@ def test_cli_command_with_load_port_breakout_config_option(self, dvs, dvs_acl):

# check ASIC router interface database
# one loopback router interface
dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)

# Breakout Ethernet8 WITH "-l" option and ensure
# ip address gets configured as per port_breakout_config_db.json
Expand All @@ -502,10 +498,10 @@ def test_cli_command_with_load_port_breakout_config_option(self, dvs, dvs_acl):
dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode2x)

# one loopback router interface and one port based router interface
dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2)

def _check_route_present():
routes = dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
routes = self.adb.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
subnet_found = False
ip2me_found = False
for route in routes:
Expand All @@ -527,10 +523,10 @@ def _check_route_present():

# check ASIC router interface database
# one loopback router interface
dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1)

def _check_route_absent():
routes = dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
routes = self.adb.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
for route in routes:
rt = json.loads(route)
if rt["dest"] == Ethernet8_IP or \
Expand All @@ -541,7 +537,6 @@ def _check_route_absent():
status, result = wait_for_result(_check_route_absent, ROUTE_CHECK_POLLING)
assert status == True

@pytest.mark.skip(reason="This test is not stable enough")
def test_cli_command_negative(self, dvs, dvs_acl):
dvs.setup_db()
dpb = DPB()
Expand Down Expand Up @@ -625,10 +620,9 @@ def test_cli_command_negative(self, dvs, dvs_acl):
dvs_acl.verify_acl_table_count(0)
self.dvs_vlan.get_and_verify_vlan_ids(0)

@pytest.mark.skip(reason="This test is not stable enough")
def test_dpb_arp_flush(self, dvs):
dvs.setup_db()
dvs_asic_db = dvs.get_asic_db()
dvs_asic_db = self.adb
dpb = DPB()

portName = "Ethernet0"
Expand Down Expand Up @@ -676,10 +670,9 @@ def test_dpb_arp_flush(self, dvs):
dvs.change_port_breakout_mode("Ethernet0", "1x100G[40G]")
dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]")

@pytest.mark.skip(reason="This test is not stable enough")
def test_dpb_arp_flush_vlan(self, dvs):
dvs.setup_db()
dvs_asic_db = dvs.get_asic_db()
dvs_asic_db = self.adb
dpb = DPB()

self.clear_srv_config(dvs)
Expand Down Expand Up @@ -740,10 +733,9 @@ def test_dpb_arp_flush_vlan(self, dvs):
# Remove VLAN(note that member was removed during port breakout)
self.dvs_vlan.remove_vlan(vlanID)

@pytest.mark.skip(reason="This test is not stable enough")
def test_dpb_arp_flush_on_port_oper_shut(self, dvs):
dvs.setup_db()
dvs_asic_db = dvs.get_asic_db()
dvs_asic_db = self.adb
dpb = DPB()

self.clear_srv_config(dvs)
Expand Down Expand Up @@ -805,10 +797,9 @@ def test_dpb_arp_flush_on_port_oper_shut(self, dvs):
self.dvs_vlan.remove_vlan_member(vlanID, portName)
self.dvs_vlan.remove_vlan(vlanID)

@pytest.mark.skip(reason="This test is not stable enough")
def test_dpb_arp_flush_on_vlan_member_remove(self, dvs):
dvs.setup_db()
dvs_asic_db = dvs.get_asic_db()
dvs_asic_db = self.adb
dpb = DPB()

self.clear_srv_config(dvs)
Expand Down

0 comments on commit 85dfbc3

Please sign in to comment.