Пример #1
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
Пример #2
0
def test_remote_cli():
    LOG.info("Download openrc files from horizon")
    horizon_dir = os.path.join(ProjVar.get_var('LOG_DIR'), 'horizon')
    tenant1 = Tenant.get('tenant1')['tenant']
    tenant2 = Tenant.get('tenant2')['tenant']
    admin_openrc = '{}-openrc.sh'.format(Tenant.get('admin')['tenant'])
    tenant1_openrc = '{}-openrc.sh'.format(tenant1)
    tenant2_openrc = '{}-openrc.sh'.format(tenant2)

    # from utils.horizon.pages.project.apiaccesspage import ApiAccessPage
    from utils.horizon.pages import loginpage
    driver = HorizonDriver.get_driver()
    login_pg = loginpage.LoginPage(driver)
    login_pg.go_to_target_page()
    home_pg = login_pg.login('admin', 'Li69nux*')
    home_pg.download_rc_v3()

    # api_access_page = ApiAccessPage(home_pg.driver)
    # api_access_page.go_to_target_page()
    # api_access_page.download_openstack_rc_file()
    assert os.path.exists(os.path.join(horizon_dir, admin_openrc)), "{} not found after download".format(admin_openrc)

    # api_access_page.change_project(name=tenant1)
    # api_access_page.download_openstack_rc_file()
    home_pg.change_project(name=tenant1)
    home_pg.download_rc_v3()
    assert os.path.exists(os.path.join(horizon_dir, tenant1_openrc)), \
        "{} not found after download".format(tenant1_openrc)

    # api_access_page.change_project(name=tenant2)
    # api_access_page.download_openstack_rc_file()
    home_pg.change_project(name=tenant2)
    home_pg.download_rc_v3()
    assert os.path.exists(os.path.join(horizon_dir, tenant2_openrc)), \
        "{} not found after download".format(tenant2_openrc)

    RemoteCLIClient.get_remote_cli_client()

    nova_helper.get_basic_flavor()
    cinder_helper.get_volume_qos_list()
    glance_helper.get_images()
    system_helper.get_computes()
    ceilometer_helper.get_alarms()
    keystone_helper.is_https_enabled()
Пример #3
0
def test_horizon_create_delete_server_group(server_groups_pg, policy):
    """
    Tests the server group creation and deletion functionality:

    Setups:
        - Login as Tenant
        - Go to Project > Compute > Server Groups page

    Teardown:
        - Go to instance page
        - Delete the created instance
        - Go to server group page
        - Delete the created group server
        - Logout

    Test Steps:
        - Create a new server group
        - Verify the group appears in server groups table
        - Launch instance with new created server group
        - Verify the instance status is active
    """
    server_groups_pg, group_name, instance_name = server_groups_pg

    # is_best_effort = True if best_effort == 'best_effort' else False
    LOG.tc_step('Create a new server group')
    server_groups_pg.create_server_group(name=group_name,
                                         policy='string:' + policy)
    assert not server_groups_pg.find_message_and_dismiss(messages.ERROR), \
        '{} creation error'.format(group_name)

    LOG.tc_step('Verify the group appears in server groups table')
    assert server_groups_pg.is_server_group_present(group_name)

    LOG.tc_step('Launch instance with new created server group')
    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 = instancespage.InstancesPage(server_groups_pg.driver,
                                               port=server_groups_pg.port)
    instances_pg.go_to_target_page()
    instances_pg.create_instance(instance_name,
                                 source_name=guest_img,
                                 flavor_name=flavor_name,
                                 network_names=[mgmt_net_name],
                                 server_group_name=group_name)
    assert not instances_pg.find_message_and_dismiss(messages.ERROR), \
        'instance: {} creation error'.format(instance_name)

    LOG.tc_step('Verify the instance status is active')
    assert instances_pg.is_instance_active(instance_name), \
        'instance: {} status is not active'.format(instance_name)

    horizon.test_result = True
Пример #4
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
Пример #5
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
Пример #6
0
def test_horizon_create_delete_instance(instances_pg):
    """
    Test the instance creation and deletion functionality:

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

    Teardown:
        - Back to Instances page
        - Logout

    Test Steps:
        - Create a new instance
        - Verify the instance appears in the instances table as active
        - Delete the newly lunched instance
        - Verify the instance does not appear in the table after deletion
    """
    instances_pg, instance_name = instances_pg

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

    LOG.tc_step('Create new instance {}'.format(instance_name))
    instances_pg.create_instance(instance_name,
                                 boot_source_type='Image',
                                 source_name=guest_img,
                                 flavor_name=flavor_name,
                                 network_names=mgmt_net_name,
                                 create_new_volume=False)
    assert not instances_pg.find_message_and_dismiss(messages.ERROR)

    LOG.tc_step('Verify the instance appears in the instances table as active')
    assert instances_pg.is_instance_active(instance_name)

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

    LOG.tc_step(
        'Verify the instance does not appear in the table after deletion')
    assert instances_pg.is_instance_deleted(instance_name)
    horizon.test_result = True
Пример #7
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
Пример #8
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