Exemple #1
0
    def check_mtu_and_interfaces(self, duthost):
        logger.info("Verify that MAC address fits template XX:XX:XX:XX:XX:XX")
        mac = duthost.shell(
            "redis-cli -n 4 hget 'DEVICE_METADATA|localhost' mac| grep -io '[0-9a-fA-F:]\{17\}'",
            module_ignore_errors=True)['stdout']
        logger.info("DUT MAC is {}".format(mac))

        if not mac:
            pytest.fail("MAC entry does not exist")

        logger.info("Verify interfaces are UP and MTU == 9100")
        checks.check_interfaces(duthost)

        cfg_facts = duthost.config_facts(host=duthost.hostname,
                                         source="persistent")['ansible_facts']
        non_default_ports = [
            k for k, v in cfg_facts["PORT"].items()
            if "mtu" in v and v["mtu"] != "9100" and "admin_status" in v
            and v["admin_status"] == "up"
        ]
        non_default_portchannel = [
            k for k, v in cfg_facts["PORTCHANNEL"].items()
            if "mtu" in v and v["mtu"] != "9100" and "admin_status" in v
            and v["admin_status"] == "up"
        ]

        if len(non_default_ports) != 0 or len(non_default_portchannel) != 0:
            pytest.fail(
                "There are ports/portchannel with non default MTU:\nPorts: {}\nPortchannel: {}"
                .format(non_default_ports, non_default_portchannel))
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)
Exemple #3
0
    def check_interfaces_and_transceivers(self):
        """
        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("Check whether transceiver information of all ports are in redis")
        xcvr_info = self.duthost.command("redis-cli -n 6 keys TRANSCEIVER_INFO*")
        parsed_xcvr_info = parse_transceiver_info(xcvr_info["stdout_lines"])
        interfaces = self.conn_graph_facts["device_conn"]
        for intf in interfaces:
            if intf not in parsed_xcvr_info:
                raise ContinuousRebootError("TRANSCEIVER INFO of {} is not found in DB".format(intf))

        logging.info("Check if all the interfaces are operational")
        result = checks.check_interfaces(self.duthost)
        if result["failed"]:
            raise ContinuousRebootError("Interface check failed, not all interfaces are up")