Added Test Related to Image Management System

fixed Lint issues
  create Protected Image
  create image with tags and properties
  create image with uuid
  create image with region and region group
  test image region status and aggregate status

Change-Id: I116615fc1047294411d11c7a07687d6952534b73
This commit is contained in:
AbhishekJ
2019-08-02 12:06:23 +00:00
parent 27d3c816d9
commit 5dc739f533

View File

@@ -1,328 +1,463 @@
# Copyright 2016 AT&T Corp # Copyright 2016 AT&T Corp
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from ranger_tempest_plugin.data_utils import data_utils import uuid
from ranger_tempest_plugin.tests.api import ims_base
from tempest import config from ranger_tempest_plugin.data_utils import data_utils
from tempest.lib import decorators from ranger_tempest_plugin.tests.api import ims_base
from tempest.lib import exceptions from tempest import config
from tempest.lib import decorators
CONF = config.CONF from tempest.lib import exceptions
CONF = config.CONF
class TestTempestIms(ims_base.ImsBaseOrmTest):
@classmethod class TestTempestIms(ims_base.ImsBaseOrmTest):
def setup_credentials(cls):
super(TestTempestIms, cls).setup_credentials() @classmethod
def setup_credentials(cls):
@classmethod super(TestTempestIms, cls).setup_credentials()
def setup_clients(cls):
super(TestTempestIms, cls).setup_clients() @classmethod
def setup_clients(cls):
@classmethod super(TestTempestIms, cls).setup_clients()
def resource_setup(cls):
# setup public image for tempest testing @classmethod
cls.image_params = \ def resource_setup(cls):
cls._get_image_params(set_private=False) # setup public image for tempest testing
cls.public_image = \ cls.image_params = \
cls._create_img_and_validate_creation_on_dcp_and_lcp( cls._get_image_params(set_private=False)
**cls.image_params) cls.public_image = \
cls._create_img_and_validate_creation_on_dcp_and_lcp(
# setup private image for tempest testing **cls.image_params)
cls.image_params = cls._get_image_params(set_enabled=False)
cls.private_image = \ # setup private image for tempest testing
cls._create_img_and_validate_creation_on_dcp_and_lcp( cls.image_params = cls._get_image_params(set_enabled=False)
**cls.image_params) cls.private_image = \
cls._create_img_and_validate_creation_on_dcp_and_lcp(
super(TestTempestIms, cls).resource_setup() **cls.image_params)
@classmethod super(TestTempestIms, cls).resource_setup()
def resource_cleanup(cls):
cls._del_img_validate_deletion_on_dcp_and_lcp(cls.public_image['id']) @classmethod
cls._del_img_validate_deletion_on_dcp_and_lcp(cls.private_image['id']) def resource_cleanup(cls):
super(TestTempestIms, cls).resource_cleanup() cls._del_img_validate_deletion_on_dcp_and_lcp(cls.public_image['id'])
cls._del_img_validate_deletion_on_dcp_and_lcp(cls.private_image['id'])
def _data_setup(self, post_body): super(TestTempestIms, cls).resource_cleanup()
image = self._create_img_and_validate_creation_on_dcp_and_lcp(
**post_body) def _data_setup(self, post_body):
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp, image = self._create_img_and_validate_creation_on_dcp_and_lcp(
image["id"]) **post_body)
# only check for Success image status if "regions" is not empty self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
if image["regions"]: image["id"])
self._wait_for_image_status_on_dcp(image["id"], 'Success') # only check for Success image status if "regions" is not empty
if image["regions"]:
return image self._wait_for_image_status_on_dcp(image["id"], 'Success')
def _delete_image(self, id_): return image
"""Try to delete from from dcp only"""
# delete the data and do get_image to ensure 404-NotFound response def _delete_image(self, id_):
self._del_img_validate_deletion_on_dcp_and_lcp(id_) """Try to delete from from dcp only"""
self.assertRaises(exceptions.NotFound, self.client.get_image, id_) # delete the data and do get_image to ensure 404-NotFound response
self._del_img_validate_deletion_on_dcp_and_lcp(id_)
def _create_region(self, status='functional'): self.assertRaises(exceptions.NotFound, self.client.get_image, id_)
region_name = data_utils.rand_name()
_, region = self.os_admin.rms_client.create_region( def _create_region(self, status='functional'):
**{ region_name = data_utils.rand_name()
'region_id': region_name, _, region = self.os_admin.rms_client.create_region(
'status': status, **{
} 'region_id': region_name,
) 'status': status,
self.addCleanup(self.os_admin.rms_client.delete_region, region_name) }
return region )
self.addCleanup(self.os_admin.rms_client.delete_region, region_name)
@decorators.idempotent_id('2b1bb28b-4151-4e75-ae1b-d21089c3418c') return region
def test_get_image(self):
"""Execute 'get_image' using the following options: @decorators.idempotent_id('2b1bb28b-4151-4e75-ae1b-d21089c3418c')
def test_get_image(self):
- get image by id (using cust_id parameter) """Execute 'get_image' using the following options:
- get image by name (using cust_name parameter)
""" - get image by id (using cust_id parameter)
- get image by name (using cust_name parameter)
# execute get_image using image ID and iamge_name """
for identifier in [self.public_image['id'], self.public_image['name']]:
_, body = self.client.get_image(identifier) # execute get_image using image ID and iamge_name
self.assertIn(self.public_image['id'], body['image']['id']) for identifier in [self.public_image['id'], self.public_image['name']]:
_, body = self.client.get_image(identifier)
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d90') self.assertIn(self.public_image['id'], body['image']['id'])
def test_list_images_with_filters(self):
"""This function executes 'list customer' with all available filters: @decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d90')
def test_list_images_with_filters(self):
- no filter (i.e. list all images) """This function executes 'list customer' with all available filters:
- filter by region
- filter by customer - no filter (i.e. list all images)
- filter by visibility (public/private) - filter by region
""" - filter by customer
- filter by visibility (public/private)
# define the list customer filters to be used for this test """
no_filter = None
customer_filter = "?customer=%s" % self.tenant_id # define the list customer filters to be used for this test
region_filter = "?region=%s" % self.region_id no_filter = None
public_filter = "?visibility=public" customer_filter = "?customer=%s" % self.tenant_id
private_filter = "?visibility=private" region_filter = "?region=%s" % self.region_id
public_filter = "?visibility=public"
# list public images private_filter = "?visibility=private"
_, body = self.client.list_images(public_filter)
image_ids = [img['id'] for img in body['images']] # list public images
self.assertIn(self.public_image['id'], image_ids) _, body = self.client.list_images(public_filter)
image_ids = [img['id'] for img in body['images']]
# list private images self.assertIn(self.public_image['id'], image_ids)
_, body = self.client.list_images(private_filter)
image_ids = [img['id'] for img in body['images']] # list private images
self.assertIn(self.private_image['id'], image_ids) _, body = self.client.list_images(private_filter)
image_ids = [img['id'] for img in body['images']]
# execute list_customers with the rest of the filters self.assertIn(self.private_image['id'], image_ids)
for list_filter in [no_filter, region_filter,
customer_filter]: # execute list_customers with the rest of the filters
_, body = self.client.list_images(list_filter) for list_filter in [no_filter, region_filter,
images = [image['id'] for image in body['images']] customer_filter]:
self.assertIn(self.private_image['id'], images) _, body = self.client.list_images(list_filter)
images = [image['id'] for image in body['images']]
@decorators.idempotent_id('4435fef4-49a9-435b-8463-cf8a1e0b7cd8') self.assertIn(self.private_image['id'], images)
def test_disable_image(self):
# disable self.public_image and check if request is successful @decorators.idempotent_id('4435fef4-49a9-435b-8463-cf8a1e0b7cd8')
self.client.enabled_image(self.public_image['id'], False) def test_disable_image(self):
self._wait_for_image_status_on_dcp(self.public_image['id'], 'Success') # disable self.public_image and check if request is successful
_, body = self.client.get_image(self.public_image['id']) self.client.enabled_image(self.public_image['id'], False)
image = body["image"] self._wait_for_image_status_on_dcp(self.public_image['id'], 'Success')
_, body = self.client.get_image(self.public_image['id'])
# assert that the image["enabled"] value is 'False' image = body["image"]
self.assertTrue(not image['enabled'])
# assert that the image["enabled"] value is 'False'
@decorators.idempotent_id('f32a13e3-6f38-423b-a616-09c8d4e1c277') self.assertTrue(not image['enabled'])
def test_enable_image(self):
# enable self.private_image and check if request is successful @decorators.idempotent_id('f32a13e3-6f38-423b-a616-09c8d4e1c277')
self.client.enabled_image(self.private_image['id'], True) def test_enable_image(self):
self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') # enable self.private_image and check if request is successful
_, body = self.client.get_image(self.private_image['id']) self.client.enabled_image(self.private_image['id'], True)
image = body["image"] self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success')
_, body = self.client.get_image(self.private_image['id'])
# assert that the image["enabled"] value is 'True' image = body["image"]
self.assertTrue(image['enabled'])
# assert that the image["enabled"] value is 'True'
@decorators.idempotent_id('cb9e3022-00d7-4a21-bdb2-67d3cd15a4f8') self.assertTrue(image['enabled'])
def test_add_delete_image_region(self):
# skip region assignment in data setup @decorators.idempotent_id('cb9e3022-00d7-4a21-bdb2-67d3cd15a4f8')
post_body = self._get_image_params(set_region=False) def test_add_delete_image_region(self):
image = self._data_setup(post_body) # skip region assignment in data setup
test_image_id = image['id'] post_body = self._get_image_params(set_region=False)
image = self._data_setup(post_body)
# add region to image then check to confirm image status = "Success" test_image_id = image['id']
self.client.add_region_to_image(test_image_id, self.region_id)
# image status must show 'Success' when assigned to a region # add region to image then check to confirm image status = "Success"
self._wait_for_image_status_on_dcp(test_image_id, 'Success') self.client.add_region_to_image(test_image_id, self.region_id)
# image status must show 'Success' when assigned to a region
# check that region is successfully added self._wait_for_image_status_on_dcp(test_image_id, 'Success')
_, body = self.client.get_image(test_image_id)
image = body["image"] # check that region is successfully added
self.assertEqual(image["regions"][0]["name"], self.region_id) _, body = self.client.get_image(test_image_id)
image = body["image"]
# delete the region then check to confirm image status = "no regions" self.assertEqual(image["regions"][0]["name"], self.region_id)
_, body = self.client.delete_region_from_image(test_image_id,
self.region_id) # delete the region then check to confirm image status = "no regions"
self._wait_for_image_status_on_dcp(test_image_id, 'no regions') _, body = self.client.delete_region_from_image(test_image_id,
self.region_id)
# image region array should be empty after the region was removed self._wait_for_image_status_on_dcp(test_image_id, 'no regions')
_, body = self.client.get_image(test_image_id)
image = body["image"] # image region array should be empty after the region was removed
self.assertFalse(image["regions"]) _, body = self.client.get_image(test_image_id)
image = body["image"]
@decorators.idempotent_id('0ee68189-66a8-4213-ad68-bc12991c174a') self.assertFalse(image["regions"])
def test_add_delete_image_tenant(self):
# add alt tenant to self.private_image & check if status = "Success" @decorators.idempotent_id('0ee68189-66a8-4213-ad68-bc12991c174a')
self.client.add_customer_to_image(self.private_image['id'], def test_add_delete_image_tenant(self):
self.alt_tenant_id) # add alt tenant to self.private_image & check if status = "Success"
self._wait_for_image_status_on_dcp(self.private_image['id'], self.client.add_customer_to_image(self.private_image['id'],
'Success') self.alt_tenant_id)
self._wait_for_image_status_on_dcp(self.private_image['id'],
# check that alt tenant successfully added to image tenants array 'Success')
_, body = self.client.get_image(self.private_image['id'])
image = body["image"] # check that alt tenant successfully added to image tenants array
self.assertEqual(len(image["customers"]), 2) _, body = self.client.get_image(self.private_image['id'])
self.assertIn(self.alt_tenant_id, image['customers']) image = body["image"]
self.assertEqual(len(image["customers"]), 2)
# now delete alt_tenant_id and ensure operation is successful self.assertIn(self.alt_tenant_id, image['customers'])
_, body = self.client.delete_customer_from_image(
self.private_image['id'], # now delete alt_tenant_id and ensure operation is successful
self.alt_tenant_id) _, body = self.client.delete_customer_from_image(
self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') self.private_image['id'],
self.alt_tenant_id)
# image region array should no longer contain alt tenant self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success')
_, body = self.client.get_image(self.private_image['id'])
image = body["image"] # image region array should no longer contain alt tenant
self.assertNotIn(self.alt_tenant_id, image['customers']) _, body = self.client.get_image(self.private_image['id'])
image = body["image"]
@decorators.idempotent_id('bac99348-6b13-4b30-958b-3c039b27eda3') self.assertNotIn(self.alt_tenant_id, image['customers'])
def test_update_image_tenant(self):
# replace current tenant in self.private_image with alt tenant @decorators.idempotent_id('bac99348-6b13-4b30-958b-3c039b27eda3')
self.client.update_customer(self.private_image['id'], def test_update_image_tenant(self):
self.alt_tenant_id) # replace current tenant in self.private_image with alt tenant
self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') self.client.update_customer(self.private_image['id'],
self.alt_tenant_id)
# check that image tenants array contains only alt tenant self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success')
_, body = self.client.get_image(self.private_image['id'])
image = body["image"] # check that image tenants array contains only alt tenant
self.assertEqual(len(image["customers"]), 1) _, body = self.client.get_image(self.private_image['id'])
self.assertIn(self.alt_tenant_id, image['customers']) image = body["image"]
self.assertEqual(len(image["customers"]), 1)
@decorators.idempotent_id('0331e02a-ab52-4341-b676-a02462244277') self.assertIn(self.alt_tenant_id, image['customers'])
def test_create_image(self):
post_body = self._get_image_params() @decorators.idempotent_id('0331e02a-ab52-4341-b676-a02462244277')
# call client create_IMAGE and wait till status equals 'Success' def test_create_image(self):
_, body = self.client.create_image(**post_body) post_body = self._get_image_params()
image = body["image"] # call client create_IMAGE and wait till status equals 'Success'
test_image_id = image["id"] _, body = self.client.create_image(**post_body)
self._wait_for_image_status_on_dcp(test_image_id, 'Success') image = body["image"]
test_image_id = image["id"]
# do not forget to add this account to addCleanUp self._wait_for_image_status_on_dcp(test_image_id, 'Success')
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id) # do not forget to add this account to addCleanUp
# verify image record created successfully self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
_, body = self.client.get_image(test_image_id) test_image_id)
image = body["image"] # verify image record created successfully
self.assertEqual(image["regions"][0]["name"], CONF.identity.region) _, body = self.client.get_image(test_image_id)
image = body["image"]
@decorators.idempotent_id('01160918-e217-401d-a6a0-e7992ab76e41') self.assertEqual(image["regions"][0]["name"], CONF.identity.region)
def test_update_image(self):
region = {} @decorators.idempotent_id('01160918-e217-401d-a6a0-e7992ab76e41')
post_body = self._get_image_params(set_region=False) def test_update_image(self):
image = self._data_setup(post_body) region = {}
test_image_id = image['id'] post_body = self._get_image_params(set_region=False)
image = self._data_setup(post_body)
# setup region and change 'enabled', 'customers' properties test_image_id = image['id']
region["name"] = self.region_id
region["type"] = "single" # setup region and change 'enabled', 'customers' properties
region["checksum"] = "7297321c2fa6424417a548c85edd6e98" region["name"] = self.region_id
region["virtual_size"] = "None" region["type"] = "single"
region["size"] = "38797312" region["checksum"] = "7297321c2fa6424417a548c85edd6e98"
post_body["regions"] = [region] region["virtual_size"] = "None"
post_body["enabled"] = False region["size"] = "38797312"
post_body["customers"] = [self.alt_tenant_id] post_body["regions"] = [region]
# empty tags list post_body["enabled"] = False
post_body["tags"] = [] post_body["customers"] = [self.alt_tenant_id]
# empty tags list
_, body = self.client.update_image(test_image_id, para=None, post_body["tags"] = []
**post_body)
self._wait_for_image_status_on_dcp(test_image_id, 'Success') _, body = self.client.update_image(test_image_id, para=None,
# verify image record updated successfully **post_body)
_, body = self.client.get_image(test_image_id) self._wait_for_image_status_on_dcp(test_image_id, 'Success')
image = body["image"] # verify image record updated successfully
self.assertEqual(image["regions"][0]["name"], CONF.identity.region) _, body = self.client.get_image(test_image_id)
self.assertIn(self.alt_tenant_id, image['customers']) image = body["image"]
self.assertFalse(image['enabled']) self.assertEqual(image["regions"][0]["name"], CONF.identity.region)
self.assertFalse(image['tags']) self.assertIn(self.alt_tenant_id, image['customers'])
self.assertFalse(image['enabled'])
@decorators.idempotent_id('23e2e7e2-5b19-4c66-b35c-7c686a986627') self.assertFalse(image['tags'])
def test_delete_image(self):
# setup data for test case @decorators.idempotent_id('23e2e7e2-5b19-4c66-b35c-7c686a986627')
post_body = self._get_image_params() def test_delete_image(self):
image = self._create_img_and_validate_creation_on_dcp_and_lcp( # setup data for test case
**post_body) post_body = self._get_image_params()
test_image_id = image['id'] image = self._create_img_and_validate_creation_on_dcp_and_lcp(
**post_body)
# delete the data and do get_image to ensure 404-NotFound response test_image_id = image['id']
self._del_img_validate_deletion_on_dcp_and_lcp(test_image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, # delete the data and do get_image to ensure 404-NotFound response
test_image_id) self._del_img_validate_deletion_on_dcp_and_lcp(test_image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image,
@decorators.idempotent_id('e642fa39-1b69-4d17-8bd1-aee90ea042a3') test_image_id)
def test_image_while_region_down(self):
# create region with status down @decorators.idempotent_id('e642fa39-1b69-4d17-8bd1-aee90ea042a3')
region = self._create_region(status='down') def test_image_while_region_down(self):
# create region with status down
# create flavor within that newly created region region = self._create_region(status='down')
post_body = self._get_image_params()
post_body['regions'][0]['name'] = region['name'] # create flavor within that newly created region
self.assertRaises(exceptions.BadRequest, post_body = self._get_image_params()
self.client.create_image, **post_body) post_body['regions'][0]['name'] = region['name']
self.assertRaises(exceptions.BadRequest,
@decorators.idempotent_id('a1fee342-3000-41a6-97f9-b33fd2734e4d') self.client.create_image, **post_body)
def test_image_while_region_building(self):
# create region with status building @decorators.idempotent_id('a1fee342-3000-41a6-97f9-b33fd2734e4d')
region = self._create_region(status='building') def test_image_while_region_building(self):
# create region with status building
# create image within that newly created region region = self._create_region(status='building')
post_body = self._get_image_params()
post_body['regions'][0]['name'] = region['name'] # create image within that newly created region
_, body = self.client.create_image(**post_body) post_body = self._get_image_params()
self.assertIn('id', body['image']) post_body['regions'][0]['name'] = region['name']
test_image_id = body['image']['id'] _, body = self.client.create_image(**post_body)
self.addCleanup(self._delete_image, test_image_id) self.assertIn('id', body['image'])
test_image_id = body['image']['id']
_, body = self.client.get_image(test_image_id) self.addCleanup(self._delete_image, test_image_id)
# since region is building it will give error
# Notification to ORD failed _, body = self.client.get_image(test_image_id)
_, body = self.client.get_image(test_image_id) # since region is building it will give error
self.assertEqual(body['image']['id'], test_image_id) # Notification to ORD failed
self.assertEqual(body['image']['status'], 'error') _, body = self.client.get_image(test_image_id)
self.assertEqual(body['image']['id'], test_image_id)
@decorators.idempotent_id('b967ce58-5d24-4af2-8416-a336772c8087') self.assertEqual(body['image']['status'], 'error')
def test_image_while_region_maintenance(self):
# create region with status maintenance @decorators.idempotent_id('b967ce58-5d24-4af2-8416-a336772c8087')
region = self._create_region(status='maintenance') def test_image_while_region_maintenance(self):
# create region with status maintenance
# create image within that newly created region region = self._create_region(status='maintenance')
post_body = self._get_image_params()
post_body['regions'][0]['name'] = region['name'] # create image within that newly created region
_, body = self.client.create_image(**post_body) post_body = self._get_image_params()
self.assertIn('id', body['image']) post_body['regions'][0]['name'] = region['name']
test_image_id = body['image']['id'] _, body = self.client.create_image(**post_body)
self.addCleanup(self._delete_image, test_image_id) self.assertIn('id', body['image'])
test_image_id = body['image']['id']
_, body = self.client.get_image(test_image_id) self.addCleanup(self._delete_image, test_image_id)
# since region is maintenance it will give error
# Notification to ORD failed _, body = self.client.get_image(test_image_id)
self.assertEqual(body['image']['id'], test_image_id) # since region is maintenance it will give error
self.assertEqual(body['image']['status'], 'Error') # Notification to ORD failed
self.assertEqual(body['image']['id'], test_image_id)
self.assertEqual(body['image']['status'], 'Error')
@decorators.idempotent_id('eae7ca20-5383-4579-9f73-0138b8b3ec85')
def test_list_public_images(self):
"""List images with visibility = 'public'"""
# set_private = False to create image with visibility = 'public'
post_body = self._get_image_params(set_private=False)
image = self._data_setup(post_body)
test_image_id = image['id']
# confirm image visibility is set to "public" after image is created
self.assertEqual(image["visibility"], "public")
filter_public_images = "?visibility=%s" % image["visibility"]
# list all public images and check if test_image_id is in the list
_, body = self.client.list_images(filter_public_images)
image_ids = [img['id'] for img in body['images']]
self.assertIn(test_image_id, image_ids)
@decorators.idempotent_id('dc321d60-f3bd-477c-b7bf-1594626f0a12')
def test_list_private_images(self):
"""List images with visibility = 'private' """
# image data created with visibility = private set by default
post_body = self._get_image_params()
image = self._data_setup(post_body)
test_image_id = image['id']
# confirm image visibility is set to "private" after image is created
self.assertEqual(image["visibility"], "private")
filter_private_images = "?visibility=%s" % image["visibility"]
# list all public images and check if test_image_id is in the list
_, body = self.client.list_images(filter_private_images)
image_ids = [img['id'] for img in body['images']]
self.assertIn(test_image_id, image_ids)
@decorators.idempotent_id('59887b26-8e73-4781-87a4-3b505ece0021')
def test_create_image_protected_true(self):
post_body = self._get_image_params()
# set Protected True
post_body['protected'] = True
# call client create_IMAGE and wait till status equals 'Success'
_, body = self.client.create_image(**post_body)
image = body["image"]
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
image = body["image"]
self.assertEqual(image["regions"][0]["name"], CONF.identity.region)
@decorators.idempotent_id('56cd1de0-3908-41d5-af98-45ad95463817')
def test_create_image_with_tags_properties(self):
post_body = self._get_image_params()
# set tags and properties
tags = ["brocade", "vyatta", "vCEImage", "mediumImage"]
properties = {
"Application-Name": "Vyatta",
"Application-Type": "VCE",
"Application-Vendor": "Brocade",
"Application-Version": "3.5.R5.att-V6.0",
"hw_vif_model": "VirtualVmxnet3",
"OS": "Debian",
"OS-Version": "7",
"Post-Processing-Networking": "None",
"Post-Processing-Tools": "None",
"vmware-adaptertype": "ide",
"vmware-disktype": "sparse"
}
post_body["tags"] = tags
post_body["properties"] = properties
# call client create_IMAGE and wait till status equals 'Success'
_, body = self.client.create_image(**post_body)
image = body["image"]
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
image = body["image"]
self.assertListEqual(image["regions"][0]["tags"], tags)
self.assertDictEqual(image["regions"][0]["properties"], properties)
@decorators.idempotent_id('67aa7014-4dbb-4d66-bc7b-1a95a57494f8')
def test_create_image_with_uuid(self):
post_body = self._get_image_params()
# set uuid
str_uuid = uuid.uuid4().hex
post_body['id'] = str_uuid
# call client create_IMAGE and wait till status equals 'Success'
_, body = self.client.create_image(**post_body)
image = body["image"]
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
image = body["image"]
self.assertEqual(image["regions"][0]["id"], str_uuid)
@decorators.idempotent_id('ae1223b5-cb75-442b-82eb-488969acc978')
def test_create_flavor_with_region_group(self):
post_body = self._get_image_params()
# region group
region_group = {"name": "NCLargetest", "type": "group"}
# update region_group to regions
post_body["regions"].append(region_group)
# call client create_IMAGE and wait till status equals 'Success'
_, body = self.client.create_image(**post_body)
image = body["image"]
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
image = body["image"]
# Aggregate Status
self.assertEqual(image["status"], 'Success')
# Region Status
self.assertEqual(image["regions"][1]["status"], 'Success')
# region group
self.assertDictEqual(image["regions"][1]["name"], "NCLargetest")