diff --git a/tests/cacl/test_cacl_application.py b/tests/cacl/test_cacl_application.py index 55acc40ab2e..03d99c4e5da 100644 --- a/tests/cacl/test_cacl_application.py +++ b/tests/cacl/test_cacl_application.py @@ -403,7 +403,7 @@ def verify_cacl(duthost, localhost, creds, docker_network, asic_index = None): expected_iptables_rules, expected_ip6tables_rules = generate_expected_rules(duthost, docker_network, asic_index) - stdout = duthost.get_asic(asic_index).command("iptables -S")["stdout"] + stdout = duthost.get_asic_or_sonic_host(asic_index).command("iptables -S")["stdout"] actual_iptables_rules = stdout.strip().split("\n") # Ensure all expected iptables rules are present on the DuT @@ -422,7 +422,7 @@ def verify_cacl(duthost, localhost, creds, docker_network, asic_index = None): #for i in range(len(expected_iptables_rules)): # pytest_assert(actual_iptables_rules[i] == expected_iptables_rules[i], "iptables rules not in expected order") - stdout = duthost.get_asic(asic_index).command("ip6tables -S")["stdout"] + stdout = duthost.get_asic_or_sonic_host(asic_index).command("ip6tables -S")["stdout"] actual_ip6tables_rules = stdout.strip().split("\n") # Ensure all expected ip6tables rules are present on the DuT @@ -444,7 +444,7 @@ def verify_cacl(duthost, localhost, creds, docker_network, asic_index = None): def verify_nat_cacl(duthost, localhost, creds, docker_network, asic_index): expected_iptables_rules, expected_ip6tables_rules = generate_nat_expected_rules(duthost, docker_network, asic_index) - stdout = duthost.get_asic(asic_index).command("iptables -t nat -S")["stdout"] + stdout = duthost.get_asic_or_sonic_host(asic_index).command("iptables -t nat -S")["stdout"] actual_iptables_rules = stdout.strip().split("\n") # Ensure all expected iptables rules are present on the DuT @@ -455,7 +455,7 @@ def verify_nat_cacl(duthost, localhost, creds, docker_network, asic_index): unexpected_iptables_rules = set(actual_iptables_rules) - set(expected_iptables_rules) pytest_assert(len(unexpected_iptables_rules) == 0, "Unexpected iptables nat rules: {}".format(repr(unexpected_iptables_rules))) - stdout = duthost.get_asic(asic_index).command("ip6tables -t nat -S")["stdout"] + stdout = duthost.get_asic_or_sonic_host(asic_index).command("ip6tables -t nat -S")["stdout"] actual_ip6tables_rules = stdout.strip().split("\n") # Ensure all expected ip6tables rules are present on the DuT diff --git a/tests/common/devices/multi_asic.py b/tests/common/devices/multi_asic.py index 954145a027f..054d81157de 100644 --- a/tests/common/devices/multi_asic.py +++ b/tests/common/devices/multi_asic.py @@ -195,7 +195,7 @@ def __getattr__(self, attr): else: return getattr(self.sonichost, attr) # For backward compatibility - def get_asic(self, asic_id): + def get_asic_or_sonic_host(self, asic_id): if asic_id == DEFAULT_ASIC_ID: return self.sonichost return self.asics[asic_id] diff --git a/tests/common/devices/sonic_asic.py b/tests/common/devices/sonic_asic.py index 81ccaae34b8..1e13f0c859c 100644 --- a/tests/common/devices/sonic_asic.py +++ b/tests/common/devices/sonic_asic.py @@ -53,10 +53,6 @@ def get_critical_services(self): service, self.asic_index if self.sonichost.is_multi_asic else "")) return a_service - def get_service_name(self, service): - service_name = "{}{}".format(service, "@{}".format(self.asic_index) if self.sonichost.is_multi_asic else "") - return service_name - def is_it_frontend(self): if self.sonichost.is_multi_asic: sub_role_cmd = 'sudo sonic-cfggen -d -v DEVICE_METADATA.localhost.sub_role -n {}'.format(self.namespace) diff --git a/tests/common/platform/interface_utils.py b/tests/common/platform/interface_utils.py index 061facb97d8..5e758cb9be3 100644 --- a/tests/common/platform/interface_utils.py +++ b/tests/common/platform/interface_utils.py @@ -39,7 +39,7 @@ def check_interface_status(dut, asic_index, interfaces, xcvr_skip_list): @param dut: The AnsibleHost object of DUT. For interacting with DUT. @param interfaces: List of interfaces that need to be checked. """ - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) namespace = asichost.get_asic_namespace() logging.info("Check interface status using cmd 'show interface'") #TODO Remove this logic when minigraph facts supports namespace in multi_asic diff --git a/tests/common/platform/transceiver_utils.py b/tests/common/platform/transceiver_utils.py index 6cedabb9ba6..2d7582dbddf 100644 --- a/tests/common/platform/transceiver_utils.py +++ b/tests/common/platform/transceiver_utils.py @@ -42,7 +42,7 @@ def all_transceivers_detected(dut, asic_index, interfaces, xcvr_skip_list): Check if transceiver information of all the specified interfaces have been detected. """ cmd = "redis-cli --raw -n 6 keys TRANSCEIVER_INFO\*" - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) docker_cmd = asichost.get_docker_cmd(cmd, "database") db_output = dut.command(docker_cmd)["stdout_lines"] not_detected_interfaces = [intf for intf in interfaces if "TRANSCEIVER_INFO|%s" % intf not in db_output] @@ -60,7 +60,7 @@ def check_transceiver_basic(dut, asic_index, interfaces, xcvr_skip_list): """ logging.info("Check whether transceiver information of all ports are in redis") cmd = "redis-cli -n 6 keys TRANSCEIVER_INFO*" - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) docker_cmd = asichost.get_docker_cmd(cmd, "database") xcvr_info = dut.command(docker_cmd) parsed_xcvr_info = parse_transceiver_info(xcvr_info["stdout_lines"]) @@ -75,7 +75,7 @@ def check_transceiver_details(dut, asic_index, interfaces, xcvr_skip_list): @param dut: The AnsibleHost object of DUT. For interacting with DUT. @param interfaces: List of interfaces that need to be checked. """ - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) logging.info("Check detailed transceiver information of each connected port") expected_fields = ["type", "hardware_rev", "serial", "manufacturer", "model"] for intf in interfaces: @@ -96,7 +96,7 @@ def check_transceiver_dom_sensor_basic(dut, asic_index, interfaces, xcvr_skip_li """ logging.info("Check whether TRANSCEIVER_DOM_SENSOR of all ports in redis") cmd = "redis-cli -n 6 keys TRANSCEIVER_DOM_SENSOR*" - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) docker_cmd = asichost.get_docker_cmd(cmd, "database") xcvr_dom_sensor = dut.command(docker_cmd) parsed_xcvr_dom_sensor = parse_transceiver_dom_sensor(xcvr_dom_sensor["stdout_lines"]) @@ -112,7 +112,7 @@ def check_transceiver_dom_sensor_details(dut, asic_index, interfaces, xcvr_skip_ @param interfaces: List of interfaces that need to be checked. """ logging.info("Check detailed TRANSCEIVER_DOM_SENSOR information of each connected ports") - asichost = dut.get_asic(asic_index) + asichost = dut.asic_instance(asic_index) expected_fields = ["temperature", "voltage", "rx1power", "rx2power", "rx3power", "rx4power", "tx1bias", "tx2bias", "tx3bias", "tx4bias", "tx1power", "tx2power", "tx3power", "tx4power"] for intf in interfaces: diff --git a/tests/platform_tests/sfp/test_sfputil.py b/tests/platform_tests/sfp/test_sfputil.py index 5e6863dcbef..b8e2e68eaa8 100644 --- a/tests/platform_tests/sfp/test_sfputil.py +++ b/tests/platform_tests/sfp/test_sfputil.py @@ -106,7 +106,7 @@ def test_check_sfputil_low_power_mode(duthosts, enum_rand_one_per_hwsku_frontend * sfputil lpmode on """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - asichost = duthost.get_asic(enum_frontend_asic_index) + asichost = duthost.asic_instance(enum_frontend_asic_index) # Get the interface pertaining to that asic portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index) diff --git a/tests/platform_tests/test_sequential_restart.py b/tests/platform_tests/test_sequential_restart.py index 52a2e0faab1..aae49c089f2 100644 --- a/tests/platform_tests/test_sequential_restart.py +++ b/tests/platform_tests/test_sequential_restart.py @@ -52,8 +52,8 @@ def restart_service_and_check(localhost, dut, enum_frontend_asic_index, service, """ logging.info("Restart the %s service on asic %s" %(service, enum_frontend_asic_index)) - asichost = dut.get_asic(enum_frontend_asic_index) - service_name = asichost.get_service_name(service) + asichost = dut.asic_instance(enum_frontend_asic_index) + service_name = asichost.get_docker_name(service) dut.command("sudo systemctl restart {}".format(service_name)) for container in dut.get_default_critical_services_list(): diff --git a/tests/route/test_default_route.py b/tests/route/test_default_route.py index 3a21568517f..4c8aef56945 100644 --- a/tests/route/test_default_route.py +++ b/tests/route/test_default_route.py @@ -16,7 +16,7 @@ def test_default_route_set_src(duthosts, enum_rand_one_per_hwsku_frontend_hostna """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - asichost = duthost.get_asic(enum_asic_index) + asichost = duthost.asic_instance(enum_asic_index) config_facts = asichost.config_facts(host=duthost.hostname, source="running")['ansible_facts'] @@ -52,7 +52,7 @@ def test_default_ipv6_route_next_hop_global_address(duthosts, enum_rand_one_per_ """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - asichost = duthost.get_asic(enum_asic_index) + asichost = duthost.asic_instance(enum_asic_index) rtinfo = asichost.get_ip_route_info(ipaddress.ip_network(u"::/0")) pytest_assert(rtinfo['nexthops'] > 0, "cannot find ipv6 nexthop for default route")