Skip to content

Commit

Permalink
tear down
Browse files Browse the repository at this point in the history
Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>
  • Loading branch information
ms-junyi committed Jul 5, 2022
1 parent 99a9719 commit b4a4741
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 21 deletions.
6 changes: 6 additions & 0 deletions test/sai_test/config/fdb_configer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def t0_fdb_config_helper(test_obj, is_create_fdb=True):
# Todo dynamic use the vlan_member_port_map to add data to fdb
test_obj.local_server_mac_list = local_server_mac_list

def t0_fdb_tear_down_helper(test_obj):
'''
Args:
test_obj: test object
'''
sai_thrift_flush_fdb_entries(test_obj.client, entry_type=SAI_FDB_FLUSH_ENTRY_TYPE_ALL)

class FdbConfiger(object):
"""
Expand Down
28 changes: 26 additions & 2 deletions test/sai_test/config/port_configer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def t0_port_config_helper(test_obj, is_recreate_bridge=True, is_create_hostIf=Tr
"""
configer = PortConfiger(test_obj)

dev_port_list = configer.get_local_mapped_ports()
portConfigs = configer.parse_port_config(
test_obj.test_params['port_config_ini'])
Expand Down Expand Up @@ -79,6 +78,15 @@ def t0_port_config_helper(test_obj, is_recreate_bridge=True, is_create_hostIf=Tr
test_obj.default_1q_bridge_id = default_1q_bridge_id
test_obj.bridge_port_list = bridge_port_list

def t0_port_tear_down_helper(test_obj):
'''
Args:
test_obj: test object
'''
configer = PortConfiger(test_obj)
default_1q_bridge_id = configer.get_default_1q_bridge()
configer.remove_bridge_port(default_1q_bridge_id)
configer.remove_host_inf(test_obj.host_intf_table_id,test_obj.hostif_list)

class PortConfiger(object):
"""
Expand Down Expand Up @@ -348,6 +356,22 @@ def remove_bridge_port(self, bridge_id):
sai_thrift_remove_bridge_port(self.client, port)
self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS)


def remove_host_inf(self,host_intf_table_id,hostif_list):
"""
Remove host interface.
Steps:
2. remove host interface
1. remove host table entry
Args:
host_intf_table_id
hostif_list
"""

for _, hostif in enumerate(hostif_list):
sai_thrift_remove_hostif(self.client,hostif)
sai_thrift_remove_hostif_table_entry(self.client,host_intf_table_id)

def turn_on_port_admin_state(self, port_list):
"""
Turn on port admin state
Expand All @@ -356,7 +380,7 @@ def turn_on_port_admin_state(self, port_list):
post_list: post list
"""
print("Set port...")
for i, port in enumerate(port_list):
for _, port in enumerate(port_list):
sai_thrift_set_port_attribute(
self.client, port_oid=port, mtu=self.get_mtu(), admin_state=True,
fec_mode=self.get_fec_mode())
Expand Down
20 changes: 20 additions & 0 deletions test/sai_test/config/vlan_configer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ def t0_vlan_config_helper(test_obj, is_reset_default_vlan=True, is_create_vlan=T
test_obj.vlans.update({key: vlans[key]})
test_obj.default_vlan_id = default_vlan_id

def t0_vlan_tear_down_helper(test_obj):
'''
Args:
test_obj: test object
remove vlan
'''
configer = VlanConfiger(test_obj)
#remove default vlan
default_vlan_id = configer.get_default_vlan()
members = configer.get_vlan_member(default_vlan_id)
configer.remove_vlan_members(members)
# configer.remove_vlan(default_vlan_id)

for _, vlan in test_obj.vlans.items():
members = configer.get_vlan_member(vlan.vlan_oid)
configer.remove_vlan_members(members)
configer.remove_vlan(vlan.vlan_oid)
test_obj.vlans.clear()



class VlanConfiger(object):
"""
Expand Down
12 changes: 12 additions & 0 deletions test/sai_test/sai_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@
from sai_thrift.sai_adapter import *
from sai_utils import *
from config.port_configer import t0_port_config_helper
from config.port_configer import t0_port_tear_down_helper
from config.port_configer import PortConfiger
from config.switch_configer import t0_switch_config_helper
from config.switch_configer import SwitchConfiger
from config.vlan_configer import t0_vlan_config_helper
from config.vlan_configer import t0_vlan_tear_down_helper
from config.vlan_configer import VlanConfiger
from config.fdb_configer import t0_fdb_config_helper
from config.fdb_configer import t0_fdb_tear_down_helper
from config.fdb_configer import FdbConfiger

THRIFT_PORT = 9092
Expand Down Expand Up @@ -233,3 +236,12 @@ def status():
int: sai call result
"""
return adapter.status

def tearDown(self):
'''
tear down
'''
t0_fdb_tear_down_helper(self)
t0_vlan_tear_down_helper(self)
t0_port_tear_down_helper(self)
super().tearDown()
37 changes: 18 additions & 19 deletions test/sai_test/sai_vlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class UntagAccessToAccessTest(T0TestBase):
Expand Down Expand Up @@ -116,12 +116,11 @@ def runTest(self):
send_packet(self, self.dev_port_list[9], pkt)
verify_packet(self, pkt, self.dev_port_list[index])
verify_no_other_packets(self, timeout=2)

finally:
pass

def tearDown(self):
pass
super().tearDown()


class MismatchDropTest(T0TestBase):
Expand Down Expand Up @@ -163,7 +162,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class TaggedFrameFilteringTest(T0TestBase):
Expand Down Expand Up @@ -196,7 +195,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class UnTaggedFrameFilteringTest(T0TestBase):
Expand Down Expand Up @@ -229,7 +228,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class TaggedVlanFloodingTest(T0TestBase):
Expand Down Expand Up @@ -257,7 +256,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class UnTaggedVlanFloodingTest(T0TestBase):
Expand Down Expand Up @@ -285,7 +284,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class BroadcastTest(T0TestBase):
Expand Down Expand Up @@ -321,7 +320,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class UntaggedMacLearningTest(T0TestBase):
Expand Down Expand Up @@ -357,7 +356,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class TaggedMacLearningTest(T0TestBase):
Expand Down Expand Up @@ -393,7 +392,7 @@ def runTest(self):
pass

def tearDown(self):
pass
super().tearDown()


class VlanMemberListTest(T0TestBase):
Expand Down Expand Up @@ -448,7 +447,7 @@ def runTest(self):
self.assertEqual(self.vlans[20].vlan_mport_oids[i - 8], mbr_list[i])

def tearDown(self):
pass
super().tearDown()


class VlanMemberInvalidTest(T0TestBase):
Expand All @@ -469,7 +468,7 @@ def runTest(self):
self.assertEqual(incorrect_member, 0)

def tearDown(self):
pass
super().tearDown()


class DisableMacLearningTaggedTest(T0TestBase):
Expand Down Expand Up @@ -501,7 +500,7 @@ def runTest(self):


def tearDown(self):
pass
super().tearDown()


class DisableMacLearningUntaggedTest(T0TestBase):
Expand Down Expand Up @@ -531,7 +530,7 @@ def runTest(self):
self.assertEqual(attr["available_fdb_entry"] - current_fdb_entry, 0)

def tearDown(self):
pass
super().tearDown()


class ArpRequestFloodingTest(T0TestBase):
Expand All @@ -554,7 +553,7 @@ def runTest(self):
self, [self.arp_request], [self.dev_port_list[2:9]])

def tearDown(self):
pass
super().tearDown()


class ArpRequestLearningTest(T0TestBase):
Expand Down Expand Up @@ -582,7 +581,7 @@ def runTest(self):
verify_no_other_packets(self)

def tearDown(self):
pass
super().tearDown()


class TaggedVlanStatusTest(T0TestBase):
Expand Down Expand Up @@ -667,7 +666,7 @@ def runTest(self):
# self.assertEqual(out_bytes, 0, 'vlan OUT bytes counter is not 0')

def tearDown(self):
pass
super().tearDown()


class UntaggedVlanStatusTest(T0TestBase):
Expand Down Expand Up @@ -752,4 +751,4 @@ def runTest(self):
# self.assertEqual(out_bytes, 0, 'vlan OUT bytes counter is not 0')

def tearDown(self):
pass
super().tearDown()

0 comments on commit b4a4741

Please sign in to comment.