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

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from ranger_tempest_plugin.data_utils import data_utils
from ranger_tempest_plugin.tests.api import ims_base
from tempest import config
@ -326,3 +328,136 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
# 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")