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.
-
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: 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: Raises: AssertionError– if check triggered an error
-
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:
- 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
-
stepler.glance.tests.test_images.test_create_update_delete_image(glance_steps)[source]¶ 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
-
stepler.glance.tests.test_images.test_images_list(glance_steps)[source]¶ Scenario: Request list of images.
Steps:
- Get list of images
Scenario: Check sharing glance image to another project.
Setup:
- Create private image
- Create project
Steps:
- Bind another project to image
- Unbind project from image
Teardown:
- Delete project
- 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:
- Kill all glance services on controller
- Wait glance becomes available
- 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:
- Create cirros image
- Create flavor
- Create keypair
- Create network with subnet and router
- Create security group
- Create server_1
Steps:
- Check that ping from server_1 to 8.8.8.8 is successful
- Create image_1 and check its content
- Restart glance services
- Wait for glance service availability
- Check that image_1 is in images list and its content is expected as well
- Create image_2 and check its content
- Create server_2 and check ping to 8.8.8.8 from it
Teardown:
- Delete images
- Delete servers
- Delete security group
- Delete network, subnet, router
- Delete keypair
- Delete flavor
- 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:
- 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
-
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:
- 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