From a95c8f2c995569f065746cdb5e4b224726c7c468 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Thu, 23 Jun 2022 06:21:26 +0000 Subject: [PATCH 01/20] add lag config Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 174 +++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 test/sai_test/config/lag_configer.py diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py new file mode 100644 index 000000000..af9b0c307 --- /dev/null +++ b/test/sai_test/config/lag_configer.py @@ -0,0 +1,174 @@ +# Copyright (c) 2021 Microsoft Open Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# Microsoft would like to thank the following companies for their review and +# assistance with these files: Intel Corporation, Mellanox Technologies Ltd, +# Dell Products, L.P., Facebook, Inc., Marvell International Ltd. +# +# + + +from bm.sai_adapter.test.ptf_tests.tests.switch import sai_thrift_create_lag_member +from sai_thrift.sai_adapter import * +from sai_utils import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] + + +def t0_lag_config_helper(test_obj, is_create_lag=True): + """ + Make lag configurations base on the configuration in the test plan. + set the configuration in test directly. + + set the following test_obj attributes: + dict: lags - {lag id: lag object} + + """ + lag_configer = LagConfiger(test_obj) + lags = {} + + if is_create_lag: + lag1 = lag_configer.create_lag([17, 18]) + lags.update({lag1.lag_id: lag1}) + lag2 = lag_configer.create_lag([19, 20]) + lags.update({lag2.lag_id: lag2}) + + if not hasattr(test_obj, 'lags'): + test_obj.lags = {} + for key in lags: + test_obj.lags.update({key: lags[key]}) + + lag_configer.set_lag_hash_algorithm(test_obj) + lag_configer.set_lag_hash_attribute(test_obj) + lag_configer.set_lag_hash_seed(test_obj) + + +class LagConfiger(object): + """ + Class use to make all the Lag configurations. + """ + + def __init__(self, test_obj) -> None: + """ + Init Lag configrer. + + Args: + test_obj: the test object + """ + self.test_obj = test_obj + self.client = test_obj.client + + def create_lag(self, lag_port_idxs): + """ + Create lag and its members. + + Args: + lag_port_idxs: lag port indexs + + Returns: + Lag: lag object + """ + + lag = Lag() + lag_id = sai_thrift_create_lag(self.client) + lag_members = self.create_lag_member(lag_id, lag_port_idxs) + lag.lag_id = lag_id + lag.lag_members = lag_members + return lag + + def create_lag_member(self, lag_id, lag_port_idxs): + """ + Create lag members for a lag. + + Args: + lag: lag object + lag_port_idxs: lag member port indexs + + Returns: + lag_members: list of lag_member + """ + + lag_members = [] + for port_index in lag_port_idxs: + lag_member = sai_thrift_create_lag_member(self.client, + lag_id=lag_id, + port_id=self.test_obj.port_list[port_index]) + lag_members.append(lag_member) + return lag_members + + def set_lag_hash_algorithm(self, algo=SAI_HASH_ALGORITHM_CRC): + """ + Set lag hash algorithm. + + Args: + algo (int): hash algorithm id + """ + sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=algo) + + def set_lag_hash_attribute(self, hash_fields_list=None): + """ + Set lag hash attributes. + + Args: + hash_fields_list: hash fields list + """ + attr_list = sai_thrift_get_switch_attribute(self.client, lag_hash=True) + lag_hash_id = attr_list['SAI_SWITCH_ATTR_LAG_HASH'] + + if hash_fields_list is None: + hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, + SAI_NATIVE_HASH_FIELD_DST_IP, + SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, + SAI_NATIVE_HASH_FIELD_L4_DST_PORT, + SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] + + hash_attr_list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) + sai_thrift_set_hash_attribute(self.client, lag_hash_id, native_hash_field_list=hash_attr_list) + + def set_lag_hash_seed(self, seed=400): + """ + Set lag hash seed. + + Args: + seed: hash seed value + """ + sai_thrift_set_switch_attribute(self.client, lag_default_hash_seed=seed) + + def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, port_id): + vr_id = sai_thrift_create_virtual_router(self.client) + rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=lag_id) + rif_id2 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) + + nbr_entry_v4 = sai_thrift_neighbor_entry_t(rif_id=rif_id1, ip_address=sai_ipaddress(ip_addr)) + sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) + + nhop = sai_thrift_create_next_hop(self.client, ip=sai_ipaddress(ip_addr), router_interface_id=rif_id1, type=SAI_NEXT_HOP_TYPE_IP) + route1 = sai_thrift_route_entry(vr_id=vr_id, destination=sai_ipprefix(ip_addr+'/24')) + sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) + + def remove_lag_members(self, lag_members): + for lag_member in lag_members: + sai_thrift_remove_lag_member(self.client, lag_member) + + def remove_lag(self, lag_id): + sai_thrift_remove_lag(self.client, lag_id) + +class Lag(object): + """ + Represent the lag object. + Attrs: + lag_id: lag id + lag_members: lag members + """ + def __init__(self, lag_id=None, lag_members=None): + self.lag_id = lag_id + self.lag_members = lag_members From f29697d0a95982ffdacf2ee353e82c69e2c9498e Mon Sep 17 00:00:00 2001 From: zitingguo Date: Thu, 23 Jun 2022 07:44:33 +0000 Subject: [PATCH 02/20] enable lag config in test base Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_test_base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/sai_test/sai_test_base.py b/test/sai_test/sai_test_base.py index 44398568c..5522d26f1 100644 --- a/test/sai_test/sai_test_base.py +++ b/test/sai_test/sai_test_base.py @@ -190,12 +190,14 @@ def setUp(self, is_reset_default_vlan=True, is_create_vlan=True, is_create_fdb=True, + is_create_lag=True, wait_sec=5): super(T0TestBase, self).setUp() self.port_configer = PortConfiger(self) self.switch_configer = SwitchConfiger(self) self.fdb_configer = FdbConfiger(self) self.vlan_configer = VlanConfiger(self) + self.lag_configer = LagConfiger(self) if force_config or not is_configured: t0_switch_config_helper(self) @@ -210,6 +212,9 @@ def setUp(self, t0_fdb_config_helper( test_obj=self, is_create_fdb=is_create_fdb) + t0_lag_config_helper( + test_obj=self, + is_create_lag=is_create_lag) print("Waiting for switch to get ready before test, {} seconds ...".format( wait_sec)) time.sleep(wait_sec) From 5deefe2be60144dc1c5abf6122b0077deca7bece Mon Sep 17 00:00:00 2001 From: zitingguo Date: Thu, 23 Jun 2022 13:43:29 +0000 Subject: [PATCH 03/20] fix lag config Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index af9b0c307..278d83c71 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -39,8 +39,23 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): if is_create_lag: lag1 = lag_configer.create_lag([17, 18]) lags.update({lag1.lag_id: lag1}) + ip_addr1 = '10.1.1.100' + mac_addr1 = '02:04:02:01:01:01' + lag_configer.create_route_and_neighbor_entry_for_lag( + lag_id=lag1.lag_id, + ip_addr=ip_addr1, + mac_addr=mac_addr1, + port_id=21) + lag2 = lag_configer.create_lag([19, 20]) lags.update({lag2.lag_id: lag2}) + ip_addr2 = '10.1.2.100' + mac_addr2 = '02:04:02:01:02:01' + lag_configer.create_route_and_neighbor_entry_for_lag( + lag_id=lag2.lag_id, + ip_addr=ip_addr2, + mac_addr=mac_addr2, + port_id=21) if not hasattr(test_obj, 'lags'): test_obj.lags = {} @@ -145,8 +160,10 @@ def set_lag_hash_seed(self, seed=400): def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, port_id): vr_id = sai_thrift_create_virtual_router(self.client) + port2 = self.test_obj.port_list[port_id] + rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=lag_id) - rif_id2 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) + rif_id2 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port2) nbr_entry_v4 = sai_thrift_neighbor_entry_t(rif_id=rif_id1, ip_address=sai_ipaddress(ip_addr)) sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) From d6a1025f64ef0c5c2effcff61848a3f0a338e8e2 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Mon, 27 Jun 2022 10:32:39 +0000 Subject: [PATCH 04/20] add remove_lag_member in lag_configer Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index 278d83c71..b41b1ad0f 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -172,7 +172,10 @@ def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, por route1 = sai_thrift_route_entry(vr_id=vr_id, destination=sai_ipprefix(ip_addr+'/24')) sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) - def remove_lag_members(self, lag_members): + def remove_lag_member(self, lag_member): + sai_thrift_remove_lag_member(self, lag_member) + + def remove_all_lag_members(self, lag_members): for lag_member in lag_members: sai_thrift_remove_lag_member(self.client, lag_member) From de8d64a483d85615719ef92601ec794f002ebe60 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Tue, 28 Jun 2022 11:34:16 +0000 Subject: [PATCH 05/20] add sai_ipprefix() in utils Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/sai_test/sai_utils.py b/test/sai_test/sai_utils.py index 0e7a2a55e..400db63ce 100644 --- a/test/sai_test/sai_utils.py +++ b/test/sai_test/sai_utils.py @@ -114,3 +114,26 @@ def get_port_config(self): port_conf = self.config_json.get('PORT') key_0 = list(port_conf.keys())[0] return self.config_json.get('PORT').get(key_0) + + +def sai_ipaddress(addr_str): + """ + Set SAI IP address, assign appropriate type and return + sai_thrift_ip_address_t object + + Args: + addr_str (str): IP address string + + Returns: + sai_thrift_ip_address_t: object containing IP address family and number + """ + + if '.' in addr_str: + family = SAI_IP_ADDR_FAMILY_IPV4 + addr = sai_thrift_ip_addr_t(ip4=addr_str) + if ':' in addr_str: + family = SAI_IP_ADDR_FAMILY_IPV6 + addr = sai_thrift_ip_addr_t(ip6=addr_str) + ip_addr = sai_thrift_ip_address_t(addr_family=family, addr=addr) + + return ip_addr From 1553f67960da01a4047f18879eb2590f0353ab62 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Tue, 28 Jun 2022 11:35:50 +0000 Subject: [PATCH 06/20] fix typo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_sanity_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sai_test/sai_sanity_test.py b/test/sai_test/sai_sanity_test.py index 1fe0ac5b5..e2994d509 100644 --- a/test/sai_test/sai_sanity_test.py +++ b/test/sai_test/sai_sanity_test.py @@ -46,7 +46,7 @@ def runTest(self): def tearDown(self): """ - Test the basic tearDown proecss + Test the basic tearDown process """ pass From 743ba2b1b3da174d9435fa417e27d2a015f46402 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Tue, 28 Jun 2022 11:44:26 +0000 Subject: [PATCH 07/20] import LagConfiger in sai_test_base Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_test_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/sai_test/sai_test_base.py b/test/sai_test/sai_test_base.py index 5522d26f1..16971ea07 100644 --- a/test/sai_test/sai_test_base.py +++ b/test/sai_test/sai_test_base.py @@ -41,6 +41,8 @@ from config.vlan_configer import VlanConfiger from config.fdb_configer import t0_fdb_config_helper from config.fdb_configer import FdbConfiger +from config.lag_configer import t0_lag_config_helper +from config.lag_configer import LagConfiger THRIFT_PORT = 9092 is_configured = False From 397d2182b1b86c9b30354a7dafe5128533356aa6 Mon Sep 17 00:00:00 2001 From: zitingguo Date: Tue, 28 Jun 2022 13:45:43 +0000 Subject: [PATCH 08/20] add a simple lag test Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 26 +++++----- test/sai_test/sai_lag_test.py | 75 ++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 test/sai_test/sai_lag_test.py diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index b41b1ad0f..1a253c387 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -19,7 +19,6 @@ # -from bm.sai_adapter.test.ptf_tests.tests.switch import sai_thrift_create_lag_member from sai_thrift.sai_adapter import * from sai_utils import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] @@ -39,7 +38,7 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): if is_create_lag: lag1 = lag_configer.create_lag([17, 18]) lags.update({lag1.lag_id: lag1}) - ip_addr1 = '10.1.1.100' + ip_addr1 = '10.10.10.0' mac_addr1 = '02:04:02:01:01:01' lag_configer.create_route_and_neighbor_entry_for_lag( lag_id=lag1.lag_id, @@ -62,9 +61,9 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): for key in lags: test_obj.lags.update({key: lags[key]}) - lag_configer.set_lag_hash_algorithm(test_obj) - lag_configer.set_lag_hash_attribute(test_obj) - lag_configer.set_lag_hash_seed(test_obj) + lag_configer.set_lag_hash_algorithm() + lag_configer.set_lag_hash_attribute() + lag_configer.set_lag_hash_seed() class LagConfiger(object): @@ -127,9 +126,9 @@ def set_lag_hash_algorithm(self, algo=SAI_HASH_ALGORITHM_CRC): Args: algo (int): hash algorithm id """ - sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=algo) + sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=True) - def set_lag_hash_attribute(self, hash_fields_list=None): + def set_lag_hash_attribute(self): """ Set lag hash attributes. @@ -139,12 +138,11 @@ def set_lag_hash_attribute(self, hash_fields_list=None): attr_list = sai_thrift_get_switch_attribute(self.client, lag_hash=True) lag_hash_id = attr_list['SAI_SWITCH_ATTR_LAG_HASH'] - if hash_fields_list is None: - hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, - SAI_NATIVE_HASH_FIELD_DST_IP, - SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, - SAI_NATIVE_HASH_FIELD_L4_DST_PORT, - SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] + hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, + SAI_NATIVE_HASH_FIELD_DST_IP, + SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, + SAI_NATIVE_HASH_FIELD_L4_DST_PORT, + SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] hash_attr_list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) sai_thrift_set_hash_attribute(self.client, lag_hash_id, native_hash_field_list=hash_attr_list) @@ -169,7 +167,7 @@ def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, por sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) nhop = sai_thrift_create_next_hop(self.client, ip=sai_ipaddress(ip_addr), router_interface_id=rif_id1, type=SAI_NEXT_HOP_TYPE_IP) - route1 = sai_thrift_route_entry(vr_id=vr_id, destination=sai_ipprefix(ip_addr+'/24')) + route1 = sai_thrift_route_entry_t(vr_id=vr_id, destination=sai_ipprefix(ip_addr+'/24')) sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) def remove_lag_member(self, lag_member): diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py new file mode 100644 index 000000000..8676ed670 --- /dev/null +++ b/test/sai_test/sai_lag_test.py @@ -0,0 +1,75 @@ +# Copyright (c) 2021 Microsoft Open Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# Microsoft would like to thank the following companies for their review and +# assistance with these files: Intel Corporation, Mellanox Technologies Ltd, +# Dell Products, L.P., Facebook, Inc., Marvell International Ltd. +# +# + +from sai_test_base import T0TestBase +from sai_utils import * + +class Lag_Load_Balance_Test(T0TestBase): + """ + Verify the load-balance of l3 + """ + + def setUp(self): + """ + Test the basic setup process. + """ + T0TestBase.setUp(self) + + def load_balance_on_src_ip(self): + router_mac = '00:77:66:55:44:00' + ip_src1 = '192.168.0.1' + ip_src2 = '192.168.0.2' + ip_dst = '10.10.10.1' + pkt1 = simple_tcp_packet(eth_dst=router_mac, + eth_src='00:22:22:22:22:22', + ip_dst=ip_dst, + ip_src=ip_src1, + ip_id=105, + ip_ttl=64) + pkt2 = simple_tcp_packet(eth_dst=router_mac, + eth_src='00:22:22:22:22:22', + ip_dst=ip_dst, + ip_src=ip_src2, + ip_id=105, + ip_ttl=64) + exp_pkt1 = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=router_mac, + ip_dst=ip_dst, + ip_src=ip_src1, + ip_id=105, + ip_ttl=63) + exp_pkt2 = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=router_mac, + ip_dst=ip_dst, + ip_src=ip_src2, + ip_id=105, + ip_ttl=63) + + send_packet(self, 21, pkt1) + verify_packet_any_port(self, exp_pkt1, [17, 18]) + send_packet(self, 21, pkt) + verify_packet_any_port(self, exp_pkt2, [17, 18]) + + def runTest(self): + try: + print("simple lag test") + self.load_balance_on_src_ip() + finally: + pass From e81d746f4de54b9709e8ccfd33b72ae59ea9a2ce Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Wed, 29 Jun 2022 06:44:55 +0000 Subject: [PATCH 09/20] fix typo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_lag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 8676ed670..3d4b07e0d 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -21,7 +21,7 @@ from sai_test_base import T0TestBase from sai_utils import * -class Lag_Load_Balance_Test(T0TestBase): +class LagLoadBalanceTest(T0TestBase): """ Verify the load-balance of l3 """ @@ -64,7 +64,7 @@ def load_balance_on_src_ip(self): send_packet(self, 21, pkt1) verify_packet_any_port(self, exp_pkt1, [17, 18]) - send_packet(self, 21, pkt) + send_packet(self, 21, pkt2) verify_packet_any_port(self, exp_pkt2, [17, 18]) def runTest(self): From c6c4757bed0e45a0df6e67f24531d1820177665e Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Wed, 29 Jun 2022 13:36:26 +0000 Subject: [PATCH 10/20] fix a config error in lag Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index 1a253c387..5b8e8b3c1 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -54,7 +54,7 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): lag_id=lag2.lag_id, ip_addr=ip_addr2, mac_addr=mac_addr2, - port_id=21) + port_id=22) if not hasattr(test_obj, 'lags'): test_obj.lags = {} @@ -95,6 +95,7 @@ def create_lag(self, lag_port_idxs): lag = Lag() lag_id = sai_thrift_create_lag(self.client) lag_members = self.create_lag_member(lag_id, lag_port_idxs) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) lag.lag_id = lag_id lag.lag_members = lag_members return lag @@ -116,6 +117,7 @@ def create_lag_member(self, lag_id, lag_port_idxs): lag_member = sai_thrift_create_lag_member(self.client, lag_id=lag_id, port_id=self.test_obj.port_list[port_index]) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) lag_members.append(lag_member) return lag_members @@ -126,7 +128,7 @@ def set_lag_hash_algorithm(self, algo=SAI_HASH_ALGORITHM_CRC): Args: algo (int): hash algorithm id """ - sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=True) + sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=algo) def set_lag_hash_attribute(self): """ From a6d182d59c799a0b9bfcd61d65d12d9478629284 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Thu, 30 Jun 2022 08:31:46 +0000 Subject: [PATCH 11/20] add lag lb test based on scr port Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_lag_test.py | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 3d4b07e0d..8fa18b825 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -73,3 +73,48 @@ def runTest(self): self.load_balance_on_src_ip() finally: pass + +class LoadbalanceOnSrcPortTest(T0TestBase): + """ + Test load balance of l3 by source port. + """ + def setUp(self): + T0TestBase.setUp(self) + + def runTest(self): + try: + print("Lag l3 load balancing based on src port") + eth_src = '00:22:22:22:22:22' + eth_dst = '00:77:66:55:44:00' + ip_src = '192.168.0.1' + ip_dst = '10.10.10.1' + + max_itrs = 150 + begin_port = 2000 + rcv_count = [0, 0] + for i in range(0, max_itrs): + src_port = begin_port + i + pkt = simple_tcp_packet(eth_dst=eth_dst, + eth_src=eth_src, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=64) + exp_pkt = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=eth_dst, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=64) + send_packet(self, 21, pkt) + rcv_idx, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) + print('src_port={}, rcv_port={}'.format(src_port, rcv_idx)) + rcv_count[rcv_idx%17] += 1 + + print(rcv_count) + for i in range(0, 2): + self.assertTrue((rcv_count[i] >= (max_itrs * 0.8)), "Not all paths are equally balanced") + finally: + pass From 2376ca912102f009efb0a89a8e00aa5a540ee3e3 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Thu, 30 Jun 2022 08:49:24 +0000 Subject: [PATCH 12/20] fix Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_lag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 8fa18b825..f86f687f1 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -116,5 +116,5 @@ def runTest(self): print(rcv_count) for i in range(0, 2): self.assertTrue((rcv_count[i] >= (max_itrs * 0.8)), "Not all paths are equally balanced") - finally: - pass + finally: + pass From 86aaa93c2128a7992e7d92f7625fbd8cd966d0ff Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Thu, 30 Jun 2022 09:25:00 +0000 Subject: [PATCH 13/20] set lag v4 hash Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 25 ++++++++++++++++++++++++- test/sai_test/sai_lag_test.py | 8 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index 5b8e8b3c1..edb9170e7 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -62,7 +62,8 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): test_obj.lags.update({key: lags[key]}) lag_configer.set_lag_hash_algorithm() - lag_configer.set_lag_hash_attribute() + lag_configer.setup_lag_v4_hash() + # lag_configer.set_lag_hash_attribute() lag_configer.set_lag_hash_seed() @@ -130,6 +131,28 @@ def set_lag_hash_algorithm(self, algo=SAI_HASH_ALGORITHM_CRC): """ sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=algo) + def setup_lag_v4_hash(self, hash_fields_list=None): + if hash_fields_list is None: + hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, + SAI_NATIVE_HASH_FIELD_DST_IP, + SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, + SAI_NATIVE_HASH_FIELD_L4_DST_PORT, + SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] + attr_list = sai_thrift_get_switch_attribute(self.client, lag_hash_ipv4=True) + lag_hash_ipv4 = attr_list['SAI_SWITCH_ATTR_LAG_HASH_IPV4'] + + if lag_hash_ipv4 == 0: + # create new hash + s32list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) + lag_hash_ipv4 = sai_thrift_create_hash(self.client, native_hash_field_list=s32list) + self.test_obj.assertTrue(lag_hash_ipv4 != 0, "Failed to create IPv4 lag hash") + sai_thrift_set_switch_attribute(self.client, lag_hash_ipv4=lag_hash_ipv4) + else: + # update existing hash + s32list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) + status = sai_thrift_set_hash_attribute(self.client, lag_hash_ipv4, native_hash_field_list=s32list) + self.test_obj.assertEqual(status, SAI_STATUS_SUCCESS) + def set_lag_hash_attribute(self): """ Set lag hash attributes. diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index f86f687f1..1322cdba0 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -107,14 +107,14 @@ def runTest(self): ip_src=ip_src, tcp_sport=src_port, ip_id=105, - ip_ttl=64) + ip_ttl=63) send_packet(self, 21, pkt) rcv_idx, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) print('src_port={}, rcv_port={}'.format(src_port, rcv_idx)) rcv_count[rcv_idx%17] += 1 - print(rcv_count) - for i in range(0, 2): - self.assertTrue((rcv_count[i] >= (max_itrs * 0.8)), "Not all paths are equally balanced") + print(rcv_count) + for i in range(0, 2): + self.assertTrue((rcv_count[i] >= ((max_itrs/2) * 0.8)), "Not all paths are equally balanced") finally: pass From 40a217e41fd256294fdc65709bba990a5095f308 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Fri, 1 Jul 2022 02:10:40 +0000 Subject: [PATCH 14/20] add lag disable egress test case Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 12 ++--- test/sai_test/sai_lag_test.py | 67 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index edb9170e7..cc699025f 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -29,15 +29,14 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): set the configuration in test directly. set the following test_obj attributes: - dict: lags - {lag id: lag object} + lag object """ lag_configer = LagConfiger(test_obj) - lags = {} if is_create_lag: lag1 = lag_configer.create_lag([17, 18]) - lags.update({lag1.lag_id: lag1}) + test_obj.lag1 = lag1 ip_addr1 = '10.10.10.0' mac_addr1 = '02:04:02:01:01:01' lag_configer.create_route_and_neighbor_entry_for_lag( @@ -47,7 +46,7 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): port_id=21) lag2 = lag_configer.create_lag([19, 20]) - lags.update({lag2.lag_id: lag2}) + test_obj.lag2 = lag2 ip_addr2 = '10.1.2.100' mac_addr2 = '02:04:02:01:02:01' lag_configer.create_route_and_neighbor_entry_for_lag( @@ -56,11 +55,6 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): mac_addr=mac_addr2, port_id=22) - if not hasattr(test_obj, 'lags'): - test_obj.lags = {} - for key in lags: - test_obj.lags.update({key: lags[key]}) - lag_configer.set_lag_hash_algorithm() lag_configer.setup_lag_v4_hash() # lag_configer.set_lag_hash_attribute() diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 1322cdba0..2b7966b68 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -118,3 +118,70 @@ def runTest(self): self.assertTrue((rcv_count[i] >= ((max_itrs/2) * 0.8)), "Not all paths are equally balanced") finally: pass + +class DisableEgressTest(T0TestBase): + def setUp(self): + T0TestBase.setUp(self) + + def runTest(self): + try: + print("Lag disable egress lag member test") + + eth_src = '00:22:22:22:22:22' + eth_dst = '00:77:66:55:44:00' + ip_src = '192.168.0.1' + ip_dst = '10.10.10.1' + + pkts_num = 10 + begin_port = 2000 + exp_drop = [] + for i in range(0, pkts_num): + src_port = begin_port + i + pkt = simple_tcp_packet(eth_dst=eth_dst, + eth_src=eth_src, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=64) + exp_pkt = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=eth_dst, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=63) + send_packet(self, 21, pkt) + rcv_idx, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) + if rcv_idx == 18: + exp_drop.append(src_port) + + # disable egress of lag member: port18 + print("disable port18 egress") + status = sai_thrift_set_lag_member_attribute(self.client, self.lag1.lag_members[1], egress_disable=True, ingress_disable=True) + self.assertEqual(status, SAI_STATUS_SUCCESS) + + for i in range(0, pkts_num): + src_port = begin_port + i + pkt = simple_tcp_packet(eth_dst=eth_dst, + eth_src=eth_src, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=64) + exp_pkt = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=eth_dst, + ip_dst=ip_dst, + ip_src=ip_src, + tcp_sport=src_port, + ip_id=105, + ip_ttl=63) + send_packet(self, 21, pkt) + if src_port in exp_drop: + # should drop + verify_no_packet(self, exp_pkt, 18) + else: + verify_packet(self, exp_pkt, 17) + finally: + pass From 80f8328b26210aff140afc2a318b4ed309115a05 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Fri, 1 Jul 2022 03:45:29 +0000 Subject: [PATCH 15/20] add IndifferenceIngressPortTest Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/sai_lag_test.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 2b7966b68..223233c2a 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -185,3 +185,37 @@ def runTest(self): verify_packet(self, exp_pkt, 17) finally: pass + +class IndifferenceIngressPortTest(T0TestBase): + def setUp(self): + T0TestBase.setUp(self) + + def runTest(self): + try: + eth_src = '00:22:22:22:22:22' + eth_dst = '00:77:66:55:44:00' + ip_src = '192.168.0.1' + ip_dst = '10.10.10.0' + + pkt = simple_tcp_packet(eth_dst=eth_dst, + eth_src=eth_src, + ip_dst=ip_dst, + ip_src=ip_src, + ip_id=105, + ip_ttl=64) + exp_pkt = simple_tcp_packet(eth_dst='02:04:02:01:01:01', + eth_src=eth_dst, + ip_dst=ip_dst, + ip_src=ip_src, + ip_id=105, + ip_ttl=63) + + exp_port = 0 + for i in range(1, 17): + send_packet(self, i, pkt) + if exp_port == 0: + exp_port, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) + else: + verify_packet(self, exp_pkt, exp_port) + finally: + pass From 9e30c0158276c76ea8a0e8594b863853fc989c20 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Sun, 3 Jul 2022 07:44:36 +0000 Subject: [PATCH 16/20] fix set hash function Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 32 ++++++---------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index cc699025f..442c126b0 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -57,7 +57,6 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): lag_configer.set_lag_hash_algorithm() lag_configer.setup_lag_v4_hash() - # lag_configer.set_lag_hash_attribute() lag_configer.set_lag_hash_seed() @@ -125,47 +124,27 @@ def set_lag_hash_algorithm(self, algo=SAI_HASH_ALGORITHM_CRC): """ sai_thrift_set_switch_attribute(self.client, lag_default_hash_algorithm=algo) - def setup_lag_v4_hash(self, hash_fields_list=None): + def setup_lag_v4_hash(self, hash_fields_list=None, lag_hash_ipv4=None): if hash_fields_list is None: hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, SAI_NATIVE_HASH_FIELD_DST_IP, SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, SAI_NATIVE_HASH_FIELD_L4_DST_PORT, SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] - attr_list = sai_thrift_get_switch_attribute(self.client, lag_hash_ipv4=True) - lag_hash_ipv4 = attr_list['SAI_SWITCH_ATTR_LAG_HASH_IPV4'] - if lag_hash_ipv4 == 0: + if lag_hash_ipv4 is None: # create new hash s32list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) lag_hash_ipv4 = sai_thrift_create_hash(self.client, native_hash_field_list=s32list) self.test_obj.assertTrue(lag_hash_ipv4 != 0, "Failed to create IPv4 lag hash") - sai_thrift_set_switch_attribute(self.client, lag_hash_ipv4=lag_hash_ipv4) + status = sai_thrift_set_switch_attribute(self.client, lag_hash_ipv4=lag_hash_ipv4) + self.test_obj.assertEqual(status, SAI_STATUS_SUCCESS) else: # update existing hash s32list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) status = sai_thrift_set_hash_attribute(self.client, lag_hash_ipv4, native_hash_field_list=s32list) self.test_obj.assertEqual(status, SAI_STATUS_SUCCESS) - def set_lag_hash_attribute(self): - """ - Set lag hash attributes. - - Args: - hash_fields_list: hash fields list - """ - attr_list = sai_thrift_get_switch_attribute(self.client, lag_hash=True) - lag_hash_id = attr_list['SAI_SWITCH_ATTR_LAG_HASH'] - - hash_fields_list = [SAI_NATIVE_HASH_FIELD_SRC_IP, - SAI_NATIVE_HASH_FIELD_DST_IP, - SAI_NATIVE_HASH_FIELD_IP_PROTOCOL, - SAI_NATIVE_HASH_FIELD_L4_DST_PORT, - SAI_NATIVE_HASH_FIELD_L4_SRC_PORT] - - hash_attr_list = sai_thrift_s32_list_t(count=len(hash_fields_list), int32list=hash_fields_list) - sai_thrift_set_hash_attribute(self.client, lag_hash_id, native_hash_field_list=hash_attr_list) - def set_lag_hash_seed(self, seed=400): """ Set lag hash seed. @@ -173,7 +152,8 @@ def set_lag_hash_seed(self, seed=400): Args: seed: hash seed value """ - sai_thrift_set_switch_attribute(self.client, lag_default_hash_seed=seed) + status = sai_thrift_set_switch_attribute(self.client, lag_default_hash_seed=seed) + self.test_obj.assertEqual(status, SAI_STATUS_SUCCESS) def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, port_id): vr_id = sai_thrift_create_virtual_router(self.client) From baa3cde6c990f05c16d8357da8f591f80d0bb0a4 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Sun, 3 Jul 2022 08:20:48 +0000 Subject: [PATCH 17/20] separate route configuration from lag Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 21 +------- test/sai_test/config/route_configer.py | 70 ++++++++++++++++++++++++++ test/sai_test/sai_test_base.py | 8 +++ 3 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 test/sai_test/config/route_configer.py diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index 442c126b0..7b7dddbca 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -35,25 +35,8 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): lag_configer = LagConfiger(test_obj) if is_create_lag: - lag1 = lag_configer.create_lag([17, 18]) - test_obj.lag1 = lag1 - ip_addr1 = '10.10.10.0' - mac_addr1 = '02:04:02:01:01:01' - lag_configer.create_route_and_neighbor_entry_for_lag( - lag_id=lag1.lag_id, - ip_addr=ip_addr1, - mac_addr=mac_addr1, - port_id=21) - - lag2 = lag_configer.create_lag([19, 20]) - test_obj.lag2 = lag2 - ip_addr2 = '10.1.2.100' - mac_addr2 = '02:04:02:01:02:01' - lag_configer.create_route_and_neighbor_entry_for_lag( - lag_id=lag2.lag_id, - ip_addr=ip_addr2, - mac_addr=mac_addr2, - port_id=22) + test_obj.lag1 = lag_configer.create_lag([17, 18]) + test_obj.lag2 = lag_configer.create_lag([19, 20]) lag_configer.set_lag_hash_algorithm() lag_configer.setup_lag_v4_hash() diff --git a/test/sai_test/config/route_configer.py b/test/sai_test/config/route_configer.py new file mode 100644 index 000000000..64bdc3fc7 --- /dev/null +++ b/test/sai_test/config/route_configer.py @@ -0,0 +1,70 @@ +# Copyright (c) 2021 Microsoft Open Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# Microsoft would like to thank the following companies for their review and +# assistance with these files: Intel Corporation, Mellanox Technologies Ltd, +# Dell Products, L.P., Facebook, Inc., Marvell International Ltd. +# +# + + +from sai_thrift.sai_adapter import * +from sai_utils import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] + +def t0_route_config_helper(test_obj, is_create_route_for_lag=True): + route_configer = RouteConfiger(test_obj) + + if is_create_route_for_lag: + ip_addr1 = '10.10.10.0' + mac_addr1 = '02:04:02:01:01:01' + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr1, port_id=test_obj.lag1.lag_id) + + ip_addr2 = '10.1.2.100' + mac_addr2 = '02:04:02:01:02:01' + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr2, port_id=test_obj.lag2.lag_id) + +class RouteConfiger(object): + """ + Class use to make all the route configurations. + """ + + def __init__(self, test_obj) -> None: + """ + Init Route configer. + + Args: + test_obj: the test object + """ + self.test_obj = test_obj + self.client = test_obj.client + + def get_default_virtual_router_id(self): + print("Get default router id") + def_attr = sai_thrift_get_switch_attribute(self.client, default_virtual_router_id=True) + + self.test_obj.assertNotEqual(def_attr["SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID"], 0) + return def_attr["SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID"] + + def create_route_and_neighbor_entry_for_port(self, ip_addr, mac_addr, port_id, virtual_router_id=None): + if virtual_router_id is None: + virtual_router_id = self.get_default_virtual_router_id() + + rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) + + nbr_entry_v4 = sai_thrift_neighbor_entry_t(rif_id=rif_id1, ip_address=sai_ipaddress(ip_addr)) + sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) + + nhop = sai_thrift_create_next_hop(self.client, ip=sai_ipaddress(ip_addr), router_interface_id=rif_id1, type=SAI_NEXT_HOP_TYPE_IP) + route1 =sai_thrift_route_entry_t(vr_id=router_id, destination=sai_ipprefix(ip_addr+'/24')) + sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) diff --git a/test/sai_test/sai_test_base.py b/test/sai_test/sai_test_base.py index 16971ea07..8826affe6 100644 --- a/test/sai_test/sai_test_base.py +++ b/test/sai_test/sai_test_base.py @@ -43,6 +43,8 @@ from config.fdb_configer import FdbConfiger from config.lag_configer import t0_lag_config_helper from config.lag_configer import LagConfiger +from config.route_configer import t0_route_config_helper +from config.route_configer import RouteConfiger THRIFT_PORT = 9092 is_configured = False @@ -193,6 +195,7 @@ def setUp(self, is_create_vlan=True, is_create_fdb=True, is_create_lag=True, + is_create_route_for_lag=True, wait_sec=5): super(T0TestBase, self).setUp() self.port_configer = PortConfiger(self) @@ -200,6 +203,7 @@ def setUp(self, self.fdb_configer = FdbConfiger(self) self.vlan_configer = VlanConfiger(self) self.lag_configer = LagConfiger(self) + self.route_configer = RouteConfiger(self) if force_config or not is_configured: t0_switch_config_helper(self) @@ -217,6 +221,10 @@ def setUp(self, t0_lag_config_helper( test_obj=self, is_create_lag=is_create_lag) + t0_route_config_helper( + test_obj=self, + is_create_route_for_lag=is_create_route_for_lag) + print("Waiting for switch to get ready before test, {} seconds ...".format( wait_sec)) time.sleep(wait_sec) From bfa71cbc216e306c4ff79c5ac0e1ec8c671a158c Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Mon, 4 Jul 2022 07:07:05 +0000 Subject: [PATCH 18/20] disable setting lag hash Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/lag_configer.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/test/sai_test/config/lag_configer.py b/test/sai_test/config/lag_configer.py index 7b7dddbca..05828bfc7 100644 --- a/test/sai_test/config/lag_configer.py +++ b/test/sai_test/config/lag_configer.py @@ -38,9 +38,11 @@ def t0_lag_config_helper(test_obj, is_create_lag=True): test_obj.lag1 = lag_configer.create_lag([17, 18]) test_obj.lag2 = lag_configer.create_lag([19, 20]) + """ lag_configer.set_lag_hash_algorithm() lag_configer.setup_lag_v4_hash() lag_configer.set_lag_hash_seed() + """ class LagConfiger(object): @@ -138,20 +140,6 @@ def set_lag_hash_seed(self, seed=400): status = sai_thrift_set_switch_attribute(self.client, lag_default_hash_seed=seed) self.test_obj.assertEqual(status, SAI_STATUS_SUCCESS) - def create_route_and_neighbor_entry_for_lag(self, lag_id, ip_addr, mac_addr, port_id): - vr_id = sai_thrift_create_virtual_router(self.client) - port2 = self.test_obj.port_list[port_id] - - rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=lag_id) - rif_id2 = sai_thrift_create_router_interface(self.client, virtual_router_id=vr_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port2) - - nbr_entry_v4 = sai_thrift_neighbor_entry_t(rif_id=rif_id1, ip_address=sai_ipaddress(ip_addr)) - sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) - - nhop = sai_thrift_create_next_hop(self.client, ip=sai_ipaddress(ip_addr), router_interface_id=rif_id1, type=SAI_NEXT_HOP_TYPE_IP) - route1 = sai_thrift_route_entry_t(vr_id=vr_id, destination=sai_ipprefix(ip_addr+'/24')) - sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) - def remove_lag_member(self, lag_member): sai_thrift_remove_lag_member(self, lag_member) From c9052950b4578534f7ef90145e5b781dade88de7 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Mon, 4 Jul 2022 08:04:45 +0000 Subject: [PATCH 19/20] add virtual interface Signed-off-by: Ziting Guo Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/route_configer.py | 15 +++++++--- test/sai_test/sai_lag_test.py | 38 +++++++++++++++++--------- test/sai_test/sai_test_base.py | 2 ++ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/test/sai_test/config/route_configer.py b/test/sai_test/config/route_configer.py index 64bdc3fc7..ac79eddae 100644 --- a/test/sai_test/config/route_configer.py +++ b/test/sai_test/config/route_configer.py @@ -24,15 +24,19 @@ def t0_route_config_helper(test_obj, is_create_route_for_lag=True): route_configer = RouteConfiger(test_obj) + vr_id = route_configer.create_vr_id() + # default_virtual_router_id = route_configer.get_default_virtual_router_id() if is_create_route_for_lag: ip_addr1 = '10.10.10.0' mac_addr1 = '02:04:02:01:01:01' - route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr1, port_id=test_obj.lag1.lag_id) + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr1, port_id=test_obj.lag1.lag_id, virtual_router_id=vr_id) ip_addr2 = '10.1.2.100' mac_addr2 = '02:04:02:01:02:01' - route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr2, port_id=test_obj.lag2.lag_id) + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr2, port_id=test_obj.lag2.lag_id, virtual_router_id=vr_id) + + test_obj.default_virtual_router_id = vr_id class RouteConfiger(object): """ @@ -49,6 +53,9 @@ def __init__(self, test_obj) -> None: self.test_obj = test_obj self.client = test_obj.client + def create_vr_id(self): + return sai_thrift_create_virtual_router(self.client) + def get_default_virtual_router_id(self): print("Get default router id") def_attr = sai_thrift_get_switch_attribute(self.client, default_virtual_router_id=True) @@ -60,11 +67,11 @@ def create_route_and_neighbor_entry_for_port(self, ip_addr, mac_addr, port_id, v if virtual_router_id is None: virtual_router_id = self.get_default_virtual_router_id() - rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) + rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) nbr_entry_v4 = sai_thrift_neighbor_entry_t(rif_id=rif_id1, ip_address=sai_ipaddress(ip_addr)) sai_thrift_create_neighbor_entry(self.client, nbr_entry_v4, dst_mac_address=mac_addr) nhop = sai_thrift_create_next_hop(self.client, ip=sai_ipaddress(ip_addr), router_interface_id=rif_id1, type=SAI_NEXT_HOP_TYPE_IP) - route1 =sai_thrift_route_entry_t(vr_id=router_id, destination=sai_ipprefix(ip_addr+'/24')) + route1 =sai_thrift_route_entry_t(vr_id=virtual_router_id, destination=sai_ipprefix(ip_addr+'/24')) sai_thrift_create_route_entry(self.client, route1, next_hop_id=nhop) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 223233c2a..46dc30553 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -21,7 +21,7 @@ from sai_test_base import T0TestBase from sai_utils import * -class LagLoadBalanceTest(T0TestBase): +class LagConfigTest(T0TestBase): """ Verify the load-balance of l3 """ @@ -33,6 +33,7 @@ def setUp(self): T0TestBase.setUp(self) def load_balance_on_src_ip(self): + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) router_mac = '00:77:66:55:44:00' ip_src1 = '192.168.0.1' ip_src2 = '192.168.0.2' @@ -69,7 +70,6 @@ def load_balance_on_src_ip(self): def runTest(self): try: - print("simple lag test") self.load_balance_on_src_ip() finally: pass @@ -83,7 +83,8 @@ def setUp(self): def runTest(self): try: - print("Lag l3 load balancing based on src port") + print("Lag l3 load balancing test based on src port") + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' @@ -111,7 +112,7 @@ def runTest(self): send_packet(self, 21, pkt) rcv_idx, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) print('src_port={}, rcv_port={}'.format(src_port, rcv_idx)) - rcv_count[rcv_idx%17] += 1 + rcv_count[rcv_idx] += 1 print(rcv_count) for i in range(0, 2): @@ -119,14 +120,18 @@ def runTest(self): finally: pass + class DisableEgressTest(T0TestBase): + """ + When disable egress on a lag member, we expect traffic drop on the disabled lag member. + """ def setUp(self): T0TestBase.setUp(self) def runTest(self): try: print("Lag disable egress lag member test") - + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' @@ -158,7 +163,7 @@ def runTest(self): # disable egress of lag member: port18 print("disable port18 egress") - status = sai_thrift_set_lag_member_attribute(self.client, self.lag1.lag_members[1], egress_disable=True, ingress_disable=True) + status = sai_thrift_set_lag_member_attribute(self.client, self.lag1.lag_members[1], egress_disable=True) self.assertEqual(status, SAI_STATUS_SUCCESS) for i in range(0, pkts_num): @@ -179,23 +184,29 @@ def runTest(self): ip_ttl=63) send_packet(self, 21, pkt) if src_port in exp_drop: - # should drop verify_no_packet(self, exp_pkt, 18) else: verify_packet(self, exp_pkt, 17) finally: pass + class IndifferenceIngressPortTest(T0TestBase): + """ + Verify the ingress ports should not be as a hash factor in lag load balance. + Forwarding the same packet from different ingress ports, if only the ingress + port changed, the load balance should not happen among lag members. + """ def setUp(self): T0TestBase.setUp(self) def runTest(self): try: + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_VLAN, vlan_id=10) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' - ip_dst = '10.10.10.0' + ip_dst = '10.10.10.1' pkt = simple_tcp_packet(eth_dst=eth_dst, eth_src=eth_src, @@ -210,12 +221,13 @@ def runTest(self): ip_id=105, ip_ttl=63) - exp_port = 0 - for i in range(1, 17): + exp_port_idx = -1 + exp_port_list = [17, 18] + for i in range(1, 9): send_packet(self, i, pkt) - if exp_port == 0: - exp_port, _ = verify_packet_any_port(self, exp_pkt, [17, 18]) + if exp_port_idx == -1: + exp_port_idx, _ = verify_packet_any_port(self, exp_pkt, exp_port_list) else: - verify_packet(self, exp_pkt, exp_port) + verify_packet(self, exp_pkt, exp_port_list[exp_port_idx]) finally: pass diff --git a/test/sai_test/sai_test_base.py b/test/sai_test/sai_test_base.py index 8826affe6..c05987283 100644 --- a/test/sai_test/sai_test_base.py +++ b/test/sai_test/sai_test_base.py @@ -185,6 +185,8 @@ class T0TestBase(ThriftInterfaceDataPlane): self.active_ports_no - number of active ports self.port_list - list of all active port objects self.portX objects for all active ports (where X is a port number) + self.lagX objects for all lag + self.default_virtual_router_id """ def setUp(self, From bd251c0759a6c98a7353ab01bde3cbb9d61b6cb2 Mon Sep 17 00:00:00 2001 From: zitingguo <736034564@qq.com> Date: Tue, 5 Jul 2022 06:49:32 +0000 Subject: [PATCH 20/20] Config default v4&v6 route Signed-off-by: zitingguo <736034564@qq.com> --- test/sai_test/config/route_configer.py | 91 +++++++++++++++++++++----- test/sai_test/sai_lag_test.py | 8 +-- test/sai_test/sai_test_base.py | 10 ++- 3 files changed, 88 insertions(+), 21 deletions(-) diff --git a/test/sai_test/config/route_configer.py b/test/sai_test/config/route_configer.py index ac79eddae..94d01fcef 100644 --- a/test/sai_test/config/route_configer.py +++ b/test/sai_test/config/route_configer.py @@ -22,21 +22,27 @@ from sai_thrift.sai_adapter import * from sai_utils import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] -def t0_route_config_helper(test_obj, is_create_route_for_lag=True): +def t0_route_config_helper(test_obj, is_create_route=True, is_create_route_for_lag=True): route_configer = RouteConfiger(test_obj) - vr_id = route_configer.create_vr_id() - # default_virtual_router_id = route_configer.get_default_virtual_router_id() + + if is_create_route: + route_configer.create_default_route() if is_create_route_for_lag: ip_addr1 = '10.10.10.0' mac_addr1 = '02:04:02:01:01:01' - route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr1, port_id=test_obj.lag1.lag_id, virtual_router_id=vr_id) + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, + mac_addr=mac_addr1, + port_id=test_obj.lag1.lag_id, + virtual_router_id=test_obj.default_vrf) ip_addr2 = '10.1.2.100' mac_addr2 = '02:04:02:01:02:01' - route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, mac_addr=mac_addr2, port_id=test_obj.lag2.lag_id, virtual_router_id=vr_id) + route_configer.create_route_and_neighbor_entry_for_port(ip_addr=ip_addr1, + mac_addr=mac_addr2, + port_id=test_obj.lag2.lag_id, + virtual_router_id=test_obj.default_vrf) - test_obj.default_virtual_router_id = vr_id class RouteConfiger(object): """ @@ -52,20 +58,75 @@ def __init__(self, test_obj) -> None: """ self.test_obj = test_obj self.client = test_obj.client + + def create_default_route(self): + self.create_default_route_intf() + self.create_default_v4_v6_route_entry() + self.create_local_v6_route() - def create_vr_id(self): - return sai_thrift_create_virtual_router(self.client) + def create_default_route_intf(self): + """ + Create default route interface on loop back interface. + """ + print("Create loop back interface...") + attr = sai_thrift_get_switch_attribute(self.client, default_virtual_router_id=True) + self.test_obj.assertNotEqual(attr['default_virtual_router_id'], 0) + self.test_obj.default_vrf = attr['default_virtual_router_id'] - def get_default_virtual_router_id(self): - print("Get default router id") - def_attr = sai_thrift_get_switch_attribute(self.client, default_virtual_router_id=True) - - self.test_obj.assertNotEqual(def_attr["SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID"], 0) - return def_attr["SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID"] + self.test_obj.loopback_intf = sai_thrift_create_router_interface(self.client, + type=SAI_ROUTER_INTERFACE_TYPE_LOOPBACK, virtual_router_id=self.test_obj.default_vrf) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) + + def create_default_v4_v6_route_entry(self): + """ + Create default v4 and v6 route entry. + """ + + print("Create default v4&v6 route entry...") + v6_default = sai_thrift_ip_prefix_t(addr_family=1, + addr=sai_thrift_ip_addr_t(ip6=DEFAULT_IP_V6_PREFIX), + mask=sai_thrift_ip_addr_t(ip6=DEFAULT_IP_V6_PREFIX)) + entry = sai_thrift_route_entry_t(vr_id=self.test_obj.default_vrf, + destination=v6_default) + self.test_obj.default_ipv6_route_entry = sai_thrift_create_route_entry( + self.client, + route_entry=entry, + packet_action=SAI_PACKET_ACTION_DROP) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) + + entry = sai_thrift_route_entry_t(vr_id=self.test_obj.default_vrf, + destination=sai_ipprefix(DEFAULT_IP_V4_PREFIX)) + self.test_obj.default_ipv4_route_entry = sai_thrift_create_route_entry( + self.client, + route_entry=entry, + packet_action=SAI_PACKET_ACTION_DROP) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) + + def create_local_v6_route(self): + """ + Create local v6 route base on the configuration of the actual switch. + """ + + print("Create local v6 route...") + entry = sai_thrift_route_entry_t(vr_id=self.test_obj.default_vrf, + destination=sai_ipprefix(LOCAL_IP_10V6_PREFIX)) + self.test_obj.local_10v6_route_entry = sai_thrift_create_route_entry( + self.client, + route_entry=entry, + packet_action=SAI_PACKET_ACTION_FORWARD) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) + + entry = sai_thrift_route_entry_t(vr_id=self.test_obj.default_vrf, + destination=sai_ipprefix(LOCAL_IP_128V6_PREFIX)) + self.test_obj.local_128v6_route_entry = sai_thrift_create_route_entry( + self.client, + route_entry=entry, + packet_action=SAI_PACKET_ACTION_FORWARD) + self.test_obj.assertEqual(self.test_obj.status(), SAI_STATUS_SUCCESS) def create_route_and_neighbor_entry_for_port(self, ip_addr, mac_addr, port_id, virtual_router_id=None): if virtual_router_id is None: - virtual_router_id = self.get_default_virtual_router_id() + virtual_router_id = self.test_obj.default_vrf rif_id1 = sai_thrift_create_router_interface(self.client, virtual_router_id=virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=port_id) diff --git a/test/sai_test/sai_lag_test.py b/test/sai_test/sai_lag_test.py index 46dc30553..653bd3a03 100644 --- a/test/sai_test/sai_lag_test.py +++ b/test/sai_test/sai_lag_test.py @@ -33,7 +33,7 @@ def setUp(self): T0TestBase.setUp(self) def load_balance_on_src_ip(self): - sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_vrf, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) router_mac = '00:77:66:55:44:00' ip_src1 = '192.168.0.1' ip_src2 = '192.168.0.2' @@ -84,7 +84,7 @@ def setUp(self): def runTest(self): try: print("Lag l3 load balancing test based on src port") - sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_vrf, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' @@ -131,7 +131,7 @@ def setUp(self): def runTest(self): try: print("Lag disable egress lag member test") - sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_vrf, type=SAI_ROUTER_INTERFACE_TYPE_PORT, port_id=self.port_list[21]) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' @@ -202,7 +202,7 @@ def setUp(self): def runTest(self): try: - sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_virtual_router_id, type=SAI_ROUTER_INTERFACE_TYPE_VLAN, vlan_id=10) + sai_thrift_create_router_interface(self.client, virtual_router_id=self.default_vrf, type=SAI_ROUTER_INTERFACE_TYPE_VLAN, vlan_id=10) eth_src = '00:22:22:22:22:22' eth_dst = '00:77:66:55:44:00' ip_src = '192.168.0.1' diff --git a/test/sai_test/sai_test_base.py b/test/sai_test/sai_test_base.py index c05987283..ebed801b6 100644 --- a/test/sai_test/sai_test_base.py +++ b/test/sai_test/sai_test_base.py @@ -180,13 +180,17 @@ class T0TestBase(ThriftInterfaceDataPlane): Set the following class attributes: self.default_vlan_id self.default_vrf + self.lookback_intf + self.default_ipv4_route_entry + self.default_ipv6_route_entry + self.local_10v6_route_entry + self.local_128v6_route_entry self.default_1q_bridge self.cpu_port_hdl self.active_ports_no - number of active ports self.port_list - list of all active port objects self.portX objects for all active ports (where X is a port number) self.lagX objects for all lag - self.default_virtual_router_id """ def setUp(self, @@ -196,6 +200,7 @@ def setUp(self, is_reset_default_vlan=True, is_create_vlan=True, is_create_fdb=True, + is_create_route=True, is_create_lag=True, is_create_route_for_lag=True, wait_sec=5): @@ -204,8 +209,8 @@ def setUp(self, self.switch_configer = SwitchConfiger(self) self.fdb_configer = FdbConfiger(self) self.vlan_configer = VlanConfiger(self) - self.lag_configer = LagConfiger(self) self.route_configer = RouteConfiger(self) + self.lag_configer = LagConfiger(self) if force_config or not is_configured: t0_switch_config_helper(self) @@ -225,6 +230,7 @@ def setUp(self, is_create_lag=is_create_lag) t0_route_config_helper( test_obj=self, + is_create_route=is_create_route, is_create_route_for_lag=is_create_route_for_lag) print("Waiting for switch to get ready before test, {} seconds ...".format(