Example #1
0
def create_network_sanity():
    """
    Create network and subnetwork used in sanity_openstack tests
    """
    net_id = network_helper.create_network(name=NETWORK_NAME,
                                           cleanup="module")[1]
    subnet_id = network_helper.create_subnet(name=SUBNET_NAME,
                                             network=NETWORK_NAME,
                                             subnet_range=SUBNET_RANGE,
                                             dhcp=True,
                                             ip_version=IP_VERSION,
                                             cleanup="module")[1]
    return net_id, subnet_id
Example #2
0
def create_network_performance():
    """
    Create network and subnetwork used in sanity_openstack tests
    """
    LOG.fixture_step("Creating net and subnet")
    net_id = network_helper.create_network(name="network-1",
                                           cleanup="module")[1]
    subnet_id = network_helper.create_subnet(name="subnet",
                                             network="network-1",
                                             subnet_range="192.168.0.0/24",
                                             dhcp=True,
                                             ip_version=4,
                                             cleanup="module")[1]
    return net_id, subnet_id
Example #3
0
def test_port_trunking():
    """
    Port trunking feature test cases

    Test Steps:
        - Create networks
        - Create subnets
        - Create a parent port and subports
        - Create a truck with parent port and subports
        - Boot the first vm with the trunk
        - Create the second trunk without subport
        - Boot the second vm
        - Add support to trunk
        - Configure vlan interfaces inside guests
        - Verify connectivity via vlan interfaces
        - Remove the subport from trunk and verify connectivity
        - Add the support to trunk and verify connectivity
        - Do vm actions and verify connectivity


    Test Teardown:
        - Delete vms, ports, subnets, and networks created

    """
    vif_model = 'avp' if system_helper.is_avs() else None
    network_names = ['network11', 'network12', 'network13']
    net_ids = []
    sub_nets = ["30.0.0.0/24", "30.0.1.0/24", "30.0.2.0/24"]
    subnet_ids = []
    # parent ports and sub ports for trunk 1 and trunk 2
    trunk1_parent_port = 'vrf10'
    trunk1_subport_1 = 'vrf11'
    trunk1_subport_2 = 'vrf12'

    trunk2_parent_port = 'host10'
    trunk2_subport_1 = 'host11'
    trunk2_subport_2 = 'host12'

    # vlan id for the subports
    segment_1 = 1
    segment_2 = 2

    LOG.tc_step("Create Networks to be used by trunk")
    for net in network_names:
        net_ids.append(
            network_helper.create_network(name=net, cleanup='function')[1])

    LOG.tc_step("Create Subnet on the Network Created")
    for sub, network in zip(sub_nets, net_ids):
        subnet_ids.append(
            network_helper.create_subnet(network=network,
                                         subnet_range=sub,
                                         gateway='none',
                                         cleanup='function')[1])

    # Create Trunks
    LOG.tc_step("Create Parent port for trunk 1")
    t1_parent_port_id = network_helper.create_port(net_ids[0],
                                                   trunk1_parent_port,
                                                   wrs_vif=vif_model,
                                                   cleanup='function')[1]
    t1_parent_port_mac = network_helper.get_ports(
        field='mac address', port_name=trunk1_parent_port)[0]

    LOG.tc_step("Create Subport with parent port mac to be used by trunk 1")
    t1_sub_port1_id = network_helper.create_port(net_ids[1],
                                                 name=trunk1_subport_1,
                                                 mac_addr=t1_parent_port_mac,
                                                 wrs_vif=vif_model,
                                                 cleanup='function')[1]

    LOG.tc_step("Create Subport with parent port mac to be used by trunk 1")
    t1_sub_port2_id = network_helper.create_port(net_ids[2],
                                                 name=trunk1_subport_2,
                                                 mac_addr=t1_parent_port_mac,
                                                 wrs_vif=vif_model,
                                                 cleanup='function')[1]

    t1_sub_ports = [{
        'port': t1_sub_port1_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_1
    }, {
        'port': t1_sub_port2_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_2
    }]

    LOG.tc_step("Create port trunk 1")
    trunk1_id = network_helper.create_trunk(t1_parent_port_id,
                                            name='trunk-1',
                                            sub_ports=t1_sub_ports,
                                            cleanup='function')[1]

    LOG.tc_step("Boot a VM with mgmt net and trunk port")
    mgmt_net_id = network_helper.get_mgmt_net_id()
    nics = [{'net-id': mgmt_net_id}, {'port-id': t1_parent_port_id}]

    LOG.tc_step("Boot a vm with created ports")
    vm_id = vm_helper.boot_vm(name='vm-with-trunk1-port',
                              nics=nics,
                              cleanup='function')[1]
    LOG.tc_step("Setup vlan interfaces inside guest")
    _bring_up_vlan_interface(vm_id, 'eth1', [segment_1])

    # Create second trunk port  with out the subports and vm
    LOG.tc_step("Create Parent port for trunk 2")
    t2_parent_port_id = network_helper.create_port(net_ids[0],
                                                   trunk2_parent_port,
                                                   wrs_vif=vif_model,
                                                   cleanup='function')[1]
    t2_parent_port_mac = network_helper.get_ports(
        field='mac address', port_name=trunk2_parent_port)[0]
    LOG.tc_step("Create Subport with parent port mac to be used by trunk 2")
    t2_sub_port1_id = network_helper.create_port(net_ids[1],
                                                 name=trunk2_subport_1,
                                                 mac_addr=t2_parent_port_mac,
                                                 wrs_vif=vif_model,
                                                 cleanup='function')[1]
    LOG.tc_step("Create Subport with parent port mac to be used by trunk 2")
    t2_sub_port2_id = network_helper.create_port(net_ids[2],
                                                 name=trunk2_subport_2,
                                                 mac_addr=t2_parent_port_mac,
                                                 wrs_vif=vif_model,
                                                 cleanup='function')[1]

    t2_sub_ports = [{
        'port': t2_sub_port1_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_1
    }, {
        'port': t2_sub_port2_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_2
    }]

    LOG.tc_step("Create port trunk 2")
    trunk2_id = network_helper.create_trunk(t2_parent_port_id,
                                            name='trunk-2',
                                            cleanup='function')[1]

    LOG.tc_step("Boot a VM with mgmt net and trunk port")
    mgmt_net_id = network_helper.get_mgmt_net_id()
    nics_2 = [{'net-id': mgmt_net_id}, {'port-id': t2_parent_port_id}]

    LOG.tc_step("Boot a vm with created ports")
    vm2_id = vm_helper.boot_vm(name='vm-with-trunk2-port',
                               nics=nics_2,
                               cleanup='function')[1]

    LOG.tc_step("Add the sub ports to the second truck")
    network_helper.set_trunk(trunk2_id, sub_ports=t2_sub_ports)

    LOG.tc_step("Setup VLAN interfaces inside guest")
    _bring_up_vlan_interface(vm2_id, 'eth1', [segment_1])

    # ping b/w 2 vms using the vlan interfaces
    eth_name = 'eth1.1'

    with vm_helper.ssh_to_vm_from_natbox(vm_id) as vm_ssh:
        ip_addr = network_helper.get_ip_for_eth(eth_name=eth_name,
                                                ssh_client=vm_ssh)

    if ip_addr:
        with vm_helper.ssh_to_vm_from_natbox(vm2_id) as vm2_ssh:
            LOG.tc_step("Ping on vlan interface from guest")
            network_helper.ping_server(ip_addr,
                                       ssh_client=vm2_ssh,
                                       num_pings=20,
                                       fail_ok=False)

    # unset the subport on trunk_1 and try the ping (it will fail)
    LOG.tc_step(
        "Removing a subport from trunk and ping on vlan interface inside guest"
    )
    ret_code_10 = network_helper.unset_trunk(trunk1_id,
                                             sub_ports=[t1_sub_port1_id])[0]
    assert ret_code_10 == 0, "Subports not removed as expected."

    with vm_helper.ssh_to_vm_from_natbox(vm2_id) as vm2_ssh:
        LOG.tc_step("Ping on vlan interface from guest")
        ping = network_helper.ping_server(ip_addr,
                                          ssh_client=vm2_ssh,
                                          num_pings=20,
                                          fail_ok=True)[0]
        assert ping == 100, "Ping did not fail as expected."

    # set the subport on trunk_1 and try the ping (it will work)
    LOG.tc_step(
        " Add back the subport to trunk and ping on vlan interface inside guest"
    )
    t1_sub_port = [{
        'port': t1_sub_port1_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_1
    }]
    network_helper.set_trunk(trunk1_id, sub_ports=t1_sub_port)

    with vm_helper.ssh_to_vm_from_natbox(vm2_id) as vm2_ssh:
        LOG.tc_step("Ping on vlan interface from guest")
        network_helper.ping_server(ip_addr,
                                   ssh_client=vm2_ssh,
                                   num_pings=20,
                                   fail_ok=False)

    # VM operation and ping
    for vm_actions in [['pause', 'unpause'], ['suspend', 'resume'],
                       ['live_migrate'], ['cold_migrate']]:

        LOG.tc_step("Perform following action(s) on vm {}: {}".format(
            vm2_id, vm_actions))
        for action in vm_actions:
            vm_helper.perform_action_on_vm(vm2_id, action=action)

        LOG.tc_step("Ping vm from natbox")
        vm_helper.wait_for_vm_pingable_from_natbox(vm_id)

        LOG.tc_step(
            "Verify ping from base_vm to vm_under_test over management networks still works "
            "after {}".format(vm_actions))
        vm_helper.ping_vms_from_vm(to_vms=vm_id,
                                   from_vm=vm2_id,
                                   net_types=['mgmt'])

        if vm_actions[0] == 'cold_migrate':
            LOG.tc_step("Setup VLAN interfaces inside guest")
            _bring_up_vlan_interface(vm2_id, 'eth1', [segment_1])

        with vm_helper.ssh_to_vm_from_natbox(vm2_id) as vm2_ssh:
            LOG.tc_step(
                "Ping on vlan interface from guest after action {}".format(
                    vm_actions))
            network_helper.ping_server(ip_addr,
                                       ssh_client=vm2_ssh,
                                       num_pings=20,
                                       fail_ok=False)

        vm_host = vm_helper.get_vm_host(vm2_id)

        vm_on_target_host = vm_helper.get_vms_on_host(vm_host)

    LOG.tc_step(
        "Reboot VMs host {} and ensure vms are evacuated to other host".format(
            vm_host))
    vm_helper.evacuate_vms(host=vm_host, vms_to_check=vm2_id, ping_vms=True)

    for vm_id_on_target_host in vm_on_target_host:
        LOG.tc_step("Setup VLAN interfaces inside guest")
        _bring_up_vlan_interface(vm_id_on_target_host, 'eth1', [segment_1])

    with vm_helper.ssh_to_vm_from_natbox(vm2_id) as vm2_ssh:
        LOG.tc_step("Ping on vlan interface from guest after evacuation")
        network_helper.ping_server(ip_addr,
                                   ssh_client=vm2_ssh,
                                   num_pings=20,
                                   fail_ok=False)

    LOG.tc_step(
        "Attempt to delete trunk when in use, expect pass for AVS only")
    code = network_helper.delete_trunks(trunks=trunk1_id, fail_ok=True)[0]

    if system_helper.is_avs():
        assert 0 == code, "Failed to delete port trunk when it's used by a running VM wiht AVS"
    else:
        assert 1 == code, "Trunk is deleted when it's used by a running VM with OVS"
Example #4
0
def test_port_trunking_basic():
    """
    Port trunking feature test cases

    Test Steps:
        - Create networks
        - Create subnets
        - Create a parent port and subports
        - Create a trunk with parent port and subports
        - Add a sub-port with existing vlan id
        - Add a sub-port with out of range vlan id
        - Delete a port that is used by the Trunk


    Test Teardown:
        - Delete vms, ports, subnets, and networks created
    """
    network_names = ['network21', 'network22', 'network23']
    net_ids = []
    sub_nets = ["40.0.0.0/24", "40.0.1.0/24", "40.0.2.0/24"]
    subnet_ids = []
    # parent ports and sub ports for trunk 1 and trunk 2
    trunk1_parent_port = 'vrf20'
    trunk1_subport_1 = 'vrf21'
    trunk1_subport_2 = 'vrf22'
    trunk1_subport_3 = 'vrf23'

    # vlan id for the subports
    segment_1 = 1
    segment_2 = 2

    LOG.tc_step("Create Networks to be used by trunk")
    for net in network_names:
        net_ids.append(
            network_helper.create_network(name=net, cleanup='function')[1])

    LOG.tc_step("Create Subnet on the Network Created")
    for sub, network in zip(sub_nets, net_ids):
        subnet_ids.append(
            network_helper.create_subnet(network=network,
                                         subnet_range=sub,
                                         gateway='none',
                                         cleanup='function')[1])

    # Create Trunks
    LOG.tc_step("Create Parent port for trunk 1")
    t1_parent_port_id = network_helper.create_port(net_ids[0],
                                                   trunk1_parent_port,
                                                   cleanup='function')[1]
    t1_parent_port_mac = network_helper.get_ports(
        field='mac address', port_name=trunk1_parent_port)[0]

    LOG.tc_step("Create Subport with parent port mac to be used by trunk 1")
    t1_sub_port1_id = network_helper.create_port(net_ids[1],
                                                 name=trunk1_subport_1,
                                                 mac_addr=t1_parent_port_mac,
                                                 cleanup='function')[1]

    LOG.tc_step("Create Subport with parent port mac to be used by trunk 1")
    t1_sub_port2_id = network_helper.create_port(net_ids[2],
                                                 name=trunk1_subport_2,
                                                 mac_addr=t1_parent_port_mac,
                                                 cleanup='function')[1]

    LOG.tc_step("Create Subport with parent port mac to be used by trunk 1")
    t1_sub_port3_id = network_helper.create_port(net_ids[2],
                                                 name=trunk1_subport_3,
                                                 cleanup='function')[1]

    t1_sub_ports = [{
        'port': t1_sub_port1_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_1
    }, {
        'port': t1_sub_port2_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_2
    }]

    LOG.tc_step("Create port trunk 1")
    trunk1_id = network_helper.create_trunk(t1_parent_port_id,
                                            name='trunk-1',
                                            sub_ports=t1_sub_ports,
                                            cleanup='function')[1]

    LOG.tc_step(
        "Attempt to add a port with same segment id and verify it's rejected")
    t1_sub_port2 = [{
        'port': t1_sub_port3_id,
        'segmentation-type': 'vlan',
        'segmentation-id': segment_1
    }]
    ret_code = network_helper.set_trunk(trunk1_id, t1_sub_port2,
                                        fail_ok=True)[0]
    assert ret_code == 1, "Subport addition with the same vlan id is not rejected."

    LOG.tc_step(
        "Attempt to add subport with out of range vlan id, and verify it's rejected"
    )
    out_of_range_id = 5000
    t1_sub_port3 = [{
        'port': t1_sub_port3_id,
        'segmentation-type': 'vlan',
        'segmentation-id': out_of_range_id
    }]
    ret_code_2 = network_helper.set_trunk(trunk1_id,
                                          t1_sub_port3,
                                          fail_ok=True)[0]
    assert ret_code_2 == 1, "Subport addition with out of range vlan id is not rejected."

    LOG.tc_step(
        "Attempt to delete a port that is used by the trunk, and verify it's rejected"
    )
    ret_code_3 = network_helper.delete_port(port_id=t1_sub_port1_id,
                                            fail_ok=True)[0]
    assert ret_code_3 == 1, "Port that is part of the trunk deletion is not rejected."
Example #5
0
def test_ipv6_subnet(vif_model, check_avs_pattern):
    """
    Ipv6 Subnet feature test cases

    Test Steps:
        - Create networks
        - Create Ipv6 enabled subnet
        - Boot the first vm with the ipv6 subnet
        - Boot the second vm with ipv6 subnet
        - Configure interfaces to get ipv6 addr
        - Verify connectivity ipv6 interfaces
        - Ping default router

    Test Teardown:
        - Delete vms, subnets, and networks created

    """
    network_names = ['network11']
    net_ids = []
    sub_nets = ["fd00:0:0:21::/64"]
    gateway_ipv6 = "fd00:0:0:21::1"
    subnet_ids = []

    dns_server = "2001:4860:4860::8888"

    LOG.tc_step("Create Networks to setup IPV6 subnet")
    for net in network_names:
        net_ids.append(
            network_helper.create_network(name=net, cleanup='function')[1])

    LOG.tc_step("Create IPV6 Subnet on the Network Created")
    for sub, network in zip(sub_nets, net_ids):
        subnet_ids.append(
            network_helper.create_subnet(network=network,
                                         ip_version=6,
                                         dns_servers=dns_server,
                                         subnet_range=sub,
                                         gateway='none',
                                         cleanup='function')[1])

    LOG.tc_step("Boot a VM with mgmt net and Network with IPV6 subnet")
    mgmt_net_id = network_helper.get_mgmt_net_id()
    nics = [{
        'net-id': mgmt_net_id
    }, {
        'net-id': net_ids[0],
        'vif-model': vif_model
    }]

    image = None
    if vif_model == 'e1000':
        image = glance_helper.create_image(name=vif_model,
                                           hw_vif_model=vif_model,
                                           cleanup='function')[1]

    LOG.tc_step("Boot a vm with created nets")
    vm_id = vm_helper.boot_vm(name='vm-with-ipv6-nic',
                              nics=nics,
                              image_id=image,
                              cleanup='function')[1]
    LOG.tc_step("Setup interface script inside guest and restart network")
    _bring_up_interface(vm_id)

    LOG.tc_step("Boot a second vm with created nets")
    vm_id2 = vm_helper.boot_vm(name='vm2-with-ipv6-nic',
                               nics=nics,
                               cleanup='function')[1]
    LOG.tc_step("Setup interface script inside guest and restart network")
    _bring_up_interface(vm_id2)

    with vm_helper.ssh_to_vm_from_natbox(vm_id) as vm_ssh:
        ip_addr = _get_ipv6_for_eth(eth_name='eth1', ssh_client=vm_ssh)

        if ip_addr is '':
            LOG.info('Ip addr is not assigned')
            assert ip_addr != '', "Failed to assign ip"
        else:
            LOG.info("Got Ipv6 address:{}".format(ip_addr))

    with vm_helper.ssh_to_vm_from_natbox(vm_id2) as vm_ssh:
        LOG.tc_step("ping b/w vms on the ipv6 net")
        ping = _ping6_vms(ssh_client=vm_ssh, ipv6_addr=ip_addr)
        assert ping == 0, "Ping between VMs failed"
        LOG.tc_step("ping Default Gateway from vms on the ipv6 net")
        ping = _ping6_vms(ssh_client=vm_ssh, ipv6_addr=gateway_ipv6)
        assert ping == 0, "Ping to default router failed"