def test_reload_configuration(duthost, conn_graph_facts): """ @summary: This test case is to reload the configuration and check platform status """ interfaces = conn_graph_facts["device_conn"] asic_type = duthost.facts["asic_type"] logging.info("Reload configuration") duthost.shell("sudo config reload -y &>/dev/null", executable="/bin/bash") logging.info("Wait until all critical services are fully started") wait_critical_processes(duthost) logging.info("Wait some time for all the transceivers to be detected") assert wait_until(300, 20, check_interface_information, duthost, interfaces), \ "Not all transceivers are detected in 300 seconds" logging.info("Check transceiver status") check_transceiver_basic(duthost, interfaces) if asic_type in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(duthost) logging.info("Check sysfs") check_sysfs(duthost)
def restart_service_and_check(localhost, dut, service, interfaces): """ Restart specified service and check platform status """ logging.info("Restart the %s service" % service) dut.command("sudo systemctl restart %s" % service) logging.info("Wait until all critical services are fully started") wait_critical_processes(dut) logging.info("Wait some time for all the transceivers to be detected") pytest_assert( wait_until(300, 20, check_interface_information, dut, interfaces), "Not all interface information are detected within 300 seconds") logging.info("Check transceiver status") check_transceiver_basic(dut, interfaces) if dut.facts["asic_type"] in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(dut) logging.info("Check sysfs") check_sysfs(dut) logging.info("Check that critical processes are healthy for 60 seconds") check_critical_processes(dut, 60)
def check_interfaces_and_services(dut, interfaces, xcvr_skip_list, reboot_type=None): """ Perform a further check after reboot-cause, including transceiver status, interface status @param localhost: The Localhost object. @param dut: The AnsibleHost object of DUT. @param interfaces: DUT's interfaces defined by minigraph """ logging.info("Wait until all critical services are fully started") wait_critical_processes(dut) if reboot_type is not None: logging.info("Check reboot cause") assert wait_until(MAX_WAIT_TIME_FOR_REBOOT_CAUSE, 20, check_reboot_cause, dut, reboot_type), \ "got reboot-cause failed after rebooted by %s" % reboot_type if reboot_ctrl_dict[reboot_type]["test_reboot_cause_only"]: logging.info( "Further checking skipped for %s test which intends to verify reboot-cause only" % reboot_type) return if dut.is_supervisor_node(): logging.info("skipping interfaces related check for supervisor") else: logging.info( "Wait {} seconds for all the transceivers to be detected".format( MAX_WAIT_TIME_FOR_INTERFACES)) result = wait_until(MAX_WAIT_TIME_FOR_INTERFACES, 20, check_all_interface_information, dut, interfaces, xcvr_skip_list) assert result, "Not all transceivers are detected or interfaces are up in {} seconds".format( MAX_WAIT_TIME_FOR_INTERFACES) logging.info("Check transceiver status") for asic_index in dut.get_frontend_asic_ids(): # Get the interfaces pertaining to that asic interface_list = get_port_map(dut, asic_index) interfaces_per_asic = { k: v for k, v in interface_list.items() if k in interfaces } check_transceiver_basic(dut, asic_index, interfaces_per_asic, xcvr_skip_list) logging.info("Check pmon daemon status") assert check_pmon_daemon_status(dut), "Not all pmon daemons running." if dut.facts["asic_type"] in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(dut) logging.info("Check sysfs") check_sysfs(dut)
def restart_service_and_check(localhost, dut, enum_frontend_asic_index, service, interfaces, xcvr_skip_list): """ Restart specified service and check platform status """ logging.info("Restart the %s service on asic %s" % (service, enum_frontend_asic_index)) 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(): if is_service_hiting_start_limit(dut, container) is True: logging.info( "{} hits start limit and clear reset-failed flag".format( container)) dut.shell( "sudo systemctl reset-failed {}.service".format(container)) dut.shell("sudo systemctl start {}.service".format(container)) logging.info("Wait until all critical services are fully started") wait_critical_processes(dut) logging.info("Wait some time for all the transceivers to be detected") pytest_assert( wait_until(300, 20, check_interface_information, dut, enum_frontend_asic_index, interfaces, xcvr_skip_list), "Not all interface information are detected within 300 seconds") logging.info("Check transceiver status on asic %s" % enum_frontend_asic_index) check_transceiver_basic(dut, enum_frontend_asic_index, interfaces, xcvr_skip_list) if dut.facts["asic_type"] in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(dut) logging.info("Check sysfs") check_sysfs(dut) logging.info("Check that critical processes are healthy for 60 seconds") check_critical_processes(dut, 60)
def check_interfaces_and_transceivers(dut, interfaces): """ Perform a check of transceivers, LAGs and interfaces status @param dut: The AnsibleHost object of DUT. @param interfaces: DUT's interfaces defined by minigraph """ logging.info("Wait %d seconds for all the transceivers to be detected" % MAX_WAIT_TIME_FOR_INTERFACES) pytest_assert(wait_until(MAX_WAIT_TIME_FOR_INTERFACES, 20, check_interface_information, dut, interfaces), \ "Not all transceivers are detected or interfaces are up in %d seconds" % MAX_WAIT_TIME_FOR_INTERFACES) logging.info("Check transceiver status") check_transceiver_basic(dut, interfaces) logging.info("Check LAGs and interfaces status") checks.check_interfaces(dut)
def test_reload_configuration(duthosts, rand_one_dut_hostname, conn_graph_facts, xcvr_skip_list): """ @summary: This test case is to reload the configuration and check platform status """ duthost = duthosts[rand_one_dut_hostname] interfaces = conn_graph_facts["device_conn"][duthost.hostname] asic_type = duthost.facts["asic_type"] if config_force_option_supported(duthost): assert wait_until(300, 20, 0, config_system_checks_passed, duthost) logging.info("Reload configuration") duthost.shell("sudo config reload -y &>/dev/null", executable="/bin/bash") logging.info("Wait until all critical services are fully started") wait_critical_processes(duthost) logging.info("Wait some time for all the transceivers to be detected") assert wait_until(300, 20, 0, check_all_interface_information, duthost, interfaces, xcvr_skip_list), \ "Not all transceivers are detected in 300 seconds" logging.info("Check transceiver status") for asic_index in duthost.get_frontend_asic_ids(): # Get the interfaces pertaining to that asic interface_list = get_port_map(duthost, asic_index) interfaces_per_asic = { k: v for k, v in interface_list.items() if k in interfaces } check_transceiver_basic(duthost, asic_index, interfaces_per_asic, xcvr_skip_list) if asic_type in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(duthost) logging.info("Check sysfs") check_sysfs(duthost)
def check_interfaces_and_services(dut, interfaces, reboot_type=None): """ Perform a further check after reboot-cause, including transceiver status, interface status @param localhost: The Localhost object. @param dut: The AnsibleHost object of DUT. @param interfaces: DUT's interfaces defined by minigraph """ logging.info("Wait until all critical services are fully started") wait_critical_processes(dut) if reboot_type is not None: logging.info("Check reboot cause") assert wait_until(MAX_WAIT_TIME_FOR_REBOOT_CAUSE, 20, check_reboot_cause, dut, reboot_type), \ "got reboot-cause failed after rebooted by %s" % reboot_type if reboot_ctrl_dict[reboot_type]["test_reboot_cause_only"]: logging.info( "Further checking skipped for %s test which intends to verify reboot-cause only" % reboot_type) return logging.info("Wait %d seconds for all the transceivers to be detected" % MAX_WAIT_TIME_FOR_INTERFACES) assert wait_until(MAX_WAIT_TIME_FOR_INTERFACES, 20, check_interface_information, dut, interfaces), \ "Not all transceivers are detected or interfaces are up in %d seconds" % MAX_WAIT_TIME_FOR_INTERFACES logging.info("Check transceiver status") check_transceiver_basic(dut, interfaces) logging.info("Check pmon daemon status") assert check_pmon_daemon_status(dut), "Not all pmon daemons running." if dut.facts["asic_type"] in ["mellanox"]: from .mellanox.check_hw_mgmt_service import check_hw_management_service from .mellanox.check_sysfs import check_sysfs logging.info("Check the hw-management service") check_hw_management_service(dut) logging.info("Check sysfs") check_sysfs(dut)