Example #1
0
def test_filter_disk_formats_in_images_list(glance_steps,
                                            cli_glance_steps,
                                            api_version=2):
    """**Scenario:** Check that created images are filtered.

    **Steps:**

    #. Create 3 images with disk format qcow2 with Glance API
    #. Create 3 images with disk format ami with Glance API
    #. Check that created images filtered with disk_format using CLI

    **Teardown:**

    #. Delete images
    """
    qcow_images = glance_steps.create_images(
        image_names=utils.generate_ids(count=3),
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))
    ami_images = glance_steps.create_images(
        image_names=utils.generate_ids(count=3),
        disk_format='ami',
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))
    cli_glance_steps.check_images_filtered(images=qcow_images + ami_images,
                                           property_filter='disk_format',
                                           api_version=api_version)
Example #2
0
def test_restart_all_swift_services(cirros_image, container_steps,
                                    os_faults_steps, glance_steps):
    """**Scenario:** Restart all swift services.

    **Setup:**

    #. Create cirros image

    **Steps:**

    #. Restart all swift services on all controllers
    #. Create new container
    #. Upload data to container
    #. Download data from container
    #. Verify data checksum
    #. Remove data from container
    #. Remove container
    #. Download cirros image
    #. Verify downloaded image file

    **Teardown:**

    #. Delete created containers
    #. Delete created images
    """
    swift_services = os_faults_steps.get_services_names(config.SWIFT)
    os_faults_steps.restart_services(swift_services)
    container_name, object_name, content = utils.generate_ids(count=3)
    container_steps.create(container_name)
    container_steps.put_object(container_name, object_name, content)
    container_steps.check_object_content(container_name, object_name, content)
    container_steps.delete_object(container_name, object_name)
    container_steps.delete(container_name)
    glance_steps.check_image_content(
        cirros_image, utils.get_file_path(config.CIRROS_QCOW2_URL))
Example #3
0
def test_kill_glance_on_primary_controller(os_faults_steps,
                                           glance_steps,
                                           controller_cmd):
    """**Scenario:** Kill glance services on controller and upload image.

    **Steps:**

    #. Kill all glance services on primary controller
    #. Wait glance becomes available
    #. Upload image to glance
    """
    controller_node = os_faults_steps.get_nodes_by_cmd(controller_cmd)

    for service_name in config.GLANCE_SERVICES:
        pid = os_faults_steps.get_process_pid(controller_node, service_name)
        os_faults_steps.send_signal_to_process(controller_node,
                                               pid=pid,
                                               signal=signal.SIGKILL,
                                               delay=10)

    glance_steps.check_glance_service_available(
        timeout=config.SERVICE_REBALANCE_TIMEOUT)

    glance_steps.create_images(
        utils.get_file_path(config.CIRROS_QCOW2_URL))
Example #4
0
def test_status_manipulation_via_locations(enable_multi_locations,
                                           glance_steps, cli_glance_steps):
    """**Scenario:** Glance image status manipulation through locations removal.

    **Setup:**

    #. Set `show_multiple_locations=True` in /etc/glance/glance-api.conf
       and restart glance service.

    **Steps:**

    #. Create glance image
    #. Add 2 urls to image locations
    #. Check that user can't manipulate of image status
       through locations removal

    **Teardown:**

    #. Set `show_multiple_locations=False` in /etc/glance/glance-api.conf
       and restart glance service.
    #. Delete glance image
    """
    image = glance_steps.create_images(image_path=utils.get_file_path(
        config.CIRROS_QCOW2_URL),
                                       upload=False)[0]
    glance_steps.add_locations(
        image, urls=[config.CIRROS_QCOW2_URL, config.FEDORA_QCOW2_URL])
    cli_glance_steps.check_image_location_isnot_removed(image)
Example #5
0
def test_change_image_status_directly(glance_steps, api_glance_steps_v1):
    """**Scenario:** Verify that user can't change image status directly.

    This test verify that user can't change image status directly with v1 API.

    Note:
        This test verify bug #1496798.

    **Setup:**

    #. Create cirros image

    **Steps:**

    #. Get token
    #. Send PUT request to glance image endpoint with
        {'x-image-meta-status': 'queued'} headers
    #. Check that image's status is still active

    **Teardown:**

    #. Delete cirros image
    """
    images = glance_steps.create_images(
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))
    api_glance_steps_v1.check_image_update_is_forbidden(
        images, status=config.STATUS_QUEUED)
    glance_steps.check_image_status(images[0], config.STATUS_ACTIVE)
def test_create_volume_from_image(glance_steps, volume_steps, disk_format):
    """**Scenario:** Verify that volume from raw|qcow2 image is created.

    **Steps:**

    #. Create cinder volume from raw|qcow2 image
    #. Delete cinder volume
    """
    image = glance_steps.create_images(
        utils.get_file_path(config.UBUNTU_ISO_URL),
        disk_format=disk_format)[0]

    volume_steps.create_volumes(
        names=utils.generate_ids('volume', count=1), image=image)
Example #7
0
def test_create_update_delete_image(glance_steps):
    """**Scenario:** Check that image can be created, updated and deleted.

    **Steps:**

    #. Create cirros image with min-ram 512 and min-disk 1
    #. Update image ram size
    #. Delete image
    """
    images = glance_steps.create_images(
        utils.get_file_path(config.CIRROS_QCOW2_URL),
        min_ram=512, min_disk=1)

    glance_steps.update_images(images, min_ram=1024)
    glance_steps.delete_images(images)
Example #8
0
def test_negative_remove_deleted_image(glance_steps, cli_glance_steps,
                                       api_version):
    """**Scenario:** Try to remove already deleted image.

    **Steps:**

    #. Create image
    #. Delete created image
    #. Try to remove deleted image
    """
    image = glance_steps.create_images(
        image_path=utils.get_file_path(config.UBUNTU_QCOW2_URL))[0]

    glance_steps.delete_images([image])
    cli_glance_steps.check_negative_delete_non_existing_image(
        image, api_version=api_version)
Example #9
0
def test_image_list_doesnt_contain_deleted_image(glance_steps,
                                                 cli_glance_steps,
                                                 api_version):
    """**Scenario:** Check support of unicode symbols in image name.

    **Steps:**

    #. Create image with name 試験画像 with Glance API
    #. Delete image via API
    #. Check that image deleted using CLI command
    """
    image = glance_steps.create_images(
        image_names=utils.generate_ids(u'試験画像', use_unicode=True),
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))[0]
    glance_steps.delete_images([image])
    cli_glance_steps.check_image_list_doesnt_contain(images=[image],
                                                     api_version=api_version)
Example #10
0
    def _create_images_context(image_names, image_url, **kwargs):
        images = get_glance_steps(
            version=config.CURRENT_GLANCE_VERSION, is_api=False).create_images(
                image_names=image_names,
                image_path=utils.get_file_path(image_url),
                **kwargs)

        for image in images:
            uncleanable.image_ids.add(image.id)

        yield images

        get_glance_steps(version=config.CURRENT_GLANCE_VERSION,
                         is_api=False).delete_images(images)

        for image in images:
            uncleanable.image_ids.remove(image.id)
Example #11
0
def test_image_list_contains_created_image(glance_steps, cli_glance_steps,
                                           api_version):
    """**Scenario:** Check support of unicode symbols in image name.

    **Steps:**

    #. Create image with name 試験画像 with Glance API
    #. Check that created image is in list using CLI

    **Teardown:**

    #. Delete image
    """
    image = glance_steps.create_images(
        image_names=utils.generate_ids(u'試験画像', use_unicode=True),
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))[0]
    cli_glance_steps.check_image_list_contains(images=[image],
                                               api_version=api_version)
Example #12
0
def test_volume_disable_bootable(glance_steps, volume_steps):
    """**Scenario:** Verify ability to disable volume bootable status.

    **Steps:**

    #. Create image
    #. Create volume from image
    #. Disable volume bootable status

    **Teardown:**

    #. Delete volume
    #. Delete image
    """
    image = glance_steps.create_images(
        utils.get_file_path(config.UBUNTU_ISO_URL))[0]
    volume = volume_steps.create_volumes(image=image)[0]
    volume_steps.set_volume_bootable(volume, False)
Example #13
0
def test_user_storage_quota_bypass(get_glance_steps,
                                   os_faults_steps,
                                   api_version):
    """**Scenario:** Check user can't bypass quota with deleting images.

    Note:
        This test verifies bug #1414685

    **Setup:**

    #. Set 'file' storage on glance-api.conf
    #. Set 'user_storage_quota' to 604979776 on glance-api.conf (a little more
        than the size of the image)
    #. Restart glance-api service

    **Steps:**

    #. Create ubuntu image without uploading
    #. Start upload image file in background
    #. Wait few seconds
    #. Delete created image
    #. Repeat steps above 10 times
    #. Wait for all uploads to be done
    #. Check that glance disk usage is not exceed quota

    **Teardown:**

    #. Restore original glance config
    #. Restart glance-api
    """
    glance = get_glance_steps(version=api_version, is_api=False)
    image_path = utils.get_file_path(config.UBUNTU_QCOW2_URL)
    glance_nodes = os_faults_steps.get_nodes(service_names=[config.GLANCE_API])
    processes = []
    for _ in range(10):
        image, = glance.create_images(image_path=None, upload=False)
        p = utils.background(glance.upload_image, image, image_path)
        processes.append(p)
        time.sleep(2)
        glance.delete_images([image])
    for p in processes:
        utils.join_process(p)
    os_faults_steps.check_glance_fs_usage(
        glance_nodes, quota=config.GLANCE_USER_STORAGE_QUOTA)
Example #14
0
def test_image_list_contains_created_qcow2_images(glance_steps,
                                                  cli_glance_steps,
                                                  api_version):
    """**Scenario:** Check that created images are contained in images list.

    **Steps:**

    #. Create 3 images with disk format qcow2 with Glance API
    #. Check that created images is in list using CLI

    **Teardown:**

    #. Delete images
    """
    qcow_images = glance_steps.create_images(
        image_names=utils.generate_ids(count=3),
        image_path=utils.get_file_path(config.CIRROS_QCOW2_URL))
    cli_glance_steps.check_image_list_contains(images=qcow_images,
                                               api_version=api_version)
Example #15
0
def test_download_glance_image(cirros_image, cli_download_image, glance_steps,
                               file_option):
    """**Scenario:** Download glance image via CLI.

    **Setup:**

    #. Upload cirros image

    **Steps:**

    #. Download cirros image via CLI
    #. Compare md5 of uploaded cirros image and downloaded cirros image

    **Teardown:**

    #. Delete cirros image
    """
    downloaded_image_path = cli_download_image(cirros_image, file_option)
    glance_steps.check_image_hash(utils.get_file_path(config.CIRROS_QCOW2_URL),
                                  downloaded_image_path)
Example #16
0
    def test_image_privacy(self, glance_steps, images_steps, auth_steps):
        """Verify that non public image is not visible for other users.

        **Setup:**

        #. Login as user to another project

        **Steps:**

        #. Create image with public=False as admin via API
        #. Check that image is not available as public image

        **Teardown:**

        #. Delete image
        """
        image = glance_steps.create_images(
            utils.get_file_path(config.CIRROS_QCOW2_URL),
            image_names=utils.utils.generate_ids(length=20))[0]
        images_steps.check_non_public_image_not_visible(image.name)
Example #17
0
def test_change_glance_credentials(request, cirros_image, glance_steps):
    """**Scenario:** Check image available after changing glance credentials.

    **Setup:**

    #. Create cirros image

    **Steps:**

    #. Change glance credentials on keystone and glance_api.conf
    #. Download cirros image
    #. Check that image downloaded successful

    **Teardown:**

    #. Restore glance credentials
    #. Delete cirros image
    """
    request.getfixturevalue('change_glance_credentials')
    glance_steps.check_image_content(
        cirros_image, utils.get_file_path(config.CIRROS_QCOW2_URL))
Example #18
0
def create_images_context(get_glance_steps, uncleanable, credentials,
                          image_names, image_url, **kwargs):
    """Context manager to create image and delete it later.
    Args:
        get_glance_steps (function): function to get glance steps
        uncleanable (AttrDict): data structure with skipped resources
        credentials (object): CredentialsManager instance
        image_names (str): desired image name
        image_url (str): url to download image from
        **kwargs: Additional arguments to pass to API
    Returns:
        object: ubuntu glance image
    """
    initial_alias = credentials.current_alias

    images = get_glance_steps(version=config.CURRENT_GLANCE_VERSION,
                              is_api=False).create_images(
                                  image_names=image_names,
                                  image_path=utils.get_file_path(image_url),
                                  **kwargs)

    for image in images:
        uncleanable.image_ids.add(image.id)

    yield images

    with credentials.change(initial_alias):
        glance_steps = get_glance_steps(version=config.CURRENT_GLANCE_VERSION,
                                        is_api=False)
        for image in images:
            try:
                glance_steps.delete_images([image])
            except exceptions.HTTPNotFound:
                pass

    for image in images:
        uncleanable.image_ids.remove(image.id)
Example #19
0
    def create_image(self,
                     image_name,
                     image_description=None,
                     image_url=config.CIRROS_QCOW2_URL,
                     image_file=None,
                     disk_format='QCOW2',
                     min_disk=None,
                     min_ram=None,
                     protected=False,
                     big_image=False,
                     check=True):
        """Step to create image.

        Args:
            image_name (str): image name
            image_description (object|None): image description
            image_url (str): URL of image location
            image_file (str): path of image file
            disk_format (str): disk format
            min_disk (int): min disk size (in Gb)
            min_ram (int): min RAM size (in Mb)
            protected (bool): indicator whether image is protected or not
            big_image (bool): indicator whether image has big size or not
            check (bool): flag whether to check step or not
        """
        page_images = self._page_images()
        page_images.button_create_image.click()

        if image_url:
            image_file = utils.get_file_path(image_url)
            image_url = None

        with page_images.form_create_image as form:
            form.field_name.value = image_name

            form.button_group_source_type.value = 'File'
            form.field_image_file.value = image_file

            if image_description:
                form.field_description.value = image_description

            if min_disk:
                form.field_min_disk.value = min_disk

            if min_ram:
                form.field_min_ram.value = min_ram

            if protected:
                form.button_group_protected.value = "Yes"
            else:
                form.button_group_protected.value = "No"

            form.combobox_disk_format.value = disk_format

            if big_image:
                form.submit(modal_timeout=config.LONG_ACTION_TIMEOUT)
            else:
                form.submit()

        if check:
            self.close_notification('success')
            if big_image:
                page_images.table_images.row(
                    name=image_name).wait_for_status(
                    config.STATUS_ACTIVE,
                    timeout=config.LONG_EVENT_TIMEOUT)
            else:
                page_images.table_images.row(
                    name=image_name).wait_for_status(config.STATUS_ACTIVE)