Ejemplo n.º 1
0
    def _check(*args, **kwargs):
        """
        @summary: Checks if the OVS bridge mux simulator is functioning correctly
        @return: A dictionary containing the testing result of the PTF interface tested:
            {
                'check_item': 'mux_simulator',
                'failed': <True/False>,
                'failed_reason': <reason string>,
                'action': <recovery function>
            }
        """
        logger.info("Checking mux simulator status")
        results = {
            'failed': False,
            'failed_reason': '',
            'check_item': 'mux_simulator',
            'action': None
        }

        failed = False
        reason = ''

        check_passed, err_msg, dut_mux_status = _check_dut_mux_status(
            duthosts, duts_minigraph_facts)
        if not check_passed:
            logger.warning(err_msg)
            results['failed'] = True
            results['failed_reason'] = err_msg
            results['action'] = reset_simulator_port
            return results

        mux_simulator_status = get_mux_status()

        for status in mux_simulator_status.values():
            port_index = str(status['port_index'])

            # Some host interfaces in dualtor topo are disabled.
            # We only care about status of mux for the enabled host interfaces
            if port_index in dut_mux_status:
                active_side = dut_mux_status[port_index]
                failed, reason = _check_single_intf_status(
                    status, expected_side=active_side)

            if failed:
                logger.warning(
                    'Mux sanity check failed for status:\n{}'.format(status))
                results['failed'] = failed
                results['failed_reason'] = reason
                results['action'] = reset_simulator_port
                return results

        return results
Ejemplo n.º 2
0
def validate_check_result(check_result, duthosts):
    """If check_result is False, collect some log and fail the test.

    Args:
        check_result (bool): Check result
        duthosts (list): List of duthost objects.
    """
    if not check_result:
        duthosts.shell('show muxcable config')
        duthosts.shell('show muxcable status')
        simulator_muxstatus = get_mux_status()
        if simulator_muxstatus is not None:
            logger.info('Mux status from mux simulator: {}'.format(
                json.dumps(simulator_muxstatus)))
        else:
            logger.error('Failed to get mux status from mux simulator')
        pytest.fail('Toggle mux from simulator test failed')
Ejemplo n.º 3
0
    def _check(*args, **kwargs):
        """
        @summary: Checks if the OVS bridge mux simulator is functioning correctly
        @return: A dictionary containing the testing result of the PTF interface tested:
            {
                'check_item': 'mux_simulator',
                'failed': <True/False>,
                'failed_reason': <reason string>,
                'action': <recovery function>
            }
        """
        logger.info("Checking mux simulator status")
        results = {
            'failed': False,
            'failed_reason': '',
            'check_item': 'mux_simulator',
            'action': None
        }

        failed = False
        reason = ''

        for side in [UPPER_TOR, LOWER_TOR]:
            toggle_all_simulator_ports(side)
            time.sleep(5)
            mux_status = get_mux_status()
            for status in mux_status.values():
                failed, reason = _check_single_intf_status(status,
                                                           expected_side=side)

                if failed:
                    logger.warning(
                        'Mux sanity check failed for status:\n{}'.format(
                            status))
                    results['failed'] = failed
                    results['failed_reason'] = reason
                    results['action'] = reset_simulator_port
                    return results

        return results