Glance

Glance conftest

Contains fixtures specific for glance.

stepler.glance.conftest.api_glance_client_v1(get_glance_client)[source]

Function fixture to get API glance client v1.

Parameters:get_glance_client (function) – function to get glance client
Returns:instantiated API glance client v1
Return type:api_clients.ApiClientV1
stepler.glance.conftest.api_glance_client_v2(get_glance_client)[source]

Function fixture to get API glance client v2.

Parameters:get_glance_client (function) – function to get glance client
Returns:instantiated API glance client v2
Return type:api_clients.ApiClientV2
stepler.glance.conftest.api_glance_steps(get_glance_steps)[source]

Function fixture to get API glance steps.

Parameters:get_glance_steps (function) – function to get API glance steps
Returns:instantiated glance steps
Return type:GlanceSteps
stepler.glance.conftest.api_glance_steps_v1(get_glance_steps)[source]

Function fixture to get API glance steps for v1.

Parameters:get_glance_steps (function) – function to get glance steps
Returns:instantiated glance steps v1
Return type:GlanceStepsV1
stepler.glance.conftest.api_glance_steps_v2(get_glance_steps)[source]

Function fixture to get API glance steps for v2.

Parameters:get_glance_steps (function) – function to get API glance steps
Returns:instantiated glance steps
Return type:GlanceSteps
stepler.glance.conftest.baremetal_ubuntu_image(get_glance_steps, uncleanable, credentials)[source]

Module fixture to create baremetal ubuntu image with default options.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • uncleanable (AttrDict) – data structure with skipped resources
  • credentials (object) – CredentialsManager instance
Returns:

ubuntu image

Return type:

object

stepler.glance.conftest.change_glance_credentials(os_faults_steps, glance_steps, user_steps)[source]

Function fixture to change glance credentials in config and keystone.

Original credentials will be restored after test.

Parameters:
  • os_faults_steps (obj) – instantiated os-faults steps
  • glance_steps (obj) – instantiated glance steps
  • user_steps (obj) – instantiated user-steps
stepler.glance.conftest.cirros_image(get_glance_steps, uncleanable, credentials)[source]

Module fixture to create cirros image with default options.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • uncleanable (AttrDict) – data structure with skipped resources
  • credentials (object) – CredentialsManager instance
Returns:

cirros glance image

Return type:

object

stepler.glance.conftest.cirros_image_private(get_glance_steps, uncleanable, credentials)[source]

Module fixture to create private cirros image with default options.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • cirros_image (object) – cirros glance image
Returns:

private cirros glance image

Return type:

object

stepler.glance.conftest.conntrack_cirros_image(get_glance_steps, uncleanable, credentials)[source]

Function fixture to create cirros image with patches for conntrack.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • uncleanable (AttrDict) – data structure with skipped resources
  • credentials (object) – CredentialsManager instance
Returns:

public cirros glance image

Return type:

object

stepler.glance.conftest.create_images_context(get_glance_steps, uncleanable, credentials, image_names, image_url, **kwargs)[source]

Context manager to create image and delete it later. :param get_glance_steps: function to get glance steps :type get_glance_steps: function :param uncleanable: data structure with skipped resources :type uncleanable: AttrDict :param credentials: CredentialsManager instance :type credentials: object :param image_names: desired image name :type image_names: str :param image_url: url to download image from :type image_url: str :param **kwargs: Additional arguments to pass to API

Returns:ubuntu glance image
Return type:object
stepler.glance.conftest.enable_multi_locations(patch_ini_file_and_restart_services, get_glance_steps)[source]

Fixture to enable glance multiple locations.

Parameters:
  • patch_ini_file_and_restart_services (function) – callable fixture to patch ini file and restart services
  • get_glance_steps (function) – callable session fixture to get glance steps.
stepler.glance.conftest.get_glance_client(get_session)[source]

Callable session fixture to get glance client v1.

Parameters:get_session (function) – function to get keystone session
Returns:function to get glance client v1
Return type:function
stepler.glance.conftest.get_glance_steps(request, get_glance_client)[source]

Callable session fixture to get glance steps.

Parameters:get_glance_client (function) – function to get glance client
Returns:function to get glance steps
Return type:function
stepler.glance.conftest.glance_client_v1(get_glance_client)[source]

Function fixture to get glance client v1.

Parameters:get_glance_client (function) – function to get glance client
Returns:instantiated glance client
Return type:glanceclient.v1.client.Client
stepler.glance.conftest.glance_client_v2(get_glance_client)[source]

Function fixture to get glance client v2.

Parameters:get_glance_client (function) – function to get glance client
Returns:instantiated glance client
Return type:glanceclient.v2.client.Client
stepler.glance.conftest.glance_steps(get_glance_steps, images_cleanup)[source]

Function fixture to get API glance steps.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • images_cleanup (function) – function to cleanup images after test
Yields:

object – instantiated glance steps of current version

stepler.glance.conftest.glance_steps_v1(get_glance_steps)[source]

Function fixture to get glance steps for v1.

Parameters:get_glance_steps (function) – function to get glance steps
Returns:instantiated glance steps v1
Return type:GlanceStepsV1
stepler.glance.conftest.glance_steps_v2(get_glance_steps)[source]

Function fixture to get glance steps for v2.

Parameters:get_glance_steps (function) – function to get glance steps
Returns:instantiated glance steps v2
Return type:GlanceStepsV2
stepler.glance.conftest.images_cleanup(uncleanable)[source]

Callable function fixture to cleanup images after test.

Parameters:uncleanable (AttrDict) – data structure with skipped resources
Returns:function to cleanup images
Return type:function
stepler.glance.conftest.set_glance_storage_to_file_with_quota(os_faults_steps, get_glance_steps)[source]

Fixture to set glance storage to file and set user_storage_quota.

Parameters:
  • os_faults_steps (obj) – instantiated os-faults steps
  • get_glance_steps (function) – function to get glance steps.
stepler.glance.conftest.ubuntu_image(get_glance_steps, uncleanable, credentials)[source]

Module fixture to create ubuntu image. Creates image from config.UBUNTU_QCOW2_URL with default options.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • uncleanable (AttrDict) – data structure with skipped resources
  • credentials (object) – CredentialsManager instance
Returns:

ubuntu glance image

Return type:

object

stepler.glance.conftest.ubuntu_xenial_image(get_glance_steps, uncleanable, credentials)[source]

Module fixture to create ubuntu xenial image. Creates image from config.UBUNTU_XENIAL_QCOW2_URL with default options.

Parameters:
  • get_glance_steps (function) – function to get glance steps
  • uncleanable (AttrDict) – data structure with skipped resources
  • credentials (object) – CredentialsManager instance
Returns:

ubuntu xenial glance image

Return type:

object

Glance steps

Contains steps specific for glance.

class stepler.glance.steps.GlanceStepsV1(client)[source]

Glance steps for v1.

check_image_update_is_forbidden(images, status)[source]

Step to check that it is forbidden to update images.

Parameters:
  • images (object) – glance images
  • status (str) – status to be set for images
Raises:

AssertionError – if check triggered an error

upload_image(image, image_path, check=True)[source]

Step to upload image.

Parameters:
  • image (obj) – glance image
  • image_path (str) – path image file
  • check (bool, optional) – flag whether to check this step or not
Raises:

AssertionError – if check failed

class stepler.glance.steps.GlanceStepsV2(client)[source]

Glance steps for v2.

add_locations(image, urls, check=True)[source]

Step to add location to image.

Parameters:
  • image (obj) – glance image
  • urls (list) – urls for adding to image location
  • check (bool) – flag whether to check step or not
Raises:

AssertionError – if locations was not added

bind_project(image, project, check=True)[source]

Step to bind image to project.

Parameters:
  • image (object) – image to bind to project
  • project (object) – project to bind to image
  • check (bool) – flag whether to check binding or not
check_glance_service_available(should_be=True, timeout=15)[source]

Step to check glance service availability.

Parameters:
  • should_be (bool) – flag whether glance should available or not
  • timeout (int) – seconds to wait glance availability status
Raises:

TimeoutExpired – if check failed after timeout

check_image_bind_status(image, project, must_bound=True, timeout=0)[source]

Check step image binding status.

Parameters:
  • image (object) – image bound/unbound with project
  • project (object) – project bound/unbound with image
  • must_bound (bool) – flag whether project and image should be bound or unbound
  • timeout (int) – seconds to wait a result of check
Raises:

TimeoutExpired – if check failed after timeout

check_image_container_and_disk_format(image_name, image_container, disk_format)[source]

Check image container format and disk format.

Parameters:
  • image_name (object) – image bound/unbound with project
  • image_container (str) – type of image container
  • disk_format (str) – type of disk format
Raises:

AssertionError – if check failed

check_image_content(image, path)[source]

Step to compare image content with file content.

Parameters:
  • image (obj) – glance image
  • path (str) – path to file to compare image with
Raises:

AssertionError – if check failed

check_image_data_corresponds_to_source(image, file_path)[source]

Step to check that image data correspond to image source.

Parameters:
  • image (obj) – image object
  • file_path (str) – path to file image upload from
Raises:

AssertionError – if image checksum not equal to source file checksum

check_image_hash(image_path_1, image_path_2)[source]

Step to check hash sum of uploaded image and downloaded image.

Parameters:
  • image_path_1 (str) – path to first image
  • image_path_2 (str) – path to second image
Raises:

AssertionError – if hash sum has been mismatched

check_that_image_id_is_changed(image_name, image_id)[source]

Step to check that after updating heat stack image_id was changed.

Parameters:
  • image_name (str) – image name that was replaced
  • image_id (str) – before updating
Raises:

AssertionError – if check failed

create_images(image_path, image_names=None, disk_format='qcow2', container_format='bare', visibility='private', upload=True, check=True, **kwargs)[source]

Step to create images.

Parameters:
  • image_path (str) – path to image at local machine
  • image_names (list) – names of created images, if not specified one image name will be generated
  • disk_format (str) – format of image disk
  • container_format (str) – format of image container
  • visibility (str) – image visibility (private or public). Default is private.
  • upload (bool) – flag whether to upload image after creation or not (upload=False is used in some negative tests)
  • check (bool) – flag whether to check step or not
  • **kwargs – Optional. A dictionary containing the attributes of the resource
Returns:

glance images

Return type:

list

Raises:

AssertionError – if check failed

get_image(check=True, **kwargs)[source]

Find one image by provided **kwargs.

Parameters:
  • check (bool) – flag whether to check step or not
  • **kwargs – like: {‘name’: ‘TestVM’, ‘status’: ‘active’}
Returns:

glance image

Return type:

object

Raises:

ValueError – if ‘**kwargs’ were not provided

get_images(name_prefix=None, check=True, **kwargs)[source]

Step to retrieve images from glance.

Parameters:
  • name_prefix (str) – name prefix to filter images
  • check (bool) – flag whether to check step or not
  • **kwargs – like: {‘name’: ‘TestVM’, ‘status’: ‘active’}
Returns:

images list

Return type:

list

Raises:

AssertionError – if check triggered an error

unbind_project(image, project, check=True)[source]

Step to unbind image to project.

Parameters:
  • image (object) – image to unbind from project
  • project (object) – project to unbind from image
  • check (bool) – flag whether to check unbinding or not
upload_image(image, image_path, check=True)[source]

Step to upload image.

Parameters:
  • image (obj) – glance image
  • image_path (str) – path image file
  • check (bool, optional) – flag whether to check this step or not
Raises:

AssertionError – if check failed

Glance tests

Image tests

stepler.glance.tests.test_images.test_change_image_status_directly(glance_steps, api_glance_steps_v1)[source]

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:

  1. Create cirros image

Steps:

  1. Get token
  2. Send PUT request to glance image endpoint with
    {‘x-image-meta-status’: ‘queued’} headers
  3. Check that image’s status is still active

Teardown:

  1. Delete cirros image
stepler.glance.tests.test_images.test_create_update_delete_image(glance_steps)[source]

Scenario: Check that image can be created, updated and deleted.

Steps:

  1. Create cirros image with min-ram 512 and min-disk 1
  2. Update image ram size
  3. Delete image
stepler.glance.tests.test_images.test_images_list(glance_steps)[source]

Scenario: Request list of images.

Steps:

  1. Get list of images
stepler.glance.tests.test_images.test_share_glance_image(cirros_image_private, project, glance_steps)[source]

Scenario: Check sharing glance image to another project.

Setup:

  1. Create private image
  2. Create project

Steps:

  1. Bind another project to image
  2. Unbind project from image

Teardown:

  1. Delete project
  2. Delete image

Glance service tests

stepler.glance.tests.test_services.test_kill_glance_on_controller(os_faults_steps, glance_steps)[source]

Scenario: Kill glance services on controller and upload image.

Steps:

  1. Kill all glance services on controller
  2. Wait glance becomes available
  3. Upload image to glance
stepler.glance.tests.test_services.test_restart_all_glance_services(cirros_image, flavor, keypair, net_subnet_router, security_group, server, get_ssh_proxy_cmd, glance_steps, os_faults_steps, server_steps)[source]

Scenario: Check that glance works after restarting services.

Setup:

  1. Create cirros image
  2. Create flavor
  3. Create keypair
  4. Create network with subnet and router
  5. Create security group
  6. Create server_1

Steps:

  1. Check that ping from server_1 to 8.8.8.8 is successful
  2. Create image_1 and check its content
  3. Restart glance services
  4. Wait for glance service availability
  5. Check that image_1 is in images list and its content is expected as well
  6. Create image_2 and check its content
  7. Create server_2 and check ping to 8.8.8.8 from it

Teardown:

  1. Delete images
  2. Delete servers
  3. Delete security group
  4. Delete network, subnet, router
  5. Delete keypair
  6. Delete flavor
  7. Delete cirros image

Glance security tests

stepler.glance.tests.test_security.test_change_glance_credentials(request, cirros_image, glance_steps)[source]

Scenario: Check image available after changing glance credentials.

Setup:

  1. Create cirros image

Steps:

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

Teardown:

  1. Restore glance credentials
  2. Delete cirros image
stepler.glance.tests.test_security.test_user_storage_quota_bypass(get_glance_steps, os_faults_steps, api_version)[source]

Scenario: Check user can’t bypass quota with deleting images.

Note

This test verifies bug #1414685

Setup:

  1. Set ‘file’ storage on glance-api.conf
  2. Set ‘user_storage_quota’ to 604979776 on glance-api.conf (a little more
    than the size of the image)
  3. Restart glance-api service

Steps:

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

Teardown:

  1. Restore original glance config
  2. Restart glance-api