def test_remove_interface_from_lag_case_1(topology, step):
    """
    Case 1:
        Verify that an interface is correclty removed from a LAG
    """
    sw1 = topology.get('sw1')
    sw1_lag_id = '10'

    assert sw1 is not None

    step("Mapping interfaces")
    port = sw1.ports['1']

    step("Turning on interface 1 used in this test")
    turn_on_interface(sw1, port)

    step("Verify interface 1 is up")
    verify_turn_on_interfaces(sw1, [port])

    step("Create LAG")
    create_lag(sw1, sw1_lag_id, 'off')

    step("Associate interface [1] to LAG")
    associate_interface_to_lag(sw1, port, sw1_lag_id)

    step("Verify interface 1 is in LAG 1")
    verify_lag_config(sw1, sw1_lag_id, [port])

    step("Remove interface from LAG 1")
    remove_interface_from_lag(sw1, port, sw1_lag_id)

    step("Verify interface is shutdown")
    verify_turn_off_interfaces(sw1, [port])
コード例 #2
0
def step_configure_lags(sw_list, sw_real_ports, step):
    step('Create LAGs')
    for sw, mode in zip(sw_list, ['active', 'passive']):
        create_lag(sw, LAG_ID, mode)
        for port in sw_real_ports[sw][0:2]:
            associate_interface_to_lag(sw, port, LAG_ID)
        verify_lag_config(
            sw,
            LAG_ID,
            sw_real_ports[sw][0:2],
            mode=mode
        )
    check_func = retry_wrapper(
        'Verify LACP status on both devices',
        'Configuration not yet applied',
        10,
        5
    )(verify_lacp_state)
    check_func(
        sw_list[0],
        sw_list[1],
        sw1_lacp_mode='active',
        sw2_lacp_mode='passive',
        ports=sw_real_ports
    )
def change_member_states(sw, sw_real_ports, before_state, new_state):
    for i, port in enumerate(sw_real_ports[sw][1:]):
        if before_state[i] == new_state[i]:
            continue
        elif before_state[i] is False and new_state[i] is True:
            associate_interface_to_lag(sw, port, LAG_ID)
        else:
            remove_interface_from_lag(sw, port, LAG_ID)
    lag_members = [
        port for port, state in zip(sw_real_ports[sw][1:], new_state)
        if state is True
    ]
    verify_lag_config(sw, LAG_ID, lag_members)
    return lag_members
コード例 #4
0
def lacp_aggregation_key_packet_validation(topology):
    """
    Aggregation Key packet validation:
        Capture LACPDUs packets and validate the aggregation
        key is set correctly for both switches
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw1_lag_id = '100'
    sw2_lag_id = '200'

    p11 = sw1.ports['1']
    p12 = sw1.ports['2']
    p21 = sw2.ports['1']
    p22 = sw2.ports['2']

    print("Turning on all interfaces used in this test")
    ports_sw1 = [p11, p12]
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    ports_sw2 = [p21, p22]
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    print("Wait for interfaces to turn on")
    time.sleep(60)

    validate_turn_on_interfaces(sw1, ports_sw1)
    validate_turn_on_interfaces(sw2, ports_sw2)

    print("Create LAG in both switches")
    create_lag_active(sw1, sw1_lag_id)
    create_lag_passive(sw2, sw2_lag_id)

    set_lacp_rate_fast(sw1, sw1_lag_id)
    set_lacp_rate_fast(sw2, sw2_lag_id)

    print("Associate interfaces [1,2] to lag in both switches")
    associate_interface_to_lag(sw1, p11, sw1_lag_id)
    associate_interface_to_lag(sw1, p12, sw1_lag_id)
    associate_interface_to_lag(sw2, p21, sw2_lag_id)
    associate_interface_to_lag(sw2, p22, sw2_lag_id)

    sw1_mac = get_device_mac_address(sw1, p11)

    print("Take capture from interface 1 in switch 1")
    capture = tcpdump_capture_interface(sw1, p11, 80)
    tcpdump_capture_interface(sw1, p12, 80)

    print("Validate actor and partner key from sw1 packets")
    sw1_actor = get_info_from_packet_capture(capture, ACTOR, sw1_mac)

    assert sw1_actor['key'] == sw1_lag_id,\
        'Packet is not sending the correct actor key in sw1'

    sw1_partner = get_info_from_packet_capture(capture, PARTNER, sw1_mac)

    assert sw1_partner['key'] == sw2_lag_id,\
        'Packet is not sending the correct partner key in sw1'
コード例 #5
0
def test_static_move_interfaces(topology, step):
    sw1 = topology.get('sw1')
    assert sw1 is not None

    lag_id1 = '1'
    lag_id2 = '2'
    interface_id = '1'

    # Create a LAG
    step("Create a LAG with id" + lag_id1)
    create_lag(sw1, lag_id1, 'off')

    # Add an interface to LAG 1
    step("Add and interface to LAG " + lag_id1)
    associate_interface_to_lag(sw1, interface_id, lag_id1)

    # Verify LAG configuration
    step("Verify LAG configuration")
    verify_lag_config(sw1, lag_id1, interface_id)
    map_lacp = sw1.libs.vtysh.show_lacp_interface(interface_id)
    validate_lag_state_static(map_lacp, LOCAL_STATE)

    # Verify if the interface was added to static LAG
    step("Verify if the interface was added to static LAG")
    verify_lag_interface_lag_id(map_lacp, lag_id1)

    # Create a LAG
    step("Create a LAG with id " + lag_id2)
    create_lag(sw1, lag_id2, 'off')

    # Add an interface to LAG 2
    step("Add and interface to LAG 2")
    associate_interface_to_lag(sw1, '1', lag_id2)

    # Verify LAG configuration
    step("Verify LAG configuration")
    verify_lag_config(sw1, lag_id2, interface_id)
    map_lacp = sw1.libs.vtysh.show_lacp_interface(interface_id)
    validate_lag_state_static(map_lacp, LOCAL_STATE)

    # Verify if the interface was added to static LAG
    step("Verify if the interface was added to static LAG")
    verify_lag_interface_lag_id(map_lacp, lag_id2)

    # Verify if the interface is not in LAG 1
    step("Verify if the interface is not in LAG 1")
    validate_interface_not_in_lag(sw1, interface_id, lag_id1)
コード例 #6
0
def configure_lags(sw_list, sw_real_ports, step):
    step('Create LAGs')
    for sw in sw_list:
        create_lag(sw, LAG_ID, 'off')
        # Set LACP rate to fast
        set_lag_rate(sw, LAG_ID, 'fast')
        for port in sw_real_ports[sw][0:2]:
            associate_interface_to_lag(sw, port, LAG_ID)
        verify_lag_config(sw,
                          LAG_ID,
                          sw_real_ports[sw][0:2],
                          heartbeat_rate='fast')
    # Increase max time to compensate for framework delay
    check_func = retry_wrapper('Verify LACP status on both devices',
                               'Configuration not yet applied', 2,
                               6)(verify_lacp_state)
    check_func(sw_list[0],
               sw_list[1],
               sw_real_ports,
               sw1_lacp_mode='off',
               sw2_lacp_mode='off')
コード例 #7
0
def configure_lags(sw_list, sw_real_ports, step):
    step('Create LAGs')
    for sw in sw_list:
        create_lag(sw, LAG_ID, 'off')
        for port in sw_real_ports[sw][1:]:
            associate_interface_to_lag(sw, port, LAG_ID)
        verify_lag_config(
            sw,
            LAG_ID,
            sw_real_ports[sw][1:]
        )
    check_func = retry_wrapper(
        'Verify LACP status on both devices',
        'Configuration not yet applied',
        2,
        4
    )(verify_lacp_state)
    check_func(
        sw_list[0],
        sw_list[1]
    )
コード例 #8
0
def test_show_lacp_events(topology, step):
    """Test output for show events.

    Main objective is to configure two switches with
    dynamic LAG (active/passive)
    Add and remove interfaces and turn off one of the LAGs
    Call show events to see results
    """

    # VID for testing
    test_vlan = '2'

    # LAG ID for testing
    test_lag = '2'
    test_lag_if = 'lag' + test_lag

    # interfaces to be added to LAG
    lag_intfs = ['1', '3']

    # interface connected to host
    host_intf = '4'

    # hosts addresses
    hs1_addr = '10.0.11.10'
    hs2_addr = '10.0.11.11'

    show_event_lacp_cmd = 'show events category lacp'
    removed_intf = '2'

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    step('Verifying switches are not None')
    assert sw1 is not None, 'Topology failed getting object sw1'
    assert sw2 is not None, 'Topology failed getting object sw2'

    step('Verifying hosts are not None')
    assert hs1 is not None, 'Topology failed getting object hs1'
    assert hs2 is not None, 'Topology failed getting object hs2'

    step('Turning on interfaces')
    for switch in [sw1, sw2]:
        for intf in lag_intfs + [removed_intf, host_intf]:
            turn_on_interface(switch, intf)

    step('Verifying interfaces from Switch 1 are Up')
    verify_turn_on_interfaces(sw1, lag_intfs + [removed_intf, host_intf])

    step('Verifying interfaces from Switch 2 are Up')
    verify_turn_on_interfaces(sw1, lag_intfs + [removed_intf, host_intf])

    step('Creating VLAN (%s) on Switch 1' % test_vlan)
    create_vlan(sw1, test_vlan)

    step('Creating VLAN (%s) on Switch 2' % test_vlan)
    create_vlan(sw2, test_vlan)

    step('Creating LAG (%s) on Switch 1' % test_lag)
    create_lag(sw1, test_lag, 'active')
    config_lacp_rate(sw1, test_lag, True)
    associate_vlan_to_lag(sw1, test_vlan, test_lag)

    step('Creating LAG (%s) on Switch 2' % test_lag)
    create_lag(sw2, test_lag, 'passive')
    config_lacp_rate(sw2, test_lag, True)
    associate_vlan_to_lag(sw2, test_vlan, test_lag)

    for switch in [sw1, sw2]:
        for intf in lag_intfs + [removed_intf]:
            step('Assigning interface %s to LAG %s' % (intf, test_lag))
            associate_interface_to_lag(switch, intf, test_lag)

        step('Associating VLAN %s to host interface %s' % (test_vlan,
                                                           host_intf))
        associate_vlan_to_l2_interface(switch, test_vlan, host_intf)

    step('Configuring interface on Host 1')
    hs1.libs.ip.interface('1',
                          addr='{hs1_addr}/24'.format(**locals()),
                          up=True)

    step('Configuring interface on Host 2')
    hs2.libs.ip.interface('1',
                          addr='{hs2_addr}/24'.format(**locals()),
                          up=True)

    step('Verifying connectivity between hosts (Successful)')
    verify_connectivity_between_hosts(hs1, hs1_addr, hs2, hs2_addr, True)

    step('Removing interface (%s) from LAG (%s)' % (removed_intf, test_lag))
    remove_interface_from_lag(sw1, removed_intf, test_lag)

    step('Removing interface (%s) from LAG (%s)' % (removed_intf, test_lag))
    remove_interface_from_lag(sw2, removed_intf, test_lag)

    output = sw1(show_event_lacp_cmd, shell='vtysh')

    assert '|15007|LOG_INFO|LACP system ID set to'\
        and '|15006|LOG_INFO|LACP mode set to active for LAG {test_lag}'\
        .format(**locals())\
        and '|15001|LOG_INFO|Dynamic LAG {test_lag} created'\
        .format(**locals())\
        and '|15008|LOG_INFO|LACP rate set to fast for LAG {test_lag}'\
        .format(**locals())\
        and '|15004|LOG_INFO|Interface {removed_intf} removed from '\
        'LAG {test_lag}'.format(**locals())\
        in output

    for intf in lag_intfs + [removed_intf]:
        assert '|15003|LOG_INFO|Interface {intf} added to LAG {test_lag}'\
            .format(**locals())\
            and '|15009|LOG_INFO|Partner is detected for interface {intf}'\
            ' LAG {test_lag}'.format(**locals())\
            in output

    output = sw2(show_event_lacp_cmd, shell='vtysh')

    assert '|15007|LOG_INFO|LACP system ID set to'\
        and '|15006|LOG_INFO|LACP mode set to passive for LAG {test_lag}'\
        .format(**locals())\
        and '|15001|LOG_INFO|Dynamic LAG {test_lag} created'\
        .format(**locals())\
        and '|15008|LOG_INFO|LACP rate set to fast for LAG {test_lag}'\
        .format(**locals())\
        and '|15004|LOG_INFO|Interface {removed_intf} removed from '\
        'LAG {test_lag}'.format(**locals())\
        in output

    for intf in lag_intfs + [removed_intf]:
        assert '|15003|LOG_INFO|Interface {intf} added to LAG {test_lag}'\
            .format(**locals())\
            and '|15009|LOG_INFO|Partner is detected for interface {intf}'\
            ' LAG {test_lag}'.format(**locals())\
            in output

    with sw2.libs.vtysh.ConfigInterfaceLag(test_lag) as ctx:
        ctx.no_lacp_mode_passive()

    step('Verifying connectivity between hosts (Unsuccessful)')
    verify_connectivity_between_hosts(hs1, hs1_addr, hs2, hs2_addr, False)

    output = sw1(show_event_lacp_cmd, shell='vtysh')

    for intf in lag_intfs:
        assert '|15011|LOG_WARN|Partner is lost (timed out) '\
            'for interface {intf} '.format(**locals())\
            in output

    output = sw2(show_event_lacp_cmd, shell='vtysh')
    assert '|15006|LOG_INFO|LACP mode set to off for '\
        'LAG {test_lag}'.format(**locals())\
        and '|ops-lacpd|15002|LOG_INFO|Dynamic LAG {test_lag} deleted'\
        .format(**locals())\
        in output
コード例 #9
0
def test_lacpd_load_balance(topology, step):
    """Test LAG load balance with l2, l3 and l4 hash algorithms."""
    # VID for testing
    test_vlan = '256'
    # LAG ID for testing
    test_lag = '2'
    # Ports for testing
    test_port_tcp = 778
    test_port_udp = 777
    times_to_send = 150
    # interfaces to be added to LAG
    lag_interfaces = ['2', '3']
    # traffic counters
    lag_intf_counter_b = {}
    lag_intf_counter_a = {}
    delta_tx = {'l2-src-dst': {}, 'l3-src-dst': {}, 'l4-src-dst': {}}

    num_addresses = 10

    mac_list = generate_mac_addresses(num_addresses)
    ip_list = generate_ip_addresses(num_addresses)

    lag_lb_algorithms = ['l2-src-dst', 'l3-src-dst', 'l4-src-dst']
    sw1_host_interfaces = ['1']
    sw2_host_interfaces = ['1', '4']
    host1_addr = '10.0.11.10'
    host2_addr = '10.0.11.11'
    host3_addr = '10.0.11.12'

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs3 = topology.get('hs3')

    step('Verifying switches are not None')
    assert sw1 is not None, 'Topology failed getting object sw1'
    assert sw2 is not None, 'Topology failed getting object sw2'

    step('Verifying hosts are not None')
    assert hs1 is not None, 'Topology failed getting object hs1'
    assert hs2 is not None, 'Topology failed getting object hs2'
    assert hs3 is not None, 'Topology failed getting object hs3'

    step('Turning interfaces ON on Switch 1')
    for intf in lag_interfaces + sw1_host_interfaces:
        turn_on_interface(sw1, intf)

    step('Turning interfaces ON on Switch 1')
    for intf in lag_interfaces + sw2_host_interfaces:
        turn_on_interface(sw2, intf)

    step('Verifying interfaces are Up on Switch 1')
    verify_turn_on_interfaces(sw1, lag_interfaces + sw1_host_interfaces)

    step('Verifying interfaces are Up on Switch 1')
    verify_turn_on_interfaces(sw2, lag_interfaces + sw2_host_interfaces)

    # Configure switches
    for switch in [sw1, sw2]:
        step('Creating VLAN %s' % test_vlan)
        create_vlan(switch, test_vlan)

        step('Creating LAG %s' % test_lag)
        create_lag(switch, test_lag, 'off')

        step('Associating VLAN %s to LAG %s' % test_vlan, test_lag)
        associate_vlan_to_lag(switch, test_vlan, test_lag)

        for intf in lag_interfaces:
            step('Associating interface %s to LAG %s' % (intf, test_lag))
            associate_interface_to_lag(switch, intf, test_lag)

    for intf in sw1_host_interfaces:
        step('Associating VLAN %s to interface %s' % (test_vlan, intf))
        associate_vlan_to_l2_interface(sw1, test_vlan, intf)

    for intf in sw2_host_interfaces:
        step('Associating VLAN %s to interface %s' % (test_vlan, intf))
        associate_vlan_to_l2_interface(sw2, test_vlan, intf)

    # Configure host interfaces
    hs1.libs.ip.interface('1',
                          addr='{host1_addr}/24'.format(**locals()),
                          up=True)

    hs2.libs.ip.interface('1',
                          addr='{host2_addr}/24'.format(**locals()),
                          up=True)

    hs3.libs.ip.interface('1',
                          addr='{host3_addr}/24'.format(**locals()),
                          up=True)

    step('Verifying connectivity between Host 1 and Host 2')
    verify_connectivity_between_hosts(hs1, host1_addr, hs2, host2_addr)

    step('Verifying connectivity between Host 1 and Host 3')
    verify_connectivity_between_hosts(hs1, host1_addr, hs3, host3_addr)

    hs2.libs.iperf.server_start(test_port_tcp, 20, False)
    hs2.libs.iperf.server_start(test_port_udp, 20, True)
    hs3.libs.iperf.server_start(test_port_tcp, 20, False)

    old_ip = host1_addr
    for lb_algorithm in lag_lb_algorithms:
        print('========== Testing with {lb_algorithm} =========='.format(
            **locals()))
        for switch in [sw1, sw2]:
            set_lag_lb_hash(switch, test_lag, lb_algorithm)
            # Check that hash is properly set
            check_lag_lb_hash(switch, test_lag, lb_algorithm)

        sleep(10)
        for intf in lag_interfaces:
            intf_info = sw1.libs.vtysh.show_interface(intf)
            lag_intf_counter_b[intf] = intf_info['tx_packets']

        for x in range(0, times_to_send):
            if lb_algorithm == 'l3-src-dst':
                ip = ip_list[x % num_addresses]
                chg_ip_address(hs1, '1', '{ip}/24'.format(**locals()),
                               '{old_ip}/24'.format(**locals()))
                old_ip = ip
            elif lb_algorithm == 'l2-src-dst':
                mac = mac_list[x % num_addresses]
                chg_mac_address(hs1, '1', mac)

            hs1.libs.iperf.client_start(host2_addr, test_port_tcp, 1, 2, False)

            if lb_algorithm == 'l4-src-dst':
                hs1.libs.iperf.client_start(host2_addr, test_port_udp, 1, 2,
                                            True)
            else:
                hs1.libs.iperf.client_start(host3_addr, test_port_tcp, 1, 2,
                                            False)
        sleep(15)
        for intf in lag_interfaces:
            intf_info = sw1.libs.vtysh.show_interface(intf)
            lag_intf_counter_a[intf] = intf_info['tx_packets']
            delta_tx[lb_algorithm][intf] =\
                lag_intf_counter_a[intf] - lag_intf_counter_b[intf]

            assert delta_tx[lb_algorithm][intf] > 0,\
                'Just one interface was used with {lb_algorithm}'\
                .format(**locals())

        if lb_algorithm == 'l3-src-dst':
            chg_ip_address(hs1, '1', '{host1_addr}/24'.format(**locals()),
                           '{old_ip}/24'.format(**locals()))

    # Print a summary of counters
    for lb_algorithm in lag_lb_algorithms:
        print('======== {lb_algorithm} ============'.format(**locals()))
        for intf in lag_interfaces:
            print('Interface: {intf}'.format(**locals()))
            dt = delta_tx[lb_algorithm][intf]
            print('TX packets: {dt}'.format(**locals()))
            print('--')
    print('=================================')
コード例 #10
0
def test_dynamic_tagged_vlan(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs3 = topology.get('hs3')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None
    assert hs3 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3', '4']

    lag_id = '1'
    vlans_id = ['800', '900']
    mode_active = 'active'
    mode_passive = 'passive'

    step("### Mapping interfaces from Docker ###")
    for port in port_labels[:3]:
        ports_sw1.append(sw1.ports[port])

    for port in port_labels:
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1:3], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[1:3], mode=mode_passive)

    step("#### Configure VLANs on switches ####")
    for vlan in vlans_id:
        create_vlan(sw1, vlan)
        create_vlan(sw2, vlan)

    step("### Tagged VLANs on LAG interfaces")
    tagged_vlan_to_lag(sw1, vlans_id, lag_id)
    tagged_vlan_to_lag(sw2, vlans_id, lag_id)

    associate_vlan_to_l2_interface(sw1, vlans_id[0], ports_sw1[0])
    associate_vlan_to_l2_interface(sw2, vlans_id[0], ports_sw2[0])
    associate_vlan_to_l2_interface(sw2, vlans_id[1], ports_sw2[3])

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)
    hs3.libs.ip.interface('1', addr='140.1.1.12/24', up=True)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:3], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:3], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients in the same vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("#### Test ping between clients in the different vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12', 5,
                                     False)

    step("### Move one WS to the VLAN with the single workstation ###")
    associate_vlan_to_l2_interface(sw1, vlans_id[1], ports_sw1[0])

    step("#### Test ping between clients in the same vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12', 5,
                                     True)
コード例 #11
0
def test_l2_static_lag_ping_case_1(topology):
    """
    Case 1:
        Verify a ping between 2 workstations connected by 2 switches configured
        with L2 static LAGs works properly.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs1_ip_address_with_mask = '10.0.10.1/24'
    hs2_ip_address_with_mask = '10.0.10.2/24'
    hs1_ip_address = '10.0.10.1'
    hs2_ip_address = '10.0.10.2'
    sw1_lag_id = '10'
    sw2_lag_id = '20'
    vlan_identifier = '8'

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    # Remove unused port 3
    port_labels = ['1', '2', '3']

    step("### Mapping interfaces from Docker ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    p11 = ports_sw1[0]
    p12 = ports_sw1[1]
    p13 = ports_sw1[2]
    p21 = ports_sw2[0]
    p22 = ports_sw2[1]
    p23 = ports_sw2[2]

    step("Turning on all interfaces used in this test")
    ports_sw1 = [p11, p12, p13]
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    ports_sw2 = [p21, p22, p23]
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("Assign an IP address on the same range to each workstation")
    hs1.libs.ip.interface('1', addr=hs1_ip_address_with_mask, up=True)
    hs2.libs.ip.interface('1', addr=hs2_ip_address_with_mask, up=True)

    step('Creating VLAN in both switches')
    create_vlan(sw1, vlan_identifier)
    create_vlan(sw2, vlan_identifier)

    step("Create LAG in both switches")
    create_lag(sw1, sw1_lag_id, 'off')
    create_lag(sw2, sw2_lag_id, 'off')

    step("Associate interfaces [1, 2] to LAG in both switches")
    associate_interface_to_lag(sw1, p11, sw1_lag_id)
    associate_interface_to_lag(sw1, p12, sw1_lag_id)
    associate_interface_to_lag(sw2, p21, sw2_lag_id)
    associate_interface_to_lag(sw2, p22, sw2_lag_id)

    step("Configure LAGs and workstations interfaces with same VLAN")
    associate_vlan_to_lag(sw1, vlan_identifier, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan_identifier, sw2_lag_id)
    associate_vlan_to_l2_interface(sw1, vlan_identifier, p13)
    associate_vlan_to_l2_interface(sw2, vlan_identifier, p23)

    step("Ping workstation 2 from workstation 1 and viceversa")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
def main_setup(request, topology):
    """Test Case common configuration."""
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    print('Verifying switches are not None')
    assert sw1 is not None, 'Topology failed getting object sw1'
    assert sw2 is not None, 'Topology failed getting object sw2'

    print('Verifying hosts are not None')
    assert hs1 is not None, 'Topology failed getting object hs1'
    assert hs2 is not None, 'Topology failed getting object hs2'

    ports_sw1 = list()
    ports_sw2 = list()

    print("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    print("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    print("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    print('Creating VLAN (%s) on Switch 1' % test_vlan)
    create_vlan(sw1, test_vlan)

    print('Creating VLAN (%s) on Switch 2' % test_vlan)
    create_vlan(sw2, test_vlan)

    print('Creating LAG (%s) active on Switch 1' % test_lag)
    create_lag_active(sw1, test_lag)

    print('Executing "show lacp aggregates" on Switch 1')
    verify_show_lacp_aggregates(sw1, test_lag_if, 'active')

    print('Associating VLAN (%s) to LAG (%s)' % (test_vlan, test_lag))
    associate_vlan_to_lag(sw1, test_vlan, test_lag)

    print('Creating LAG (%s) passive on Switch 2' % test_lag)
    create_lag_passive(sw2, test_lag)

    print('Executing "show lacp aggregates" on Switch 2')
    verify_show_lacp_aggregates(sw2, test_lag_if, 'passive')

    print('Associating VLAN (%s) to LAG (%s)' % (test_vlan, test_lag))
    associate_vlan_to_lag(sw2, test_vlan, test_lag)

    print('Configuring IP address to Host 1')
    hs1.libs.ip.interface('1',
                          addr='%s/24' % hs1_addr,
                          up=True)

    print('Configuring IP address to Host 2')
    hs2.libs.ip.interface('1',
                          addr='%s/24' % hs2_addr,
                          up=True)

    print("Associate interfaces to LAG in both switches")
    for port in ports_sw1[0:2]:
        associate_interface_to_lag(sw1, port, test_lag)
    for port in ports_sw2[0:2]:
        associate_interface_to_lag(sw2, port, test_lag)

    for switch in [sw1, sw2]:
        # Interface 4 is connected to one host
        associate_vlan_to_l2_interface(switch, test_vlan, switch.ports['3'])

    # Adding small delay to compensate for framework delay
    sleep(10)
    print('Verify connectivity between hosts')
    verify_connectivity_between_hosts(hs1, hs1_addr, hs2, hs2_addr, True)
コード例 #13
0
def test_lacp_agg_key_more_than_one_lag_connected(topology):
    """
    Case 2:
        Verify only interfaces associated with the same
        aggregation key get to Collecting/Distributing state
        Initial Topology:
            SW1>
                LAG150 -> Interfaces: 1,2,3,4
            SW2>
                LAG150 -> Interfaces: 1,2
                LAG400 -> Interfaces: 3,4
        Expected behaviour:
            Interfaces 1 and 2 in both switches get state Active, InSync,
            Collecting and Distributing. Interfaces 3 and 4 should get state
            Active, OutOfSync, Collecting and Distributing
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw1_lag_id = '150'
    sw2_lag_id = '150'
    sw2_lag_id_2 = '400'

    assert sw1 is not None
    assert sw2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3', '4']

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Verify interfaces to turn on")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    mac_addr_sw1 = sw1.libs.vtysh.show_interface('1')['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface('1')['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2, \
        'Mac address of interfaces in sw1 is equal to mac address of ' + \
        'interfaces in sw2. This is a test framework problem. Dynamic ' + \
        'LAGs cannot work properly under this condition. Refer to Taiga ' + \
        'issue #1251.'

    step("Create LAG in both switches")
    create_lag_active(sw1, sw1_lag_id)
    create_lag_active(sw2, sw2_lag_id)
    create_lag_active(sw2, sw2_lag_id_2)
    set_lacp_rate_fast(sw1, sw1_lag_id)
    set_lacp_rate_fast(sw2, sw2_lag_id)
    set_lacp_rate_fast(sw2, sw2_lag_id_2)

    step("Associate interfaces to lag in both switches")
    for interface in ports_sw1:
        associate_interface_to_lag(sw1, interface, sw1_lag_id)

    for interface in ports_sw2[0:2]:
        associate_interface_to_lag(sw2, interface, sw2_lag_id)

    for interface in ports_sw2[2:4]:
        associate_interface_to_lag(sw2, interface, sw2_lag_id_2)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, sw1_lag_id, ports_sw1, 'fast', mode='active')
    verify_lag_config(sw2, sw2_lag_id, ports_sw2[0:2], 'fast', mode='active')
    verify_lag_config(sw2, sw2_lag_id_2, ports_sw2[2:4], 'fast', mode='active')

    step("Get the configured interfaces for each LAG using diag-dump " +
         "lacp basic in both switches")
    time.sleep(60)
    sw1_lacp_interfaces = get_diagdump_lacp_interfaces(sw1)
    sw2_lacp_interfaces = get_diagdump_lacp_interfaces(sw2)
    validate_diagdump_lacp_interfaces(sw1_lacp_interfaces, sw1_lag_id,
                                      ports_sw1, ports_sw1,
                                      [ports_sw1[0], ports_sw1[1]])
    validate_diagdump_lacp_interfaces(sw2_lacp_interfaces, sw2_lag_id,
                                      [ports_sw2[0], ports_sw2[1]],
                                      [ports_sw2[0], ports_sw2[1]],
                                      [ports_sw2[0], ports_sw2[1]])
    validate_diagdump_lacp_interfaces(sw2_lacp_interfaces, sw2_lag_id_2,
                                      [ports_sw2[2], ports_sw2[3]],
                                      [ports_sw2[2], ports_sw2[3]], [])

    step("Get information for LAG in interface 1 with both switches")
    map_lacp_sw1_p11 = sw1.libs.vtysh.show_lacp_interface(ports_sw1[0])
    map_lacp_sw1_p12 = sw1.libs.vtysh.show_lacp_interface(ports_sw1[1])
    map_lacp_sw1_p13 = sw1.libs.vtysh.show_lacp_interface(ports_sw1[2])
    map_lacp_sw1_p14 = sw1.libs.vtysh.show_lacp_interface(ports_sw1[3])
    map_lacp_sw2_p21 = sw2.libs.vtysh.show_lacp_interface(ports_sw2[0])
    map_lacp_sw2_p22 = sw2.libs.vtysh.show_lacp_interface(ports_sw2[1])
    map_lacp_sw2_p23 = sw2.libs.vtysh.show_lacp_interface(ports_sw2[2])
    map_lacp_sw2_p24 = sw2.libs.vtysh.show_lacp_interface(ports_sw2[3])

    step("Get the state of LAGs using diag-dump lacp basic in both switches")
    sw1_lacp_state = get_diagdump_lacp_state(sw1)
    sw2_lacp_state = get_diagdump_lacp_state(sw2)

    # Recast labels to work with the library output
    ports_sw1[:] = [int(x) if x.isdigit() else x for x in ports_sw1]
    ports_sw2[:] = [int(x) if x.isdigit() else x for x in ports_sw2]

    map_diagdump_lacp_sw1_p11 = sw1_lacp_state[str(sw1_lag_id)][ports_sw1[0]]
    map_diagdump_lacp_sw1_p12 = sw1_lacp_state[str(sw1_lag_id)][ports_sw1[1]]
    map_diagdump_lacp_sw1_p13 = sw1_lacp_state[str(sw1_lag_id)][ports_sw1[2]]
    map_diagdump_lacp_sw1_p14 = sw1_lacp_state[str(sw1_lag_id)][ports_sw1[3]]
    map_diagdump_lacp_sw2_p21 = sw2_lacp_state[str(sw2_lag_id)][ports_sw2[0]]
    map_diagdump_lacp_sw2_p22 = sw2_lacp_state[str(sw2_lag_id)][ports_sw2[1]]
    map_diagdump_lacp_sw2_p23 = sw2_lacp_state[str(sw2_lag_id_2)][ports_sw2[2]]
    map_diagdump_lacp_sw2_p24 = sw2_lacp_state[str(sw2_lag_id_2)][ports_sw2[3]]

    step("Validate the LAG was created in both switches")
    validate_lag_state_sync(map_lacp_sw1_p11, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw1_p12, LOCAL_STATE)
    validate_lag_state_out_of_sync(map_lacp_sw1_p13, LOCAL_STATE)
    validate_lag_state_out_of_sync(map_lacp_sw1_p14, LOCAL_STATE)

    validate_lag_state_sync(map_lacp_sw2_p21, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw2_p22, LOCAL_STATE)
    validate_lag_state_afn(map_lacp_sw2_p23, LOCAL_STATE)
    validate_lag_state_afn(map_lacp_sw2_p24, LOCAL_STATE)

    # Validate diag-dump results
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw1_p11,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw1_p12,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_out_sync(map_diagdump_lacp_sw1_p13,
                                         DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_out_sync(map_diagdump_lacp_sw1_p14,
                                         DIAG_DUMP_LOCAL_STATE)

    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw2_p21,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw2_p22,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_afn(map_diagdump_lacp_sw2_p23,
                                    DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_afn(map_diagdump_lacp_sw2_p24,
                                    DIAG_DUMP_LOCAL_STATE)
コード例 #14
0
def test_l2_l3_switch_case_1(topology):
    """
    Case 1:
        Verify the correct communication of 2 switches connected first by a
        L2 LAG, then by a L3 LAG and finally connected by a L2 LAG again.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    ip_address_mask = '24'
    hs1_ip_address = '10.0.10.1'
    hs2_ip_address = '10.0.10.2'
    hs1_ip_address_with_mask = hs1_ip_address + '/' + ip_address_mask
    hs2_ip_address_with_mask = hs2_ip_address + '/' + ip_address_mask
    sw1_lag_ip_address = '10.0.0.1'
    sw2_lag_ip_address = '10.0.0.2'
    sw1_lag_id = '10'
    sw2_lag_id = '20'
    vlan_identifier = '8'
    number_pings = 5

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Verify all interface are up")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("Assign an IP address on the same range to each workstation")
    hs1.libs.ip.interface('1', addr=hs1_ip_address_with_mask, up=True)
    hs2.libs.ip.interface('1', addr=hs2_ip_address_with_mask, up=True)

    step('Creating VLAN in both switches')
    create_vlan(sw1, vlan_identifier)
    create_vlan(sw2, vlan_identifier)

    step("Create LAG in both switches")
    create_lag(sw1, sw1_lag_id, 'off')
    create_lag(sw2, sw2_lag_id, 'off')

    step("Associate interfaces [2, 3] to LAG in both switches")
    for intf in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, intf, sw1_lag_id)

    for intf in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, intf, sw2_lag_id)

    step("Configure LAGs and workstations interfaces with same VLAN")
    associate_vlan_to_lag(sw1, vlan_identifier, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan_identifier, sw2_lag_id)
    associate_vlan_to_l2_interface(sw1, vlan_identifier, ports_sw1[0])
    associate_vlan_to_l2_interface(sw2, vlan_identifier, ports_sw2[0])

    step("Test ping between clients")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)

    step("Assign IP on the same range to LAG in both switches")
    assign_ip_to_lag(sw1, sw1_lag_id, sw1_lag_ip_address, ip_address_mask)
    assign_ip_to_lag(sw2, sw2_lag_id, sw2_lag_ip_address, ip_address_mask)

    step(" Ping between workstations should fail")
    check_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address,
                                     number_pings, False)

    step("Ping between switches should succeed")
    check_connectivity_between_switches(sw1, sw1_lag_ip_address, sw2,
                                        sw2_lag_ip_address, number_pings,
                                        True)

    step("Configure LAGs with VLAN")
    associate_vlan_to_lag(sw1, vlan_identifier, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan_identifier, sw2_lag_id)

    step("Ping between workstations should succeed")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)

    step("Ping between switches should fail")
    check_connectivity_between_switches(sw1, sw1_lag_ip_address, sw2,
                                        sw2_lag_ip_address, number_pings,
                                        False)
コード例 #15
0
def test_l2_dynamic_lag_ping_case_1(topology, step):
    """
    Case 1:
        Verify a ping between 2 workstations connected by 2 switches configured
        with L2 dynamic LAGs works properly.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs1_ip_address_with_mask = '10.0.10.1/24'
    hs2_ip_address_with_mask = '10.0.10.2/24'
    hs1_ip_address = '10.0.10.1'
    hs2_ip_address = '10.0.10.2'
    sw1_lag_id = '10'
    sw2_lag_id = '20'
    vlan_identifier = '8'
    number_pings = 5

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw1, ports_sw2)

    step("Assign an IP address on the same range to each workstation")
    hs1.libs.ip.interface('1', addr=hs1_ip_address_with_mask, up=True)
    hs2.libs.ip.interface('1', addr=hs2_ip_address_with_mask, up=True)

    step('Creating VLAN in both switches')
    create_vlan(sw1, vlan_identifier)
    create_vlan(sw2, vlan_identifier)

    step("Create LAG in both switches")
    create_lag(sw1, sw1_lag_id, 'active')
    create_lag(sw2, sw2_lag_id, 'active')

    step("Associate interfaces [2, 3] to LAG in both switches")
    for port in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, port, sw1_lag_id)
    for port in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, port, sw2_lag_id)

    step("Verify LAG configuration")
    verify_lag_config(sw1, sw1_lag_id, ports_sw1[1:3], mode='active')
    verify_lag_config(sw2, sw2_lag_id, ports_sw2[1:3], mode='active')

    step("Configure LAGs and workstations interfaces with same VLAN")
    associate_vlan_to_lag(sw1, vlan_identifier, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan_identifier, sw2_lag_id)
    associate_vlan_to_l2_interface(sw1, vlan_identifier, ports_sw1[0])
    associate_vlan_to_l2_interface(sw2, vlan_identifier, ports_sw2[0])

    step("Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:3], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw1, ports_sw1[1:3], REMOTE_STATE, 'active')

    step("Get information for LAG in interface 2 with both switches")
    map_lacp_sw1 = sw1.libs.vtysh.show_lacp_interface(
        find_device_label(sw1, ports_sw1[1]))
    map_lacp_sw2 = sw2.libs.vtysh.show_lacp_interface(
        find_device_label(sw2, ports_sw2[1]))

    step("Validate the LAG was created in both switches")
    validate_lag_name(map_lacp_sw1, sw1_lag_id)
    validate_local_key(map_lacp_sw1, sw1_lag_id)
    validate_remote_key(map_lacp_sw1, sw2_lag_id)
    validate_lag_state_sync(map_lacp_sw1, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw1, REMOTE_STATE)

    validate_lag_name(map_lacp_sw2, sw2_lag_id)
    validate_local_key(map_lacp_sw2, sw2_lag_id)
    validate_remote_key(map_lacp_sw2, sw1_lag_id)
    validate_lag_state_sync(map_lacp_sw2, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw2, REMOTE_STATE)

    step("Ping workstation 2 from workstation 1 and viceversa")
    check_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address,
                                     number_pings, True)

    # ops-lacpd is stopped so that it produces the gcov coverage data
    #
    # Daemons from both switches will dump the coverage data to the
    # same file but the data write is done on daemon exit only.
    # The systemctl command waits until the process exits to return the
    # prompt and the shell function waits for the command to return,
    # therefore it is safe to stop the ops-lacpd daemons sequentially
    # This ensures that data from both processes is captured.
    sw1("systemctl stop ops-lacpd", shell="bash")
    sw2("systemctl stop ops-lacpd", shell="bash")
コード例 #16
0
def test_l3_static_lag_ping_case_1(topology, step):
    """
    Case 1:
        Verify a simple ping works properly between 2 switches configured
        with static L3 LAGs. Each LAG having 3 interfaces.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw1_lag_id = '100'
    sw2_lag_id = '200'
    sw1_lag_ip_address = '10.0.0.1'
    sw2_lag_ip_address = '10.0.0.2'
    ip_address_mask = '24'
    number_pings = 10

    assert sw1 is not None
    assert sw2 is not None

    port_labels = ['1', '2', '3']
    ports_sw1 = list()
    ports_sw2 = list()

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    p11 = ports_sw1[0]
    p12 = ports_sw1[1]
    p13 = ports_sw1[2]
    p21 = ports_sw2[0]
    p22 = ports_sw2[1]
    p23 = ports_sw2[2]

    step("Turning on all interfaces used in this test")
    ports_sw1 = [p11, p12, p13]
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    ports_sw2 = [p21, p22, p23]
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Create LAG in both switches")
    create_lag(sw1, sw1_lag_id, 'off')
    create_lag(sw2, sw2_lag_id, 'off')

    step("Associate interfaces [1,2, 3] to lag in both switches")
    associate_interface_to_lag(sw1, p11, sw1_lag_id)
    associate_interface_to_lag(sw1, p12, sw1_lag_id)
    associate_interface_to_lag(sw1, p13, sw1_lag_id)
    associate_interface_to_lag(sw2, p21, sw2_lag_id)
    associate_interface_to_lag(sw2, p22, sw2_lag_id)
    associate_interface_to_lag(sw2, p23, sw2_lag_id)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("Assign IP to LAGs")
    assign_ip_to_lag(sw1, sw1_lag_id, sw1_lag_ip_address, ip_address_mask)
    assign_ip_to_lag(sw2, sw2_lag_id, sw2_lag_ip_address, ip_address_mask)

    step("Ping switch2 from switch1 and viceversa")
    check_connectivity_between_switches(sw1, sw1_lag_ip_address, sw2,
                                        sw2_lag_ip_address, number_pings, True)
コード例 #17
0
def test_lag_shutdown_disabled(topology, step):
    """Test LAG with shutdown enabled.

    By default a new LAG is configured as 'no shutdown', so this case will
    test to execute 'no shutdown' on both switches and connectivity must
    remain working and IPv4 pings between both clients must be successful.
    """

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    sw1_lag_id = '100'
    sw2_lag_id = '200'
    h1_ip_address = '10.0.0.1'
    h2_ip_address = '10.0.0.2'
    vlan = '100'
    mask = '/24'

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    print("Configure IP and bring UP in host 1")
    hs1.libs.ip.interface('1', addr=(h1_ip_address + mask), up=True)

    print("Configure IP and bring UP in host 2")
    hs2.libs.ip.interface('1', addr=(h2_ip_address + mask), up=True)

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    print("Create LAG in both switches")
    create_lag_active(sw1, sw1_lag_id)
    create_lag_active(sw2, sw2_lag_id)

    print("Configure vlan and switch interfaces")
    create_vlan(sw1, vlan)
    create_vlan(sw2, vlan)

    print("Associate vlan with lag in both switches")
    associate_vlan_to_lag(sw1, vlan, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan, sw2_lag_id)

    print("Associate vlan with l2 interfaces in both switches")
    associate_vlan_to_l2_interface(sw1, vlan, ports_sw1[0])
    associate_vlan_to_l2_interface(sw2, vlan, ports_sw2[0])

    step("Associate interfaces [2,3] to lag in both switches")
    for port in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, port, sw1_lag_id)
    for port in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, port, sw2_lag_id)

    step("Verify LAG configuration")
    verify_lag_config(sw1, sw1_lag_id, ports_sw1[1:3], mode='active')
    verify_lag_config(sw2, sw2_lag_id, ports_sw2[1:3], mode='active')

    step("Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:3], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw1, ports_sw1[1:3], REMOTE_STATE, 'active')

    step("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1[1:3])
    verify_turn_on_interfaces(sw2, ports_sw2[1:3])

    step("Test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, True)

    step("Turn on LAG SW1")
    lag_no_shutdown(sw1, sw1_lag_id)

    step("Test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, True)

    step("Turn on LAG SW2")
    lag_no_shutdown(sw2, sw2_lag_id)

    step("Test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, True)

    step("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1[1:3])
    verify_turn_on_interfaces(sw2, ports_sw2[1:3])
コード例 #18
0
def main_setup(request, topology):
    """Test Suite Common Topology."""
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')

    print('Verifying switches are not None')
    assert sw1 is not None
    assert sw2 is not None

    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    print("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    print("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    print("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    print('Verifying interfaces of Switch 1')
    verify_turn_on_interfaces(sw1, ports_sw1)

    print('Verifying interfaces of Switch 2')
    verify_turn_on_interfaces(sw2, ports_sw2)

    mac_addr_sw1 = sw1.libs.vtysh.show_interface('1')['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface('1')['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2, \
        'Mac address of interfaces in sw1 is equal to mac address of ' + \
        'interfaces in sw2. This is a test framework problem. Dynamic ' + \
        'LAGs cannot work properly under this condition. Refer to Taiga ' + \
        'issue #1251.'

    print('Creating LAG %s on Switch 1' % sw1_lag_id)
    create_lag_active(sw1, sw1_lag_id)

    print('Creating LAG %s on Switch 2' % sw2_lag_id)
    create_lag_active(sw2, sw2_lag_id)

    print('Setting LAG %s to "fast" on Switch 1' % sw1_lag_id)
    set_lag_rate(sw1, sw1_lag_id, 'fast')

    print('Setting LAG %s to "fast" on Switch 2' % sw2_lag_id)
    set_lag_rate(sw2, sw2_lag_id, 'fast')

    for port in ports_sw1:
        print('Associate interfaces %s to lag on Switch 1' % port)
        associate_interface_to_lag(sw1, port, sw1_lag_id)

    for port in ports_sw2:
        print('Associate interfaces %s to lag on Switch 2' % port)
        associate_interface_to_lag(sw2, port, sw2_lag_id)

    print("Verify state machines in all switches")
    """
    The interface 1 and 2 of sw1 must be collecting and distributing
    """
    verify_actor_state('asfncd', [sw1], ports_sw1)
    verify_actor_state('asfncd', [sw2], ports_sw2)
def test_static_modify_maximum_members(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()

    port_labels = ['1', '2', '3', '4', '5', '6', '7', '8', '9']

    lag_id = '1'
    vlan_id = '900'

    step("### Mapping interfaces from Docker ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:9]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:9]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1:9])
    verify_lag_config(sw2, lag_id, ports_sw2[1:9])

    step("#### Configure VLANs on switches ####")
    create_vlan(sw1, vlan_id)
    create_vlan(sw2, vlan_id)

    associate_vlan_to_l2_interface(sw1, vlan_id, ports_sw1[0])
    associate_vlan_to_lag(sw1, vlan_id, lag_id)

    associate_vlan_to_l2_interface(sw2, vlan_id, ports_sw2[0])
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)

    step("#### Test ping between clients work ####")
    verify_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11')

    step("### Remove one interface from each LAG ###")
    remove_interface_from_lag(sw1, ports_sw1[1], lag_id)
    remove_interface_from_lag(sw2, ports_sw2[1], lag_id)

    step("### Validate if the interface was removed of LAG ###")
    validate_interface_not_in_lag(sw1, ports_sw1[1], lag_id)
    validate_interface_not_in_lag(sw2, ports_sw2[1], lag_id)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("### Turning on interface ###")
    turn_on_interface(sw1, ports_sw1[1])
    turn_on_interface(sw2, ports_sw2[1])

    step("### Validate interface is turn on ###")
    verify_turn_on_interfaces(sw1, ports_sw1[1])
    verify_turn_on_interfaces(sw2, ports_sw2[1])

    step("### Associate Interface to LAG ###")
    associate_interface_to_lag(sw1, ports_sw1[1], lag_id)
    associate_interface_to_lag(sw2, ports_sw2[1], lag_id)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)
def test_lacp_agg_key_move_interface(topology):
    """
    Case 1:
        Verify aggregation key functionality when
        interface is moved to another LAG in one of
        the switches from the topology
        Initial Topology:
            SW1>
                LAG100 -> Interfaces: 1,2
            SW2>
                LAG100 -> Interfaces: 1,2
        Final Topology:
            SW1>
                LAG200 -> Interfaces: 1,3
                LAG100 -> Interfaces: 2,4
            SW2>
                LAG100 -> Interfaces: 1,2
        Expected behaviour:
            Interface 1 should not be in Collecting/Distributing
            state in neither switch.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw1_lag_id = '100'
    sw1_lag_id_2 = '200'
    sw2_lag_id = '100'

    assert sw1 is not None
    assert sw2 is not None

    p11 = sw1.ports['1']
    p12 = sw1.ports['2']
    p13 = sw1.ports['3']
    p14 = sw1.ports['4']
    p21 = sw2.ports['1']
    p22 = sw2.ports['2']
    p23 = sw2.ports['3']
    p24 = sw2.ports['4']

    print("Turning on all interfaces used in this test")
    ports_sw1 = [p11, p12, p13, p14]
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    ports_sw2 = [p21, p22, p23, p24]
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    print("Waiting for interfaces to turn on")
    time.sleep(60)

    print("Validate interfaces are turn on")
    validate_turn_on_interfaces(sw1, ports_sw1)
    validate_turn_on_interfaces(sw2, ports_sw2)

    print("Create LAG in both switches")
    create_lag_active(sw1, sw1_lag_id)
    create_lag_active(sw2, sw2_lag_id)

    set_lacp_rate_fast(sw1, sw1_lag_id)
    set_lacp_rate_fast(sw2, sw2_lag_id)

    print("Associate interfaces [1,2] to lag in both switches")
    associate_interface_to_lag(sw1, p11, sw1_lag_id)
    associate_interface_to_lag(sw1, p12, sw1_lag_id)
    associate_interface_to_lag(sw2, p21, sw2_lag_id)
    associate_interface_to_lag(sw2, p22, sw2_lag_id)

    # Without this sleep time, we are validating temporary
    # states in state machines
    print("Waiting for LAG negotations between switches")
    time.sleep(80)

    print("Get information for LAG in interface 1 with both switches")
    map_lacp_sw1 = sw1.libs.vtysh.show_lacp_interface(p11)
    map_lacp_sw2 = sw2.libs.vtysh.show_lacp_interface(p21)

    print("Get the state of LAGs using diag-dump lacp basic in both switches")
    sw1_lacp_state = get_diagdump_lacp_state(sw1)
    sw2_lacp_state = get_diagdump_lacp_state(sw2)
    map_diagdump_lacp_sw1_p11 = sw1_lacp_state[str(sw1_lag_id)][int(p11)]
    map_diagdump_lacp_sw2_p21 = sw2_lacp_state[str(sw2_lag_id)][int(p21)]

    print("Get the configured interfaces for each LAG using diag-dump " +
          "lacp basic in both switches")
    sw1_lacp_interfaces = get_diagdump_lacp_interfaces(sw1)
    sw2_lacp_interfaces = get_diagdump_lacp_interfaces(sw2)
    validate_diagdump_lacp_interfaces(sw1_lacp_interfaces, sw1_lag_id,
                                      [p11, p12], [p11, p12], [p11, p12])
    validate_diagdump_lacp_interfaces(sw2_lacp_interfaces, sw2_lag_id,
                                      [p21, p22], [p21, p22], [p21, p22])

    print("Validate the LAG was created in both switches")
    validate_lag_name(map_lacp_sw1, sw1_lag_id)
    validate_local_key(map_lacp_sw1, sw1_lag_id)
    validate_remote_key(map_lacp_sw1, sw2_lag_id)
    validate_lag_state_sync(map_lacp_sw1, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw1, REMOTE_STATE)
    # Validate diag-dump results
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw1_p11,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw1_p11,
                                     DIAG_DUMP_REMOTE_STATE)

    validate_lag_name(map_lacp_sw2, sw2_lag_id)
    validate_local_key(map_lacp_sw2, sw2_lag_id)
    validate_remote_key(map_lacp_sw2, sw1_lag_id)
    validate_lag_state_sync(map_lacp_sw2, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw2, REMOTE_STATE)
    # Validate diag-dump results
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw2_p21,
                                     DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw2_p21,
                                     DIAG_DUMP_REMOTE_STATE)

    print("Changing interface 1 to lag 200 in switch 1")
    create_lag_active(sw1, sw1_lag_id_2)
    set_lacp_rate_fast(sw1, sw1_lag_id_2)
    associate_interface_to_lag(sw1, p11, sw1_lag_id_2)
    associate_interface_to_lag(sw1, p13, sw1_lag_id_2)
    associate_interface_to_lag(sw1, p14, sw1_lag_id)

    # Waiting for switch 1 to update LAG status with newest configuration
    print("Waiting for LAG update withe new configuration")
    time.sleep(30)

    print("Get information from LAG in interface 1 with both switches")
    map_lacp_sw1_p11 = sw1.libs.vtysh.show_lacp_interface(p11)
    map_lacp_sw1_p12 = sw1.libs.vtysh.show_lacp_interface(p12)
    map_lacp_sw1_p13 = sw1.libs.vtysh.show_lacp_interface(p13)
    map_lacp_sw1_p14 = sw1.libs.vtysh.show_lacp_interface(p14)
    map_lacp_sw2_p21 = sw2.libs.vtysh.show_lacp_interface(p21)
    map_lacp_sw2_p22 = sw2.libs.vtysh.show_lacp_interface(p22)

    print("Get the state of LAGs using diag-dump lacp basic in both switches")
    sw1_lacp_state = get_diagdump_lacp_state(sw1)
    sw2_lacp_state = get_diagdump_lacp_state(sw2)
    map_diagdump_lacp_sw1_p11 = sw1_lacp_state[str(sw1_lag_id_2)][int(p11)]
    map_diagdump_lacp_sw1_p12 = sw1_lacp_state[str(sw1_lag_id)][int(p12)]
    map_diagdump_lacp_sw2_p21 = sw2_lacp_state[str(sw2_lag_id)][int(p21)]
    map_diagdump_lacp_sw2_p22 = sw2_lacp_state[str(sw2_lag_id)][int(p22)]

    print("Get the configured interfaces for each LAG using diagdump " +
          "getlacpinterfaces in both switches")
    sw1_lacp_interfaces = get_diagdump_lacp_interfaces(sw1)
    sw2_lacp_interfaces = get_diagdump_lacp_interfaces(sw2)
    validate_diagdump_lacp_interfaces(sw1_lacp_interfaces, sw1_lag_id,
                                      [p12, p24], [p12, p24], [p12])
    validate_diagdump_lacp_interfaces(sw1_lacp_interfaces, sw1_lag_id_2,
                                      [p11, p13], [p11, p13], [])
    validate_diagdump_lacp_interfaces(sw2_lacp_interfaces, sw2_lag_id,
                                      [p21, p22], [p21, p22], [p22])

    print("Validate lag is out of sync in interface 1 in both switches")
    validate_lag_name(map_lacp_sw1_p11, sw1_lag_id_2)
    validate_local_key(map_lacp_sw1_p11, sw1_lag_id_2)
    validate_remote_key(map_lacp_sw1_p11, sw2_lag_id)
    validate_lag_state_afn(map_lacp_sw1_p11, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw1_p12, LOCAL_STATE)
    validate_lag_state_default_neighbor(map_lacp_sw1_p13, LOCAL_STATE)
    validate_lag_state_default_neighbor(map_lacp_sw1_p14, LOCAL_STATE)
    # Validate diag-dump results
    validate_diagdump_lag_state_afn(map_diagdump_lacp_sw1_p11,
                                    DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw1_p12,
                                     DIAG_DUMP_LOCAL_STATE)

    validate_lag_name(map_lacp_sw2_p21, sw2_lag_id)
    validate_local_key(map_lacp_sw2_p21, sw2_lag_id)
    validate_remote_key(map_lacp_sw2_p21, sw1_lag_id_2)
    validate_lag_state_out_of_sync(map_lacp_sw2_p21, LOCAL_STATE)
    validate_lag_state_sync(map_lacp_sw2_p22, LOCAL_STATE)
    # Validate diag-dump results
    validate_diagdump_lag_state_out_sync(map_diagdump_lacp_sw2_p21,
                                         DIAG_DUMP_LOCAL_STATE)
    validate_diagdump_lag_state_sync(map_diagdump_lacp_sw2_p22,
                                     DIAG_DUMP_LOCAL_STATE)
コード例 #21
0
def test_dynamic_maximum_members(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3', '4', '5', '6', '7', '8', '9']

    lag_id = '1'
    vlan_id = '900'
    mode_active = 'active'
    mode_passive = 'passive'

    step("### Mapping interfaces from Docker ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:9]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:9]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1:9], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[1:9], mode=mode_passive)

    step("#### Configure VLANs on switches ####")
    create_vlan(sw1, vlan_id)
    create_vlan(sw2, vlan_id)

    associate_vlan_to_l2_interface(sw1, vlan_id, ports_sw1[0])
    associate_vlan_to_lag(sw1, vlan_id, lag_id)

    associate_vlan_to_l2_interface(sw2, vlan_id, ports_sw2[0])
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:9], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:9], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("#### Delete LAG ####")
    delete_lag(sw1, lag_id)
    delete_lag(sw2, lag_id)

    step("#### Negative Test ping between clients ###")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)
コード例 #22
0
def test_lag_shutdown_enabled(topology, step):
    """Test LAG with shutdown enabled.

    When lag shutdown is enabled IPv4 ping must be unsuccessful, after
    configuring LAGs as no shutdown IPv4 ping must be successful
    """

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    sw1_lag_id = '100'
    sw2_lag_id = '200'
    h1_ip_address = '10.0.0.1'
    h2_ip_address = '10.0.0.2'
    vlan = '100'
    mask = '/24'

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    step("Configure IP and bring UP in host 1")
    hs1.libs.ip.interface('1', addr=h1_ip_address + mask, up=True)

    step("Configure IP and bring UP in host 2")
    hs2.libs.ip.interface('1', addr=h2_ip_address + mask, up=True)

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Validate interfaces are turn on")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("Create LAG in both switches")
    create_lag_passive(sw1, sw1_lag_id)
    create_lag_active(sw2, sw2_lag_id)

    step("Configure vlan and switch interfaces")
    create_vlan(sw1, vlan)
    create_vlan(sw2, vlan)

    step("Associate vlan with lag in both switches")
    associate_vlan_to_lag(sw1, vlan, sw1_lag_id)
    associate_vlan_to_lag(sw2, vlan, sw2_lag_id)

    step("Associate vlan with l2 interfaces in both switches")
    associate_vlan_to_l2_interface(sw1, vlan, ports_sw1[0])
    associate_vlan_to_l2_interface(sw2, vlan, ports_sw2[0])

    step("Associate interfaces [2,3] to lag in both switches")
    for port in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, port, sw1_lag_id)
    for port in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, port, sw2_lag_id)

    step("Verify LAG configuration")
    verify_lag_config(sw1, sw1_lag_id, ports_sw1[1:3], mode='passive')
    verify_lag_config(sw2, sw2_lag_id, ports_sw2[1:3], mode='active')

    step("Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:3], LOCAL_STATE, 'passive')
    verify_state_sync_lag(sw1, ports_sw1[1:3], REMOTE_STATE, 'active')

    step("Test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, True)

    step("Turn off LAG in SW1")
    lag_shutdown(sw1, sw1_lag_id)

    step("Negative test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, False)

    step("Turn off LAG in SW2")
    lag_shutdown(sw2, sw2_lag_id)

    step("Negative test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, False)

    step("Verify all interface are down")
    verify_turn_off_interfaces(sw1, ports_sw1[1:3])
    verify_turn_off_interfaces(sw2, ports_sw2[1:3])

    step("Turn on LAG")
    lag_no_shutdown(sw1, sw1_lag_id)
    lag_no_shutdown(sw2, sw2_lag_id)

    step("Verify all interface are up")
    verify_turn_on_interfaces(sw1, ports_sw1[1:3])
    verify_turn_on_interfaces(sw2, ports_sw2[1:3])

    step("Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:3], LOCAL_STATE, 'passive')
    verify_state_sync_lag(sw1, ports_sw1[1:3], REMOTE_STATE, 'active')

    step("Test connectivity between hosts")
    check_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                     10, True)
def test_dynamic_modify_minimum_members(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3', '4']

    lag_id = '1'
    vlan_id = '900'
    mode_active = 'active'
    mode_passive = 'passive'

    step("### Mapping interfaces ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:4]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:4]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1:4], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[1:4], mode=mode_passive)

    step("#### Configure VLANs on switches ####")
    create_vlan(sw1, vlan_id)
    create_vlan(sw2, vlan_id)

    associate_vlan_to_l2_interface(sw1, vlan_id, ports_sw1[0])
    associate_vlan_to_lag(sw1, vlan_id, lag_id)

    associate_vlan_to_l2_interface(sw2, vlan_id, ports_sw2[0])
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:4], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:4], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("### Remove one interface from each LAG ###")
    remove_interface_from_lag(sw1, ports_sw1[1], lag_id)
    remove_interface_from_lag(sw2, ports_sw2[1], lag_id)

    step("### Validate if the interface was removed of LAG ###")
    validate_interface_not_in_lag(sw1, ports_sw1[1], lag_id)
    validate_interface_not_in_lag(sw2, ports_sw2[1], lag_id)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[2:4], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[2:4], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("### Turning on interface ###")
    turn_on_interface(sw1, ports_sw1[1])
    turn_on_interface(sw2, ports_sw2[1])

    step("### Validate interface is turn on ###")
    verify_turn_on_interfaces(sw1, ports_sw1[1])
    verify_turn_on_interfaces(sw2, ports_sw2[1])

    step("### Add back the interface ###")
    associate_interface_to_lag(sw1, ports_sw1[1], lag_id)
    associate_interface_to_lag(sw2, ports_sw2[1], lag_id)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:4], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:4], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("### Remove all the interfaces from the LAGs ###")
    for intf in ports_sw1[1:4]:
        remove_interface_from_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:4]:
        remove_interface_from_lag(sw2, intf, lag_id)

    step("### Verify if the interfaces were removed from the LAGs ###")
    for intf in ports_sw1[1:4]:
        validate_interface_not_in_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:4]:
        validate_interface_not_in_lag(sw2, intf, lag_id)

    step("#### Negative test ping between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1[1:4]:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2[1:4]:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:4]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:4]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:4], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:4], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("### Remove two the interfaces from the LAGs ###")
    for intf in ports_sw1[1:3]:
        remove_interface_from_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:3]:
        remove_interface_from_lag(sw2, intf, lag_id)

    step("### Verify if the interfaces were removed from the LAGs ###")
    for intf in ports_sw1[1:3]:
        validate_interface_not_in_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:3]:
        validate_interface_not_in_lag(sw2, intf, lag_id)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[3], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[3], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1[1:3]:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2[1:3]:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("### Add back the interface ###")
    for intf in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw1[1:3]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[1:4], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[1:4], REMOTE_STATE, mode_passive)

    step("#### Test ping between clients work ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     True)
コード例 #24
0
def test_show_lacp_interface_case_1(topology, step):
    """
    Case 1:
        Verify the correct output when running the command show lacp
        interface when LAG is changed from dynamic to static
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    lag_id = '1'
    agg_name = 'lag' + lag_id

    assert sw1 is not None
    assert sw2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2']

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Verify all interface are up")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    mac_addr_sw1 = sw1.libs.vtysh.show_interface('1')['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface('1')['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2, \
        'Mac address of interfaces in sw1 is equal to mac address of ' + \
        'interfaces in sw2. This is a test framework problem. Dynamic ' + \
        'LAGs cannot work properly under this condition. Refer to Taiga ' + \
        'issue #1251.'

    step("Create LAG in both switches")
    create_lag(sw1, lag_id, 'active')
    create_lag(sw2, lag_id, 'active')

    step("Associate interfaces [1, 2] to LAG in both switches")
    for intf in ports_sw1[0:2]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[0:2]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("Verify show lacp interfaces")
    output = sw1.libs.vtysh.show_lacp_interface()
    assert output['actor']['1']['agg_name'] == agg_name,\
        "Interface 1 is not in LAG 10"
    assert output['actor']['2']['agg_name'] == agg_name,\
        "Interface 2 is not in LAG 10"
    assert output['partner']['1']['agg_name'] == agg_name,\
        "Interface 1 is not in LAG 20"
    assert output['partner']['2']['agg_name'] == agg_name,\
        "Interface 2 is not in LAG 20"

    step("Set lacp mode to 'off' on both switches")
    lag_no_active(sw1, lag_id)
    lag_no_active(sw2, lag_id)

    step("Verify show lacp interfaces")
    """
    Only interface and aggregation name should be present
    lacpd state should be erased (false)
    """
    output = sw1.libs.vtysh.show_lacp_interface()
    for actor_partner in output:
        for intf in output[actor_partner]:
            assert output[actor_partner][intf]['intf'] == intf,\
                "Key intf should be 1"
            assert output[actor_partner][intf]['agg_name'] == agg_name,\
                "Key agg_name should be %s" % agg_name
            assert output[actor_partner][intf]['port_id'] == '',\
                "Key port_id should be empty"
            assert output[actor_partner][intf]['port_priority'] == '',\
                "Key port_priority should be empty"
            assert output[actor_partner][intf]['key'] == '',\
                "Key key should be empty"
            assert output[actor_partner][intf]['system_id'] == '',\
                "Key system_id should be empty"
            assert output[actor_partner][intf]['system_priority'] == '',\
                "Key system_priority should be empty"
            for flag in output[actor_partner][intf]['state']:
                assert output[actor_partner][intf]['state'][flag] is False,\
                    "Actor state shoud be false"
def test_static_minimum_members(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    lag_id = '1'
    vlan_id = '900'

    step("### Mapping interfaces ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[1:3]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[1:3]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1:3])
    verify_lag_config(sw2, lag_id, ports_sw2[1:3])

    step("#### Configure VLANs on switches ####")
    create_vlan(sw1, vlan_id)
    create_vlan(sw2, vlan_id)

    associate_vlan_to_l2_interface(sw1, vlan_id, ports_sw1[0])
    associate_vlan_to_lag(sw1, vlan_id, lag_id)

    associate_vlan_to_l2_interface(sw2, vlan_id, ports_sw2[0])
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)

    step("#### Test ping between clients work ####")
    verify_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11')

    step("### Delete LAGs ###")
    delete_lag(sw1, lag_id)
    delete_lag(sw2, lag_id)

    step("#### Negative test ping between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Associate one interface to LAG ####")
    associate_interface_to_lag(sw1, ports_sw1[1], lag_id)
    associate_interface_to_lag(sw2, ports_sw2[1], lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[1])
    verify_lag_config(sw2, lag_id, ports_sw2[1])

    step("### Associate Vlan to LAG")
    associate_vlan_to_lag(sw1, vlan_id, lag_id)
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("#### Test ping between clients ####")
    verify_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11')

    step("### Delete LAGs ###")
    delete_lag(sw1, lag_id)
    delete_lag(sw2, lag_id)

    step("#### Negative test ping between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)

    step("##### Create LAGs without interfaces ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Negative test ping between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)

    step("### Delete LAGs ###")
    delete_lag(sw1, lag_id)
    delete_lag(sw2, lag_id)

    step("#### Negative test ping between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11', 5,
                                     False)
コード例 #26
0
def test_l3_dynamic_lag_ping_case_1(topology, step):
    """
    Case 1:
        Verify a simple ping works properly between 2 switches configured
        with L3 dynamic LAGs. Each LAG having 3 interfaces.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')

    step('### Verifying switches are not None ###')
    assert sw1 is not None, 'Topology failed getting object sw1'
    assert sw2 is not None, 'Topology failed getting object sw2'

    lag_id = '1'
    sw1_lag_ip_address = '10.0.0.1'
    sw2_lag_ip_address = '10.0.0.2'
    ip_address_mask = '24'
    mode_active = 'active'
    mode_passive = 'passive'

    ports_sw1 = list()
    ports_sw2 = list()
    # Remove unused port 3
    port_labels = ['1', '2']

    step("### Mapping interfaces from Docker ###")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    step("### Turning on all interfaces used in this test ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turned on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    # Modify hardcoded interfaces for dynamic interfaces
    mac_addr_sw1 = sw1.libs.vtysh.show_interface('1')['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface('1')['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2,\
        'Mac address of interfaces in sw1 is equal to mac address of ' +\
        'interfaces in sw2. This is a test framework problem. Dynamic ' +\
        'LAGs cannot work properly under this condition. Refer to Taiga ' +\
        'issue #1251.'

    step("### Create LAG in both switches ###")
    create_lag(sw1, lag_id, 'active')
    create_lag(sw2, lag_id, 'passive')

    step("### Set LACP rate to fast ###")
    set_lacp_rate_fast(sw1, lag_id)
    set_lacp_rate_fast(sw2, lag_id)

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("### Assign IP to LAGs ###")
    assign_ip_to_lag(sw1, lag_id, sw1_lag_ip_address, ip_address_mask)
    assign_ip_to_lag(sw2, lag_id, sw2_lag_ip_address, ip_address_mask)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1,
                      lag_id,
                      ports_sw1,
                      heartbeat_rate='fast',
                      mode=mode_active)
    verify_lag_config(sw2,
                      lag_id,
                      ports_sw2,
                      heartbeat_rate='fast',
                      mode=mode_passive)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1, LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1, REMOTE_STATE, mode_passive)
    verify_state_sync_lag(sw2, ports_sw2, LOCAL_STATE, mode_passive)
    verify_state_sync_lag(sw2, ports_sw2, REMOTE_STATE, mode_active)

    step("### Get information for LAG in interface 1 with both switches ###")
    map_lacp_sw1 = sw1.libs.vtysh.show_lacp_interface(ports_sw1[0])
    map_lacp_sw2 = sw2.libs.vtysh.show_lacp_interface(ports_sw2[0])

    step("### Validate the LAG was created in both switches ###")
    validate_local_key(map_lacp_sw1, lag_id)
    validate_remote_key(map_lacp_sw1, lag_id)
    validate_local_key(map_lacp_sw2, lag_id)
    validate_remote_key(map_lacp_sw2, lag_id)

    step("#### Test ping between switches work ####")
    verify_connectivity_between_switches(sw1,
                                         sw1_lag_ip_address,
                                         sw2,
                                         sw2_lag_ip_address,
                                         success=True)
def test_l2_l3_interface_switch_case_1(topology, step):
    """
    Case 1:
        This test verifies the functionality of 2 LAGs when an interface is
        changed from a L2 LAG to a L3 LAG and viceversa.
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ip_address_mask = '24'
    hs1_ip_address = '10.0.10.1'
    hs2_ip_address = '10.0.10.2'
    hs1_ip_address_with_mask = hs1_ip_address + '/' + ip_address_mask
    hs2_ip_address_with_mask = hs2_ip_address + '/' + ip_address_mask
    sw1_l3_lag_ip_address = '10.0.0.1'
    sw2_l3_lag_ip_address = '10.0.0.2'
    l2_lag_id = '2'
    l3_lag_id = '3'
    vlan_identifier = '8'

    ports_sw1 = list()
    ports_sw2 = list()

    step("Mapping interfaces")
    for port in port_labels:
        ports_sw1.append(sw1.ports[port])
        ports_sw2.append(sw2.ports[port])
    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()

    p11 = ports_sw1[0]
    p12 = ports_sw1[1]
    p13 = ports_sw1[2]
    p14 = ports_sw1[3]
    p21 = ports_sw2[0]
    p22 = ports_sw2[1]
    p23 = ports_sw2[2]
    p24 = ports_sw2[3]

    step("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("Verify all interface are up")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    step("Assign an IP address on the same range to each workstation")
    hs1.libs.ip.interface('1', addr=hs1_ip_address_with_mask, up=True)
    hs2.libs.ip.interface('1', addr=hs2_ip_address_with_mask, up=True)

    step('Creating VLAN in both switches')
    create_vlan(sw1, vlan_identifier)
    create_vlan(sw2, vlan_identifier)

    step("Create L2 LAG in both switches")
    create_lag(sw1, l2_lag_id, 'off')
    create_lag(sw2, l2_lag_id, 'off')

    step("Associate interfaces [1, 2] to L2 LAG in both switches")
    associate_interface_to_lag(sw1, p11, l2_lag_id)
    associate_interface_to_lag(sw1, p12, l2_lag_id)
    associate_interface_to_lag(sw2, p21, l2_lag_id)
    associate_interface_to_lag(sw2, p22, l2_lag_id)

    step("Verify LAG configuration")
    verify_lag_config(sw1, l2_lag_id, [p11, p12])
    verify_lag_config(sw2, l2_lag_id, [p21, p22])

    step("Create L3 LAG in both switches")
    create_lag(sw1, l3_lag_id, 'off')
    create_lag(sw2, l3_lag_id, 'off')

    step("Associate interface 3 to L3 LAG in both switches")
    associate_interface_to_lag(sw1, p13, l3_lag_id)
    associate_interface_to_lag(sw2, p23, l3_lag_id)

    step("Verify LAG configuration")
    verify_lag_config(sw1, l3_lag_id, [p13])
    verify_lag_config(sw2, l3_lag_id, [p23])

    step("Configure LAGs and workstations interfaces with same VLAN")
    associate_vlan_to_lag(sw1, vlan_identifier, l2_lag_id)
    associate_vlan_to_lag(sw2, vlan_identifier, l2_lag_id)
    associate_vlan_to_l2_interface(sw1, vlan_identifier, p14)
    associate_vlan_to_l2_interface(sw2, vlan_identifier, p24)

    step("Assign IP on the same range to LAG in both switches")
    assign_ip_to_lag(sw1, l3_lag_id, sw1_l3_lag_ip_address, ip_address_mask)
    assign_ip_to_lag(sw2, l3_lag_id, sw2_l3_lag_ip_address, ip_address_mask)

    step("Test ping between clients work")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
    verify_connectivity_between_switches(sw1, sw1_l3_lag_ip_address, sw2,
                                         sw2_l3_lag_ip_address)

    step("Associate interface 2 to L3 LAG in both switches")
    associate_interface_to_lag(sw1, p12, l3_lag_id)
    associate_interface_to_lag(sw2, p22, l3_lag_id)

    step("Test ping between clients work")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
    verify_connectivity_between_switches(sw1, sw1_l3_lag_ip_address, sw2,
                                         sw2_l3_lag_ip_address)

    step("Associate interface 2 to L2 LAG in both switches")
    associate_interface_to_lag(sw1, p12, l2_lag_id)
    associate_interface_to_lag(sw2, p22, l2_lag_id)

    step("Test ping between clients work")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
    verify_connectivity_between_switches(sw1, sw1_l3_lag_ip_address, sw2,
                                         sw2_l3_lag_ip_address)

    step("Remove interface 2 from L2 LAG in both switches")
    remove_interface_from_lag(sw1, p12, l2_lag_id)
    remove_interface_from_lag(sw2, p22, l2_lag_id)

    step("Associate interface 2 to L3 LAG in both switches")
    associate_interface_to_lag(sw1, p12, l3_lag_id)
    associate_interface_to_lag(sw2, p22, l3_lag_id)

    step("Test ping between clients work")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
    verify_connectivity_between_switches(sw1, sw1_l3_lag_ip_address, sw2,
                                         sw2_l3_lag_ip_address)

    step("Remove interface 2 from L3 LAG in both switches")
    remove_interface_from_lag(sw1, p12, l3_lag_id)
    remove_interface_from_lag(sw2, p22, l3_lag_id)

    step("Associate interface 2 to L2 LAG in both switches")
    associate_interface_to_lag(sw1, p12, l2_lag_id)
    associate_interface_to_lag(sw2, p22, l2_lag_id)

    step("Test ping between clients work")
    verify_connectivity_between_hosts(hs1, hs1_ip_address, hs2, hs2_ip_address)
    verify_connectivity_between_switches(sw1, sw1_l3_lag_ip_address, sw2,
                                         sw2_l3_lag_ip_address)
def test_static_negative_tag_untag_vlan(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs3 = topology.get('hs3')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None
    assert hs3 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3', '4']

    lag_id = '1'
    vlans_id = ['800', '900']

    step("### Mapping interfaces ###")
    for port in port_labels[:3]:
        ports_sw1.append(sw1.ports[port])

    for port in port_labels:
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    mac_addr_sw1 = sw1.libs.vtysh.show_interface(1)['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface(1)['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2, \
        'Mac address of interfaces in sw1 is equal to mac address of ' + \
        'interfaces in sw2. This is a test framework problem. Dynamic ' + \
        'LAGs cannot work properly under this condition. Refer to Taiga ' + \
        'issue #1251.'

    step("##### Create LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[0:2]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[0:2]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[0:2])
    verify_lag_config(sw2, lag_id, ports_sw2[0:2])

    step("#### Configure VLANs on switches ####")
    for vlan in vlans_id:
        create_vlan(sw1, vlan)
        create_vlan(sw2, vlan)

    step("### Tagged VLANs on LAG interfaces")
    tagged_vlan_to_lag(sw1, vlans_id, lag_id)
    tagged_vlan_to_lag(sw2, vlans_id, lag_id)

    associate_vlan_to_l2_interface(sw1, vlans_id[0], ports_sw1[2])
    associate_vlan_to_l2_interface(sw2, vlans_id[0], ports_sw2[2])
    associate_vlan_to_l2_interface(sw2, vlans_id[1], ports_sw2[3])

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='140.1.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='140.1.1.11/24', up=True)
    hs3.libs.ip.interface('1', addr='140.1.1.12/24', up=True)

    step("#### Test ping between clients in the same vlan ####")
    verify_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11')

    step("#### Test ping between clients in the different vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12',
                                     5, False)

    step("### Move one WS to the VLAN with the single workstation ###")
    associate_vlan_to_l2_interface(sw1, vlans_id[1], ports_sw1[2])

    step("#### Test ping between clients in the same vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12',
                                     5, True)

    step("### Untag VLANs on LAG Interfaces ###")
    no_tagged_vlan_to_tag(sw1, vlans_id, lag_id)
    no_tagged_vlan_to_tag(sw2, vlans_id, lag_id)

    step("#### Test ping failed between clients ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11',
                                     5, False)
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12',
                                     5, False)

    step("### Re Associate VLANs to Lag ###")
    associate_vlan_to_lag(sw1, vlans_id[1], lag_id, no_routing=False)
    associate_vlan_to_lag(sw2, vlans_id[1], lag_id, no_routing=False)

    step("#### Test ping between clients in the same vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12',
                                     5, True)
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11',
                                     5, False)

    step("### Re Tagged VLANs on LAG interfaces")
    tagged_vlan_to_lag(sw1, vlans_id, lag_id, no_routing=False)
    tagged_vlan_to_lag(sw2, vlans_id, lag_id, no_routing=False)

    step("#### Test ping between clients in the same vlan ####")
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs2, '140.1.1.11',
                                     5, False)
    check_connectivity_between_hosts(hs1, '140.1.1.10', hs3, '140.1.1.12',
                                     5, True)
コード例 #29
0
def test_static_dynamic_tag_vlan(topology, step):

    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')

    assert sw1 is not None
    assert sw2 is not None
    assert hs1 is not None
    assert hs2 is not None

    ports_sw1 = list()
    ports_sw2 = list()
    port_labels = ['1', '2', '3']

    lag_id = '1'
    vlan_id = '10'
    mode_active = 'active'
    mode_passive = 'passive'

    step("### Mapping interfaces ###")
    for port in port_labels[:3]:
        ports_sw1.append(sw1.ports[port])

    for port in port_labels[:3]:
        ports_sw2.append(sw2.ports[port])

    step("#### Turning on interfaces in sw1 ###")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    step("#### Turning on interfaces in sw2 ###")
    for port in ports_sw2:
        turn_on_interface(sw2, port)

    step("#### Validate interfaces are turn on ####")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)

    mac_addr_sw1 = sw1.libs.vtysh.show_interface(1)['mac_address']
    mac_addr_sw2 = sw2.libs.vtysh.show_interface(1)['mac_address']
    assert mac_addr_sw1 != mac_addr_sw2, \
        'Mac address of interfaces in sw1 is equal to mac address of ' + \
        'interfaces in sw2. This is a test framework problem. Dynamic ' + \
        'LAGs cannot work properly under this condition. Refer to Taiga ' + \
        'issue #1251.'

    step("##### Create static LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Associate Interfaces to LAG ####")
    for intf in ports_sw1[0:2]:
        associate_interface_to_lag(sw1, intf, lag_id)

    for intf in ports_sw2[0:2]:
        associate_interface_to_lag(sw2, intf, lag_id)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[0:2])
    verify_lag_config(sw2, lag_id, ports_sw2[0:2])

    step("#### Configure VLANs on switches ####")
    create_vlan(sw1, vlan_id)
    create_vlan(sw2, vlan_id)

    associate_vlan_to_lag(sw1, vlan_id, lag_id)
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    step("### Associate VLAN to L2 Interface ###")
    associate_vlan_to_l2_interface(sw1, vlan_id, ports_sw1[2])
    associate_vlan_to_l2_interface(sw2, vlan_id, ports_sw2[2])

    step("#### Configure workstations ####")
    hs1.libs.ip.interface('1', addr='192.168.1.10/24', up=True)
    hs2.libs.ip.interface('1', addr='192.168.1.11/24', up=True)

    step("#### Test ping between clients in the same vlan ####")
    verify_connectivity_between_hosts(hs1, '192.168.1.10', hs2, '192.168.1.11')

    step("##### Recreate static LAGs ####")
    create_lag(sw1, lag_id, 'off')
    create_lag(sw2, lag_id, 'off')

    step("#### Test ping between clients in the same vlan ####")
    verify_connectivity_between_hosts(hs1, '192.168.1.10', hs2, '192.168.1.11')

    step("##### Create dynamic LAGs ####")
    create_lag(sw1, lag_id, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[0:2], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[0:2], mode=mode_passive)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[0:2], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[0:2], REMOTE_STATE, mode_passive)

    check_connectivity_between_hosts(hs1, '192.168.1.10', hs2, '192.168.1.11',
                                     5, True)

    step("##### Recreate dynamic LAGs ####")
    create_lag(sw1, lag_id, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1, lag_id, ports_sw1[0:2], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[0:2], mode=mode_passive)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1[0:2], LOCAL_STATE, mode_active)
    verify_state_sync_lag(sw1, ports_sw1[0:2], REMOTE_STATE, mode_passive)

    check_connectivity_between_hosts(hs1, '192.168.1.10', hs2, '192.168.1.11',
                                     5, True)
コード例 #30
0
def test_lacp_aggregation_key_with_hosts(topology):
    """
    Case 1:
        A single switch should form LAGs to 2 different
        other switches as long as the aggregation key is
        the same through members of a single LAG, but
        ports should be blocked if 1 of the members is
        configured to be a member of the LAG going to a different switch
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')
    sw3 = topology.get('sw3')
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    hs3 = topology.get('hs3')

    assert sw1 is not None
    assert sw2 is not None

    sw1_lag_id = '10'
    sw2_lag_id = '20'
    sw3_lag_id = '310'  # With switch 1
    sw3_lag_id_2 = '320'  # With switch 2
    sw1_vlan = '100'
    sw2_vlan = '200'
    sw3_sw1_vlan = '100'
    sw3_sw2_vlan = '200'
    hs1_ip = '10.0.10.1'
    hs2_ip = '10.0.20.1'
    hs3_ip_1 = '10.0.10.2'
    hs3_ip_2 = '10.0.20.2'
    mask = '/24'

    ports_sw1 = list()
    ports_sw2 = list()
    ports_sw3 = list()

    print("Mapping interfaces")
    for port in port_labels[0:3]:
        ports_sw1.append(sw1.ports[port])
    for port in port_labels[0:2]:
        ports_sw2.append(sw2.ports[port])
    for port in port_labels:
        ports_sw3.append(sw3.ports[port])

    step("Sorting the port list")
    ports_sw1.sort()
    ports_sw2.sort()
    ports_sw3.sort()

    p13h = ports_sw1[2]
    p22h = ports_sw2[1]
    p32 = ports_sw3[1]
    p34h = ports_sw3[3]

    print("Turning on all interfaces used in this test")
    for port in ports_sw1:
        turn_on_interface(sw1, port)

    for port in ports_sw2:
        turn_on_interface(sw2, port)

    for port in ports_sw3:
        turn_on_interface(sw3, port)

    print("Verify all interface are up")
    verify_turn_on_interfaces(sw1, ports_sw1)
    verify_turn_on_interfaces(sw2, ports_sw2)
    verify_turn_on_interfaces(sw3, ports_sw3)

    step("Create LAG in all switches")
    create_lag_active(sw1, sw1_lag_id)
    create_lag_active(sw2, sw2_lag_id)
    create_lag_active(sw3, sw3_lag_id)
    create_lag_active(sw3, sw3_lag_id_2)

    set_lacp_rate_fast(sw1, sw1_lag_id)
    set_lacp_rate_fast(sw2, sw2_lag_id)
    set_lacp_rate_fast(sw3, sw3_lag_id)
    set_lacp_rate_fast(sw3, sw3_lag_id_2)

    step("Associate interfaces with LAG")
    for intf in ports_sw1[0:2]:
        associate_interface_to_lag(sw1, intf, sw1_lag_id)
    associate_interface_to_lag(sw2, ports_sw2[0], sw2_lag_id)
    for intf in ports_sw3[0:2]:
        associate_interface_to_lag(sw3, intf, sw3_lag_id)
    associate_interface_to_lag(sw3, ports_sw3[2], sw3_lag_id_2)

    step("Configure IP and bring UP in host 1")
    hs1.libs.ip.interface('1', addr=(hs1_ip + mask), up=True)

    step("Configure IP and bring UP in host 2")
    hs2.libs.ip.interface('1', addr=(hs2_ip + mask), up=True)

    step("Configure IP and bring UP in host 3")
    hs3.libs.ip.interface('1', addr=(hs3_ip_1 + mask), up=True)

    create_vlan(sw1, sw1_vlan)
    create_vlan(sw2, sw2_vlan)
    create_vlan(sw3, sw3_sw1_vlan)
    create_vlan(sw3, sw3_sw2_vlan)

    associate_vlan_to_lag(sw1, sw1_vlan, sw1_lag_id)
    associate_vlan_to_lag(sw2, sw2_vlan, sw2_lag_id)
    associate_vlan_to_lag(sw3, sw3_sw1_vlan, sw3_lag_id)
    associate_vlan_to_lag(sw3, sw3_sw2_vlan, sw3_lag_id_2)

    # First associate Host 3 with Vlan from Switch 1
    step("Configure connection between Host 1 and 3")
    associate_vlan_to_l2_interface(sw1, sw1_vlan, p13h)
    associate_vlan_to_l2_interface(sw3, sw3_sw1_vlan, p34h)

    validate_vlan_state(sw1, sw1_vlan, "up")
    validate_vlan_state(sw3, sw3_sw1_vlan, "up")

    step("#### Test ping between clients work ####")
    verify_connectivity_between_hosts(hs1, hs1_ip, hs3, hs3_ip_1)

    # Then associate Host 3 with Vlan from Switch 2
    step("Configure connection between Host 2 and 3")
    associate_vlan_to_l2_interface(sw2, sw2_vlan, p22h)
    associate_vlan_to_l2_interface(sw3, sw3_sw2_vlan, p34h)

    validate_vlan_state(sw2, sw2_vlan, "up")
    validate_vlan_state(sw3, sw3_sw2_vlan, "up")

    hs3.libs.ip.remove_ip('1', addr=(hs3_ip_1 + mask))
    hs3.libs.ip.interface('1', addr=(hs3_ip_2 + mask), up=True)

    step("Check connectivty between Host 2 and 3")
    verify_connectivity_between_hosts(hs2, hs2_ip, hs3, hs3_ip_2)

    step("Setting up priorities")
    with sw1.libs.vtysh.ConfigInterface(ports_sw1[0]) as ctx:
        ctx.lacp_port_priority(1)
    with sw1.libs.vtysh.ConfigInterface(ports_sw1[1]) as ctx:
        ctx.lacp_port_priority(10)
    with sw3.libs.vtysh.ConfigInterface(ports_sw3[0]) as ctx:
        ctx.lacp_port_priority(1)
    with sw3.libs.vtysh.ConfigInterface(ports_sw3[1]) as ctx:
        ctx.lacp_port_priority(10)

    step("Changing interface 2 from Switch 3 to LAG with Switch 2")
    associate_interface_to_lag(sw3, p32, sw3_lag_id_2)

    # This should get the interface Out of Sync because that
    # interface is linked with Switch 1

    # Only the link 2 should be get out of sync
    verify_state_out_of_sync_lag(sw1, [ports_sw1[1]], LOCAL_STATE)
    verify_state_out_of_sync_lag(sw3, [ports_sw3[1]], LOCAL_STATE)

    verify_state_sync_lag(sw1, [ports_sw1[0]], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw2, [ports_sw2[0]], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw3, [ports_sw3[0]], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw3, [ports_sw3[2]], LOCAL_STATE, 'active')

    step("Check connectivity between Host 2 and 3 again")
    verify_connectivity_between_hosts(hs2, hs2_ip, hs3, hs3_ip_2)

    step("Change configuration to connect Host 1 and 3 again")
    associate_vlan_to_l2_interface(sw3, sw3_sw1_vlan, p34h)

    validate_vlan_state(sw3, sw3_sw1_vlan, "up")

    hs3.libs.ip.remove_ip('1', addr=(hs3_ip_2 + mask))
    hs3.libs.ip.interface('1', addr=(hs3_ip_1 + mask), up=True)

    step("Check connectivity between Host 1 and Host 3")
    verify_connectivity_between_hosts(hs1, hs1_ip, hs3, hs3_ip_1)