Beispiel #1
0
def reload_dut_config(request, duthost, define_sub_ports_configuration):
    """
    DUT's configuration reload on teardown

    Args:
        request: pytest request object
        duthost: DUT host object
        define_sub_ports_configuration: Dictonary of parameters for configuration DUT
    """
    yield
    sub_ports = define_sub_ports_configuration['sub_ports']
    dut_ports = define_sub_ports_configuration['dut_ports']
    cfg_facts = duthost.config_facts(host=duthost.hostname,
                                     source="running")['ansible_facts']
    existing_sub_ports = cfg_facts.get("VLAN_SUB_INTERFACE", {})
    for sub_port in sub_ports:
        if sub_port in existing_sub_ports:
            remove_sub_port(duthost, sub_port, sub_ports[sub_port]['ip'])

    py_assert(check_sub_port(duthost, sub_ports.keys(), True),
              "Some sub-port were not deleted")

    if 'port_in_lag' in request.node.name:
        for lag_port in dut_ports.values():
            remove_lag_port(duthost, cfg_facts, lag_port)

    duthost.shell('sudo config load -y /etc/sonic/config_db.json')
    def test_routing_between_sub_ports_unaffected_by_sub_ports_removal(
            self, type_of_traffic, duthost, ptfadapter, apply_route_config):
        """
        Validates that the routing of packets between sub-ports are not affected by the removal of other sub ports.

        Test steps:
        Test steps:
            1.) Setup configuration of sub-ports on the DUT.
            2.) Setup configuration of sub-ports on the PTF.
            3.) Add one of the sub-ports to namespace on the PTF.
            4.) Setup static routes between sub-port and sub-port in namespace on the PTF
            5.) Create packet (TCP, UDP or ICMP).
            6.) Remove some other sub ports
            7.) Send packet from sub-port to sub-port in namespace on the PTF.
            8.) Verify that sub-port gets received packet on the PTF.
            9.) Remove static routes from PTF
            10.) Remove namespaces from PTF
            11.) Clear configuration of sub-ports on the DUT.
            12.) Clear configuration of sub-ports on the PTF.

        Note:
            Test verifies two cases of routing between sub-ports:
                1.) Routing between sub-ports on the same port
                2.) Routing between sub-ports on the different ports

        Pass Criteria: PTF port gets packets from port in namespace on the PTF.
        """
        new_sub_ports = apply_route_config['new_sub_ports']
        sub_ports = apply_route_config['sub_ports']
        type_of_traffic = type_of_traffic.split('-')

        # find to-be-removed sub ports
        sub_ports_to_remove = set(sub_ports.keys())
        for sub_port, next_hop_sub_ports in new_sub_ports.items():
            sub_ports_to_remove.remove(sub_port)
            for next_hop_sub_port, _ in next_hop_sub_ports:
                sub_ports_to_remove.remove(next_hop_sub_port)

        # remove those to-be-removed sub ports
        for sub_port in sub_ports_to_remove:
            remove_sub_port(duthost, sub_port, sub_ports[sub_port]["ip"])

        for src_port, next_hop_sub_ports in new_sub_ports.items():
            for sub_port, _ in next_hop_sub_ports:
                generate_and_verify_traffic(
                    duthost=duthost,
                    ptfadapter=ptfadapter,
                    src_port=sub_ports[src_port]['neighbor_port'],
                    ip_src=sub_ports[src_port]['neighbor_ip'],
                    dst_port=sub_ports[sub_port]['neighbor_port'],
                    ip_dst=sub_ports[sub_port]['neighbor_ip'],
                    pkt_action='fwd',
                    type_of_traffic=type_of_traffic,
                    ttl=63)
Beispiel #3
0
def reload_dut_config(request, duthost, define_sub_ports_configuration):
    """
    DUT's configuration reload on teardown

    Args:
        request: pytest request object
        duthost: DUT host object
        define_sub_ports_configuration: Dictonary of parameters for configuration DUT
    """
    yield
    sub_ports = define_sub_ports_configuration['sub_ports']
    dut_ports = define_sub_ports_configuration['dut_ports']
    cfg_facts = duthost.config_facts(host=duthost.hostname,
                                     source="running")['ansible_facts']

    for sub_port, sub_port_info in sub_ports.items():
        remove_sub_port(duthost, sub_port, sub_port_info['ip'])

    if 'port_in_lag' in request.node.name:
        for lag_port in dut_ports.values():
            remove_lag_port(duthost, cfg_facts, lag_port)

    duthost.shell('sudo config load -y /etc/sonic/config_db.json')