Example #1
0
def volume_types_pg(admin_home_pg_container, request):
    LOG.fixture_step('Go to Admin > Volume > Volume Types page')
    volume_type_name = helper.gen_resource_name('volume_type')
    qos_spec_name = helper.gen_resource_name('qos_spec')
    volume_types_pg = volumetypespage.VolumetypesPage(admin_home_pg_container.driver, port=admin_home_pg_container.port)
    volume_types_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Volume Types page')
        volume_types_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return volume_types_pg, volume_type_name, qos_spec_name
Example #2
0
def test_horizon_non_bootable_volume_launch_as_instance_negative(volumes_pg_action):
    """
    This test case checks launch as instance option does not exist for non-bootable volume:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Instances
        - Create a non bootable volume

    Teardown:
        - Back to Instances page
        - Delete the newly created volume
        - Logout

    Test Steps:
        - Launch volume as instance
        - Check that ValueError exception is raised
    """
    volumes_pg_action, volume_name = volumes_pg_action
    instance_name = helper.gen_resource_name('volume_instance')
    LOG.tc_step('Meet Error when launching non-bootable volume {} as instance'.format(volume_name))
    mgmt_net_name = '-'.join([Tenant.get_primary()['tenant'], 'mgmt', 'net'])
    flavor_name = nova_helper.get_basic_flavor(rtn_id=False)

    with raises(ValueError):
        volumes_pg_action.launch_as_instance(volume_name, instance_name, delete_volume_on_instance_delete=True,
                                             flavor_name=flavor_name, network_names=[mgmt_net_name])
    horizon.test_result = True
Example #3
0
def test_horizon_network_subnet_create_admin(get_pnet, admin_networks_pg):
    """
    Test the network creation and deletion functionality:

    Setups:
        - Login as Admin
        - Go to Admin > Network > Networks

    Teardown:
        - Back to Networks page
        - Logout

    Test Steps:
        - Create a new network with subnet
        - Verify the network appears in the networks table as active
        - Delete the newly created network
        - Verify the network does not appear in the table after deletion
    """
    pnet_name, pnet_type = get_pnet
    network_name = helper.gen_resource_name('network')
    subnet_name = helper.gen_resource_name('subnet')

    LOG.tc_step('Create new network {}.'.format(network_name))
    admin_networks_pg.create_network(network_name,
                                     project=Tenant.get_primary()['tenant'],
                                     provider_network_type=pnet_type,
                                     physical_network=pnet_name,
                                     segmentation_id=300,
                                     subnet_name=subnet_name,
                                     network_address='192.168.0.0/24')
    assert admin_networks_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not admin_networks_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step('Verify the network appears in the networks table as active')
    assert admin_networks_pg.is_network_present(network_name)
    assert admin_networks_pg.get_network_info(network_name,
                                              'Status') == 'Active'

    LOG.tc_step('Delete network {}.'.format(network_name))
    admin_networks_pg.delete_network_by_row(network_name)
    assert admin_networks_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not admin_networks_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step(
        'Verify the network does not appear in the table after deletion')
    assert not admin_networks_pg.is_network_present(network_name)
    horizon.test_result = True
Example #4
0
def new_user(admin_home_pg_container, request):
    """
    Args:
        admin_home_pg_container:
        request:

    Setups:
        - Login as Admin
        - Go to Identity > User
        - Create a new user
        - Verify the user appears in the users table

    Teardown:
        - Delete the newly created user
        - Verify the user does not appear in the table after deletion
        - Back to Users page
        - Logout

    """
    LOG.fixture_step('Go to Identity > Users')
    users_pg = userspage.UsersPage(admin_home_pg_container.driver, port=admin_home_pg_container.port)
    users_pg.go_to_target_page()
    username = helper.gen_resource_name('user')
    password = TEST_PASSWORD

    LOG.fixture_step('Create new user {}'.format(username))
    users_pg.create_user(username, password=password,
                         project='admin', role='admin')
    assert users_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not users_pg.find_message_and_dismiss(messages.ERROR)

    LOG.fixture_step('Verify the user appears in the users table')
    assert users_pg.is_user_present(username)
    login_pg = loginpage.LoginPage(users_pg.driver, port=users_pg.port)

    def delete_test_user():
        LOG.fixture_step('Go to users page and delete user {}'.format(username))
        users_pg.log_out()
        login_pg.go_to_target_page()
        login_pg.login(user='******', password=Tenant.get('admin')['password'])
        users_pg.go_to_target_page()
        users_pg.delete_user(username)
        assert users_pg.find_message_and_dismiss(messages.SUCCESS)
        assert not users_pg.find_message_and_dismiss(messages.ERROR)

        LOG.fixture_step('Verify the user does not appear in the table after deletion')
        assert not users_pg.is_user_present(username)

        LOG.fixture_step('Back to Users page')
        users_pg.go_to_target_page()
    request.addfinalizer(delete_test_user)

    LOG.fixture_step("Login as new user, and go to user password change page")
    users_pg.log_out()
    login_pg.go_to_target_page()
    home_pg = login_pg.login(user=username, password=TEST_PASSWORD)
    password_change_pg = changepasswordpage.ChangepasswordPage(home_pg.driver, port=home_pg.port)
    password_change_pg.go_to_target_page()
    return password_change_pg, username
Example #5
0
 def create_host_aggregate(self, name=None, availability_zone=None):
     create_host_aggregate_form = self.host_aggregates_table.create_host_aggregate(
     )
     if name is None:
         name = helper.gen_resource_name('aggregate')
     create_host_aggregate_form.name.text = name
     if availability_zone is not None:
         create_host_aggregate_form.availability_zone.text = availability_zone
     create_host_aggregate_form.submit()
     return name
Example #6
0
def test_horizon_network_subnet_create_tenant(project_networks_pg):
    """
    Test the network creation and deletion functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Network > Networks

    Teardown:
        - Back to Networks page
        - Logout

    Test Steps:
        - Create a new network with subnet
        - Verify the network appears in the networks table as active
        - Delete the newly created network
        - Verify the network does not appear in the table after deletion
    """
    network_name = helper.gen_resource_name('network')
    subnet_name = helper.gen_resource_name('subnet')
    LOG.tc_step('Create new network {}.'.format(network_name))
    project_networks_pg.create_network(network_name,
                                       subnet_name=subnet_name,
                                       network_address='192.168.0.0/24')
    assert project_networks_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not project_networks_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step('Verify the network appears in the networks table as active')
    assert project_networks_pg.is_network_present(network_name)
    assert project_networks_pg.get_network_info(network_name,
                                                "Status") == "Active"

    LOG.tc_step('Delete network {}.'.format(network_name))
    project_networks_pg.delete_network_by_row(network_name)
    assert project_networks_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not project_networks_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step(
        'Verify the network does not appear in the table after deletion')
    assert not project_networks_pg.is_network_present(network_name)
    horizon.test_result = True
Example #7
0
def volumes_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Volumes page')
    volume_name = helper.gen_resource_name('volume')
    volumes_pg = volumespage.VolumesPage(tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    volumes_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Volumes page')
        volumes_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return volumes_pg, volume_name
Example #8
0
def server_groups_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Server Groups')
    group_name = helper.gen_resource_name('groups')
    instance_name = helper.gen_resource_name('instance_groups')
    instances_pg = instancespage.InstancesPage(
        tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    groups_pg = servergroupspage.ServerGroupsPage(
        tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    groups_pg.go_to_target_page()

    def teardown():
        instances_pg.go_to_target_page()
        if instances_pg.is_instance_present(instance_name):
            instances_pg.delete_instance_by_row(instance_name)
        groups_pg.go_to_target_page()
        time.sleep(5)
        if groups_pg.is_server_group_present(group_name):
            groups_pg.delete_server_group(name=group_name)

    request.addfinalizer(teardown)
    return groups_pg, group_name, instance_name
Example #9
0
def test_horizon_volume_launch_as_instance(volumes_pg_action):
    """
    This test case checks launch volume as instance functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Instances
        - Create a new volume

    Teardown:
        - Back to Instances page
        - Delete the newly created volume
        - Logout

    Test Steps:
        - Edit new volume as bootable
        - Launch volume as instance
        - Check that instance is 'active' and attached by the volume
        - Check that volume status is 'in use'
        - Delete the instance
    """
    volumes_pg_action, volume_name = volumes_pg_action
    LOG.tc_step('Edit new volume as Bootable')
    volumes_pg_action.edit_volume(volume_name, volume_name, bootable=True)
    instance_name = helper.gen_resource_name('volume_instance')

    LOG.tc_step('Launch volume {} as instance'.format(volume_name))
    mgmt_net_name = '-'.join([Tenant.get_primary()['tenant'], 'mgmt', 'net'])
    flavor_name = nova_helper.get_basic_flavor(rtn_id=False)
    volumes_pg_action.launch_as_instance(volume_name,
                                         instance_name,
                                         delete_volume_on_instance_delete=False,
                                         flavor_name=flavor_name,
                                         network_names=[mgmt_net_name])
    LOG.tc_step('Check that instance is Active and attached by the volume')
    time.sleep(5)
    instances_pg = instancespage.InstancesPage(volumes_pg_action.driver, volumes_pg_action.port)
    instances_pg.go_to_target_page()
    assert instances_pg.is_instance_active(instance_name)
    volumes_pg_action.go_to_target_page()
    assert instance_name in volumes_pg_action.get_volume_info(volume_name, "Attached To")

    LOG.tc_step('Check that volume status is In-use')
    assert volumes_pg_action.is_volume_status(volume_name, 'In-use')

    LOG.tc_step('Delete the instance')
    instances_pg.go_to_target_page()
    instances_pg.delete_instance(instance_name)
    assert instances_pg.find_message_and_dismiss(messages.INFO)
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)
    assert instances_pg.is_instance_deleted(instance_name)
    horizon.test_result = True
Example #10
0
def groups_pg(admin_home_pg_container, request):
    LOG.fixture_step('Go to Identity > Groups')
    group_name = helper.gen_resource_name('groups')
    groups_pg = groupspage.GroupsPage(admin_home_pg_container.driver,
                                      port=admin_home_pg_container.port)
    groups_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Groups page')
        groups_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return groups_pg, group_name
Example #11
0
def projects_pg(admin_home_pg_container, request):
    LOG.fixture_step('Go to Identity > Projects')
    project_name = helper.gen_resource_name('projects')
    projects_pg = projectspage.ProjectsPage(admin_home_pg_container.driver, port=admin_home_pg_container.port)
    projects_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Groups page')
        projects_pg.go_to_target_page()

    request.addfinalizer(teardown)

    return projects_pg, project_name
Example #12
0
def flavors_pg(admin_home_pg_container, request):
    LOG.fixture_step('Go to Admin > Compute > Flavors')
    flavor_name = helper.gen_resource_name('flavors')
    flavors_pg = flavorspage.FlavorsPage(admin_home_pg_container.driver,
                                         port=admin_home_pg_container.port)
    flavors_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Flavors page')
        flavors_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return flavors_pg, flavor_name
Example #13
0
def roles_pg(admin_home_pg, request):
    LOG.fixture_step('Go to Identity > Roles')
    role_name = helper.gen_resource_name('roles')
    roles_pg = rolespage.RolesPage(admin_home_pg.driver,
                                   port=admin_home_pg.port)
    roles_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Roles page')
        roles_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return roles_pg, role_name
Example #14
0
def test_horizon_launch_instance_from_image(tenant_images_pg):
    """
    Test launch instance from image functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Image

    Teardown:
        - Back to Images page
        - Logout

    Test Steps:
        - Create a new image
        - Launch new instance from image
        - Check that status of newly created instance is Active
        - Delete the newly lunched instance
        - Delete the newly created image
    """
    images_pg, image_name, image_id = tenant_images_pg

    mgmt_net_name = '-'.join([Tenant.get_primary()['tenant'], 'mgmt', 'net'])
    flv_name = nova_helper.get_basic_flavor(rtn_id=False)

    images_pg.refresh_page()
    assert images_pg.is_image_active(image_name)

    instance_name = helper.gen_resource_name('image_instance')
    LOG.tc_step('Launch new instance {} from image.'.format(instance_name))
    images_pg.launch_instance_from_image(image_name,
                                         instance_name,
                                         flavor_name=flv_name,
                                         network_names=[mgmt_net_name],
                                         create_new_volume=False)
    assert not images_pg.find_message_and_dismiss(messages.ERROR)
    instance_pg = instancespage.InstancesPage(images_pg.driver,
                                              port=images_pg.port)
    instance_pg.go_to_target_page()
    assert not instance_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step('Check that status of newly created instance is Active.')
    instance_pg.refresh_page()
    assert instance_pg.is_instance_active(instance_name)

    LOG.tc_step('Delete instance {}.'.format(instance_name))
    instance_pg.delete_instance_by_row(instance_name)
    assert not instance_pg.find_message_and_dismiss(messages.ERROR)
    assert instance_pg.is_instance_deleted(instance_name)

    horizon.test_result = True
Example #15
0
def volumes_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Volumes page')
    volume_name = helper.gen_resource_name('volume')
    volume_snapshot_name = helper.gen_resource_name('snapshot')
    volumes_pg = volumespage.VolumesPage(tenant_home_pg_container.driver,
                                         port=tenant_home_pg_container.port)
    volumes_pg.go_to_target_page()

    LOG.fixture_step('Create new volume {}'.format(volume_name))
    volumes_pg.create_volume(volume_name)
    assert volumes_pg.is_volume_status(volume_name, 'Available')

    def teardown():
        LOG.fixture_step('Back to Volumes page')
        volumes_pg.go_to_target_page()

        LOG.fixture_step('Delete volume {}'.format(volume_name))
        volumes_pg.delete_volume(volume_name)
        assert volumes_pg.is_volume_deleted(volume_name)

    request.addfinalizer(teardown)

    return volumes_pg, volume_name, volume_snapshot_name
Example #16
0
def security_groups_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Network > Security Groups')
    global SEC_GROUP_NAME
    SEC_GROUP_NAME = helper.gen_resource_name('sec_group')
    security_groups_pg = securitygroupspage.SecuritygroupsPage(
        tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    security_groups_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Security Groups page')
        security_groups_pg.go_to_target_page()

    request.addfinalizer(teardown)
    return security_groups_pg
Example #17
0
def instances_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Instance')
    instance_name = helper.gen_resource_name('instance')
    instances_pg = instancespage.InstancesPage(
        tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    instances_pg.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to instance page')
        if instances_pg.is_instance_present(instance_name):
            instances_pg.delete_instance_by_row(instance_name)
        instances_pg.go_to_target_page()

    request.addfinalizer(teardown)

    return instances_pg, instance_name
Example #18
0
def admin_images_pg(admin_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Images')
    image_name = helper.gen_resource_name('image')
    images_pg = imagespage.ImagesPage(admin_home_pg_container.driver,
                                      port=admin_home_pg_container.port)
    images_pg.go_to_target_page()
    image_id = glance_helper.create_image(image_name)[1]
    image_name = glance_helper.get_image_values(image_id, 'Name')[0]

    def teardown():
        LOG.fixture_step('Back to Images page')
        images_pg.go_to_target_page()
        LOG.fixture_step('Delete image {}'.format(image_name))
        images_pg.delete_image(image_name)

    request.addfinalizer(teardown)
    return images_pg, image_name, image_id
Example #19
0
def projects_pg_action(admin_home_pg_container, request):
    LOG.fixture_step('Go to Identity > Projects')
    project_name = helper.gen_resource_name('projects')
    projects_pg = projectspage.ProjectsPage(admin_home_pg_container.driver, port=admin_home_pg_container.port)
    projects_pg.go_to_target_page()
    LOG.fixture_step('Create new project {}'.format(project_name))
    projects_pg.create_project(project_name)

    def teardown():
        LOG.fixture_step('Delete the newly created project')
        projects_pg.delete_project(project_name)
        LOG.fixture_step('Back to Groups page')
        projects_pg.go_to_target_page()

    request.addfinalizer(teardown)

    return projects_pg, project_name
Example #20
0
def test_horizon_volume_upload_to_image(volumes_pg_action):
    """
    This test case checks upload volume to image functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Instances
        - Create a new volume

    Teardown:
        - Back to Instances page
        - Delete the newly created volume
        - Logout

    Test Steps:
        - Upload volume to image with some disk format
        - Check that image is created with correct format
        - Delete the image
        - Repeat actions for all disk formats
    """
    volumes_pg_action, volume_name = volumes_pg_action
    all_formats = {"qcow2": u'QCOW2', "raw": u'RAW', "vdi": u'VDI',
                   "vhd": u'VHD', "vmdk": u'VMDK', "vhdx": u"VHDX"}
    for disk_format in all_formats:
        LOG.tc_step('Upload volume to image with disk format {}'.format(disk_format))
        image_name = helper.gen_resource_name('volume_image')
        volumes_pg_action.upload_to_image(volume_name, image_name, disk_format)
        assert not volumes_pg_action.find_message_and_dismiss(messages.ERROR)
        assert volumes_pg_action.is_volume_status(volume_name, 'Available')

        LOG.tc_step('Check that image is created with format {}'.format(disk_format))
        images_pg = imagespage.ImagesPage(volumes_pg_action.driver, volumes_pg_action.port)
        images_pg.go_to_target_page()
        assert images_pg.is_image_present(image_name)
        assert images_pg.is_image_active(image_name)
        assert images_pg.get_image_info(image_name, 'Disk Format') == all_formats[disk_format]

        LOG.tc_step('Delete image {}'.format(image_name))
        images_pg.delete_image(image_name)
        time.sleep(1)
        assert images_pg.find_message_and_dismiss(messages.SUCCESS)
        assert not images_pg.find_message_and_dismiss(messages.ERROR)
        assert not images_pg.is_image_present(image_name)
        volumes_pg_action.go_to_target_page()
    horizon.test_result = True
Example #21
0
def test_horizon_create_volume_from_image(admin_images_pg):
    """
    Test create volume from image functionality:

    Setups:
        - Login as Admin
        - Go to Project > Compute > Image

    Teardown:
        - Back to Images page
        - Logout

    Test Steps:
        - Create a new image
        - Create new volume from image
        - Check that volume status is Available
        - Delete the volume
        - Delete the image
    """
    images_pg, image_name, image_id = admin_images_pg
    images_pg.refresh_page()
    assert images_pg.is_image_active(image_name)

    volume_name = helper.gen_resource_name('volume_from_image')
    LOG.tc_step('Create new volume {} from image'.format(volume_name))
    volumes_pg = images_pg.create_volume_from_image(image_name,
                                                    volume_name=volume_name)
    assert volumes_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not volumes_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step('Check that volume status is Available')
    volumes_pg.go_to_target_page()
    assert volumes_pg.is_volume_status(volume_name, 'Available')
    assert volumes_pg.is_volume_present(volume_name)

    LOG.tc_step('Delete volume {}.'.format(volume_name))
    volumes_pg.delete_volume(volume_name)
    assert volumes_pg.is_volume_deleted(volume_name)

    horizon.test_result = True
Example #22
0
def test_horizon_manage_volume_attachments(instances_pg):
    """
    Test the attach/detach actions for volume:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Instances

    Teardown:
        - Back to Instances page
        - Logout

    Test Steps:
        - Create a new instance
        - Go to Project -> Compute -> Volumes, create volume
        - Attach the volume to the newly created instance
        - Check that volume is In-use and link to instance
        - Detach volume from instance
        - Check volume is Available
        - Delete the volume
        - Delete the instance
    """
    instances_pg, volume_name = instances_pg
    instance_name = helper.gen_resource_name('volume_attachment')

    LOG.tc_step('Create new instance {}'.format(instance_name))
    mgmt_net_name = '-'.join([Tenant.get_primary()['tenant'], 'mgmt', 'net'])
    flavor_name = nova_helper.get_basic_flavor(rtn_id=False)
    guest_img = GuestImages.DEFAULT['guest']
    instances_pg.create_instance(instance_name,
                                 boot_source_type='Image',
                                 create_new_volume=False,
                                 source_name=guest_img,
                                 flavor_name=flavor_name,
                                 network_names=[mgmt_net_name])
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)
    assert instances_pg.is_instance_active(instance_name)

    LOG.tc_step('Go to Project -> Compute -> Volumes, create volume {}'.format(volume_name))
    volumes_pg = volumespage.VolumesPage(instances_pg.driver, instances_pg.port)
    volumes_pg.go_to_target_page()
    time.sleep(3)
    volumes_pg.create_volume(volume_name)
    assert (volumes_pg.is_volume_status(volume_name, 'Available'))

    LOG.tc_step('Attach the volume to the newly created instance')
    volumes_pg.attach_volume_to_instance(volume_name, instance_name)

    LOG.tc_step('Check that volume is In-use and link to instance')
    assert volumes_pg.is_volume_status(volume_name, 'In-use')
    assert instance_name in volumes_pg.get_volume_info(volume_name, 'Attached To')

    LOG.tc_step('Detach volume from instance')
    volumes_pg.detach_volume_from_instance(volume_name, instance_name)

    LOG.tc_step('Check volume is Available instead of In-use')
    assert volumes_pg.is_volume_status(volume_name, 'Available')

    LOG.tc_step('Delete the volume {}'.format(volume_name))
    volumes_pg.delete_volume(volume_name)
    assert volumes_pg.is_volume_deleted(volume_name)

    LOG.tc_step('Delete the instance {}'.format(instance_name))
    instances_pg.go_to_target_page()
    instances_pg.delete_instance(instance_name)
    instances_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)
    assert instances_pg.is_instance_deleted(instance_name)
    horizon.test_result = True
def test_horizon_sysconfig_addrpool_add_delete(sys_config_pg):
    """
    Test the address pools edit and display:

    Setups:
        - Login as Admin
        - Go to Admin > Platform > System Configuration

    Teardown:
        - Back to System Configuration Page
        - Logout

    Test Steps:
        - Check address pools display
        - Create a new address pool
        - Check the address pool is in the list
        - Delete the address pool
        - Check the address pool is absent in the list
    """
    sys_config_pg.go_to_address_pools_tab()
    LOG.tc_step('Check address pools display')
    addr_table = table_parser.table(cli.system('addrpool-list --nowrap')[1])
    uuid_list = table_parser.get_values(addr_table, target_header='uuid')
    for uuid in uuid_list:
        expt_horizon = {}
        name = table_parser.get_values(addr_table,
                                       target_header='name',
                                       **{'uuid': uuid})[0]
        expt_horizon['Name'] = name

        prefix = table_parser.get_values(addr_table,
                                         target_header='prefix',
                                         **{'uuid': uuid})[0]
        cli_network_val = table_parser.get_values(addr_table, 'network',
                                                  **{'uuid': uuid})
        cli_network_val = cli_network_val[0][0] + cli_network_val[0][
            1] + '/' + prefix
        expt_horizon['Network'] = cli_network_val

        cli_order_val = table_parser.get_values(addr_table, 'order',
                                                **{'uuid': uuid})[0]
        expt_horizon['Allocation Order'] = cli_order_val

        cli_ranges_list = eval(
            table_parser.get_values(addr_table, 'ranges', **{'uuid': uuid})[0])
        cli_ranges = ','.join(cli_ranges_list)
        expt_horizon['Address Ranges'] = cli_ranges
        table_name = sys_config_pg.address_pools_table.name
        sys_config_pg.check_horizon_displays(table_name=table_name,
                                             expt_horizon=expt_horizon)

    LOG.tc_step('Create a new address pool')
    address_name = helper.gen_resource_name('address_name')
    sys_config_pg.create_address_pool(name=address_name,
                                      network='192.168.0.0/24')
    assert sys_config_pg.is_address_present(address_name)

    LOG.tc_step('Delete the address pool')
    sys_config_pg.delete_address_pool(address_name)

    LOG.tc_step('Check the address pool is absent in the list')
    assert not sys_config_pg.is_address_present(address_name)
    horizon.test_result = True
Example #24
0
def test_horizon_floating_ip_associate_disassociate(instances_pg):
    """
    Tests the floating-ip allocate/release functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Instances

    Teardown:
        - Back to Instances page
        - Logout

    Test Steps:
        - Create a new instance
        - Allocates floating ip
        - Associate floating ip to the instance and verify it
        - Disassociate floating ip to the instance and verify it
        - Release Floating ip
        - Delete the instance
    """
    instance_name = helper.gen_resource_name('instance')
    LOG.tc_step('Create new instance {}'.format(instance_name))
    mgmt_net_name = '-'.join([Tenant.get_primary()['tenant'], 'mgmt', 'net'])
    flv_name = nova_helper.get_basic_flavor(rtn_id=False)
    guest_img = GuestImages.DEFAULT['guest']

    instances_pg.create_instance(instance_name,
                                 boot_source_type='Image',
                                 create_new_volume=False,
                                 source_name=guest_img,
                                 flavor_name=flv_name,
                                 network_names=[mgmt_net_name])
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)
    assert instances_pg.is_instance_active(instance_name)

    instance_ipv4 = instances_pg.get_fixed_ipv4(instance_name)
    instance_info = "{} {}".format(instance_name, instance_ipv4)

    floating_ips_page = project_floatingipspage.FloatingipsPage(instances_pg.driver, port=instances_pg.port)
    floating_ips_page.go_to_target_page()

    LOG.tc_step('Allocates floating ip')
    floating_ip = floating_ips_page.allocate_floatingip()
    assert floating_ips_page.find_message_and_dismiss(messages.SUCCESS)
    assert not floating_ips_page.find_message_and_dismiss(messages.ERROR)
    assert floating_ips_page.is_floatingip_present(floating_ip)

    assert '-' == floating_ips_page.get_floatingip_info(floating_ip, 'Mapped Fixed IP Address')

    LOG.tc_step('Associate floating ip to {} and verify'.format(instance_name))
    floating_ips_page.associate_floatingip(floating_ip, instance_name, instance_ipv4)
    assert floating_ips_page.find_message_and_dismiss(messages.SUCCESS)
    assert not floating_ips_page.find_message_and_dismiss(messages.ERROR)
    assert instance_info == floating_ips_page.get_floatingip_info(floating_ip, 'Mapped Fixed IP Address')

    LOG.tc_step('Disassociate floating ip to {} and verify'.format(instance_name))
    floating_ips_page.disassociate_floatingip(floating_ip)
    assert floating_ips_page.find_message_and_dismiss(messages.SUCCESS)
    assert not floating_ips_page.find_message_and_dismiss(messages.ERROR)
    assert '-' == floating_ips_page.get_floatingip_info(floating_ip, 'Mapped Fixed IP Address')

    LOG.tc_step('Release Floating ip')
    floating_ips_page.release_floatingip(floating_ip)
    assert floating_ips_page.find_message_and_dismiss(messages.SUCCESS)
    assert not floating_ips_page.find_message_and_dismiss(messages.ERROR)
    assert not floating_ips_page.is_floatingip_present(floating_ip)

    LOG.tc_step('Delete instance {}'.format(instance_name))
    instances_pg.go_to_target_page()
    instances_pg.delete_instance(instance_name)
    assert instances_pg.find_message_and_dismiss(messages.INFO)
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)
    assert instances_pg.is_instance_deleted(instance_name)
    horizon.test_result = True