Example #1
0
def instances_pg(tenant_home_pg_container, request):
    LOG.fixture_step('Go to Project > Compute > Instances')
    instances_page = instancespage.InstancesPage(tenant_home_pg_container.driver, port=tenant_home_pg_container.port)
    instances_page.go_to_target_page()

    def teardown():
        LOG.fixture_step('Back to Instances page')
        instances_page.go_to_target_page()

    request.addfinalizer(teardown)
    return instances_page
Example #2
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
Example #3
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 #4
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 #5
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 #6
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