def test_ft_lag_convert_to_lacp(topology, step):
    hs1 = topology.get('hs1')
    hs2 = topology.get('hs2')
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')

    assert hs1 is not None, 'hs1 was not initialized'
    assert hs2 is not None, 'hs2 was not initialized'
    assert sw1 is not None, 'sw1 was not initialized'
    assert sw2 is not None, 'sw2 was not initialized'

    sw_real_ports = {
        sw1: [sw1.ports[port] for port in SW_LBL_PORTS],
        sw2: [sw2.ports[port] for port in SW_LBL_PORTS]
    }

    step("Sorting the port list")
    sw_real_ports[sw1].sort()
    sw_real_ports[sw2].sort()

    step("Enable switches interfaces")
    enable_switches_interfaces([sw1, sw2], sw_real_ports, step)

    step("Configure static LAGs with members")
    configure_lags([sw1, sw2], sw_real_ports, step)

    step("Add VLAN configuration to LAGs and workstation interfaces")
    configure_vlans([sw1, sw2], sw_real_ports, step)

    step("Configure workstations")
    configure_workstations([hs1, hs2], sw_real_ports[sw1], step)

    step("Validate workstations can communicate")
    validate_connectivity([hs1, hs2], True, step)

    step("Change LACP mode on LAGs from static to dynamic")
    change_lacp_mode([sw1, sw2], sw_real_ports, step)

    step("### Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, sw_real_ports[sw1][0:2], LOCAL_STATE, 'active')
    verify_state_sync_lag(sw1, sw_real_ports[sw1][0:2], REMOTE_STATE,
                          'passive')

    step("Validate workstations can communicate")
    validate_connectivity([hs1, hs2], True, step)
Exemplo n.º 2
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)
Exemplo n.º 3
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])
Exemplo n.º 4
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)
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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_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)
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")
Exemplo n.º 10
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)
Exemplo n.º 11
0
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')

    assert sw1 is not None, 'Topology failed getting object sw1'
    assert sw2 is not None, 'Topology failed getting object sw2'
    assert hs1 is not None, 'Topology failed getting object hs1'
    assert hs2 is not None, 'Topology failed getting object hs2'

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

    p11h = sw1.ports['1']
    p12 = sw1.ports['2']
    p13 = sw1.ports['3']
    p21h = sw2.ports['1']
    p22 = sw2.ports['2']
    p23 = sw2.ports['3']

    ports_sw1 = [p11h, p12, p13]
    ports_sw2 = [p21h, p22, p23]

    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("#### Validate interfaces are turned 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.'

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

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

    print("#### 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)

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

    print("### 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)
    verify_state_sync_lag(sw2, ports_sw2[1:3], LOCAL_STATE, mode_passive)
    verify_state_sync_lag(sw2, ports_sw2[1:3], REMOTE_STATE, mode_active)

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

    associate_vlan_to_l2_interface(sw1, vlan_id, p11h)
    associate_vlan_to_lag(sw1, vlan_id, lag_id)

    associate_vlan_to_l2_interface(sw2, vlan_id, p21h)
    associate_vlan_to_lag(sw2, vlan_id, lag_id)

    print("#### 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)
Exemplo n.º 12
0
def test_lacp_agg_key_cross_links(topology, step):
    """
    Case 3:
        Verify LAGs should be formed independent of port ids as long
        as aggregation key is the same
        Initial Topology:
            SW1>
                LAG150 -> Interfaces: 1,5
                LAG250 -> Interfaces: 2,6
                LAG350 -> Interfaces: 3,7
            SW2>
                LAG150 -> Interfaces: 1,6
                LAG250 -> Interfaces: 2,7
                LAG350 -> Interfaces: 3,5
        Expected behaviour:
        All interfaces in all LAGs should be InSync, Collecting
        and Distributing state
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')

    lag_id_1 = '150'
    lag_id_2 = '250'
    lag_id_3 = '350'
    sw_lag_id = [lag_id_1, lag_id_2, lag_id_3]

    assert sw1 is not None
    assert sw2 is not None

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

    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)

    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 (150, 250 and 350) in both switches")
    for lag in sw_lag_id:
        create_lag_active(sw1, lag)
        create_lag_active(sw2, lag)
        set_lacp_rate_fast(sw1, lag)
        set_lacp_rate_fast(sw2, lag)

    p11 = sw1.ports['1']
    p12 = sw1.ports['2']
    p13 = sw1.ports['3']
    p15 = sw1.ports['5']
    p16 = sw1.ports['6']
    p17 = sw1.ports['7']
    p21 = sw2.ports['1']
    p22 = sw2.ports['2']
    p23 = sw2.ports['3']
    p25 = sw2.ports['5']
    p26 = sw2.ports['6']
    p27 = sw2.ports['7']

    step("#### Associate Interfaces to LAG ####")
    step("Associate interfaces with LAG in switch1")
    associate_interface_to_lag(sw1, p11, lag_id_1)
    associate_interface_to_lag(sw1, p15, lag_id_1)
    associate_interface_to_lag(sw1, p12, lag_id_2)
    associate_interface_to_lag(sw1, p16, lag_id_2)
    associate_interface_to_lag(sw1, p13, lag_id_3)
    associate_interface_to_lag(sw1, p17, lag_id_3)

    step("Associate interfaces with LAG in switch2")
    associate_interface_to_lag(sw2, p21, lag_id_1)
    associate_interface_to_lag(sw2, p26, lag_id_1)
    associate_interface_to_lag(sw2, p22, lag_id_2)
    associate_interface_to_lag(sw2, p27, lag_id_2)
    associate_interface_to_lag(sw2, p23, lag_id_3)
    associate_interface_to_lag(sw2, p25, lag_id_3)

    step("#### Verify LAG configuration ####")
    verify_lag_config(sw1,
                      lag_id_1, [p11, p15],
                      mode='active',
                      heartbeat_rate='fast')
    verify_lag_config(sw1,
                      lag_id_2, [p12, p16],
                      mode='active',
                      heartbeat_rate='fast')
    verify_lag_config(sw1,
                      lag_id_3, [p13, p17],
                      mode='active',
                      heartbeat_rate='fast')
    verify_lag_config(sw2,
                      lag_id_1, [p21, p26],
                      mode='active',
                      heartbeat_rate='fast')
    verify_lag_config(sw2,
                      lag_id_2, [p22, p27],
                      mode='active',
                      heartbeat_rate='fast')
    verify_lag_config(sw2,
                      lag_id_3, [p23, p25],
                      mode='active',
                      heartbeat_rate='fast')

    ports_sw1.remove('4')
    ports_sw2.remove('4')
    step("Validate correct state in switch1 for interfaces")
    verify_state_sync_lag(sw1, ports_sw1, LOCAL_STATE, 'active')
    step("Validate correct state in switch2 for interfaces")
    verify_state_sync_lag(sw2, ports_sw2, LOCAL_STATE, 'active')
def test_lacp_different_aggregation_keys(topology):
    """
    Case 4:
        Verify LAGs with different names from switches can
        get connected as long as all interfaces connected have
        same aggregation key
        Initial Topology:
            SW1>
                LAG10 -> Interfaces: 1,2
            SW2>
                LAG20 -> Interfaces: 1,2
        Expected behaviour:
        All interfaces in all LAGs should be InSync, Collecting
        and Distributing state
    """
    sw1 = topology.get('sw1')
    sw2 = topology.get('sw2')

    sw1_lag_id = '10'
    sw2_lag_id = '20'

    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("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(sw2, ports_sw2)

    step("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)

    step("Associate interfaces 1,2 to the lag in both switches")
    for port in ports_sw1:
        associate_interface_to_lag(sw1, port, sw1_lag_id)

    for port in ports_sw2:
        associate_interface_to_lag(sw2, port, sw2_lag_id)

    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, 'fast', mode='active')

    step("Verify if LAG is synchronized")
    verify_state_sync_lag(sw1, ports_sw1, LOCAL_STATE, 'active')
    verify_state_sync_lag(sw1, ports_sw1, REMOTE_STATE, 'active')
def test_dynamic_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']
    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:
        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, mode_active)
    create_lag(sw2, lag_id, mode_passive)

    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], mode=mode_active)
    verify_lag_config(sw2, lag_id, ports_sw2[0:2], 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[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("### 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)

    step("#### Test ping between clients in the same vlan ####")
    check_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')

    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("### 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)

    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)

    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')
def test_lag_shutdown_by_default(topology, step):
    """Test LAG with shutdown by default ('no shutdown').

    By default a new LAG will be configured with 'no shutdown'. IPv4 pings
    from both clients must be successful.
    """

    step('\n############################################')
    step('Test lag shutdown (By default)')
    step('############################################')

    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'

    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']

    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)

    # Changing hardcoded interfaces for dynamic assignation
    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)

    step("### Set LACP rate to fast ###")
    set_lacp_rate_fast(sw1, sw1_lag_id)
    set_lacp_rate_fast(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[2])
    associate_vlan_to_l2_interface(sw2, vlan, ports_sw2[2])

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

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

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

    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)

    verify_connectivity_between_hosts(hs1, h1_ip_address, hs2, h2_ip_address,
                                      True)

    step('\n############################################')
    step('Test lag shutdown (By default) DONE')
    step('############################################')