diff --git a/ranger-tempest-plugin/Dockerfile b/ranger-tempest-plugin/Dockerfile index 5952bd27..b28999d8 100644 --- a/ranger-tempest-plugin/Dockerfile +++ b/ranger-tempest-plugin/Dockerfile @@ -69,7 +69,7 @@ RUN grep -q 'os-testr.*' /tempest/requirements.txt \ && sed -i 's/os-testr.*/os-testr==0.8.0/' /tempest/requirements.txt \ || sed -i '/PrettyTable.*/a os-testr==0.8.0' /tempest/requirements.txt -### now run 'pip install -r requirements' +### now run 'pip install -r requirements' RUN pip install -r /tempest/requirements.txt RUN pip install -r /tempest/test-requirements.txt @@ -77,20 +77,21 @@ RUN pip install -r /tempest/test-requirements.txt RUN mkdir -p /tempest/logs \ && mkdir -p /tempest/tempest_lock \ && mkdir -p /tempest/images \ + && mkdir -p /var/log/tempest \ && rm -rf /tempest/.stestr -# copy tempest test setup files +# copy tempest test setup files COPY tempest_setup/.testr.conf /tempest/ COPY tempest_setup/create_tenant.sh /tempest/ COPY tempest_setup/accounts.yaml /tempest/etc COPY tempest_setup/tempest.conf /tempest/etc ########################################################################## -### END OF openstack tempest setup teps +### END OF openstack tempest setup steps ########################################################################## ########################################################################## -### RUN tempest tests on test_regions +### RUN tempest tests on test_regions ########################################################################## ### create egg-info for tempest WORKDIR /tempest/ diff --git a/ranger-tempest-plugin/ranger_tempest_plugin/tests/api/test_images.py b/ranger-tempest-plugin/ranger_tempest_plugin/tests/api/test_images.py index 18348294..3ee652e9 100755 --- a/ranger-tempest-plugin/ranger_tempest_plugin/tests/api/test_images.py +++ b/ranger-tempest-plugin/ranger_tempest_plugin/tests/api/test_images.py @@ -33,22 +33,22 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): @classmethod def resource_setup(cls): - # create an image for tempest testing - cls.image_params = cls._get_image_params() - cls.image = cls._create_img_and_validate_creation_on_dcp_and_lcp( + # setup public image for tempest testing + cls.image_params = cls._get_image_params(set_private=False) + cls.public_image = cls._create_img_and_validate_creation_on_dcp_and_lcp( + **cls.image_params) + + # setup private image for tempest testing + cls.image_params = cls._get_image_params(set_enabled=False) + cls.private_image = cls._create_img_and_validate_creation_on_dcp_and_lcp( **cls.image_params) - # save off specific data needed for our tempest tests - cls.image_id = cls.image['id'] - cls.image_name = cls.image['name'] - # cls.visibility = cls.image['visibility'] - # cls.tenant_id = cls.image["customers"][0] super(TestTempestIms, cls).resource_setup() @classmethod def resource_cleanup(cls): - cls._del_img_validate_deletion_on_dcp_and_lcp(cls.image_id) - # cls.region_id) + 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']) super(TestTempestIms, cls).resource_cleanup() def _data_setup(self, post_body): @@ -70,9 +70,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): """ # execute get_image using image ID and iamge_name - for identifier in [self.image_id, self.image_name]: + for identifier in [self.public_image['id'], self.public_image['name']]: _, body = self.client.get_image(identifier) - self.assertIn(self.image_id, body['image']['id']) + self.assertIn(self.public_image['id'], body['image']['id']) @decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d90') def test_list_images_with_filters(self): @@ -80,85 +80,58 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): - no filter (i.e. list all images) - 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 region_filter = "?region=%s" % self.region_id + public_filter = "?visibility=public" + private_filter = "?visibility=private" - # execute list_customers with the available filters + # list public images + _, body = self.client.list_images(public_filter) + image_ids = [img['id'] for img in body['images']] + self.assertIn(self.public_image['id'], image_ids) + + # list private images + _, body = self.client.list_images(private_filter) + image_ids = [img['id'] for img in body['images']] + self.assertIn(self.private_image['id'], image_ids) + + # execute list_customers with the rest of the filters for list_filter in [no_filter, region_filter, customer_filter]: _, body = self.client.list_images(list_filter) images = [image['id'] for image in body['images']] - self.assertIn(self.image_id, images) - - @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) + self.assertIn(self.private_image['id'], images) @decorators.idempotent_id('4435fef4-49a9-435b-8463-cf8a1e0b7cd8') def test_disable_image(self): - # setup data for test case - "enabled" is set to "true" by default - post_body = self._get_image_params() - image = self._data_setup(post_body) - test_image_id = image['id'] - # send False to IMS client enable_image function to disable customer - self.client.enabled_image(test_image_id, False) - self._wait_for_image_status_on_dcp(test_image_id, 'Success') - _, body = self.client.get_image(test_image_id) + # disable self.public_image and check if request is successful + self.client.enabled_image(self.public_image['id'], False) + self._wait_for_image_status_on_dcp(self.public_image['id'], 'Success') + _, body = self.client.get_image(self.public_image['id']) image = body["image"] + # assert that the image["enabled"] value is 'False' self.assertTrue(not image['enabled']) @decorators.idempotent_id('f32a13e3-6f38-423b-a616-09c8d4e1c277') def test_enable_image(self): - # setup data for test case - set_enabled is set to "False" - post_body = self._get_image_params(set_enabled=False) - image = self._data_setup(post_body) - test_image_id = image['id'] - # send True to IMS client enable_image function to enable customer - self.client.enabled_image(test_image_id, True) - self._wait_for_image_status_on_dcp(test_image_id, 'Success') - _, body = self.client.get_image(test_image_id) + # enable self.private_image and check if request is successful + self.client.enabled_image(self.private_image['id'], True) + self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') + _, body = self.client.get_image(self.private_image['id']) image = body["image"] + # assert that the image["enabled"] value is 'True' self.assertTrue(image['enabled']) @decorators.idempotent_id('cb9e3022-00d7-4a21-bdb2-67d3cd15a4f8') - def test_add_image_region(self): - # set_region = False to skip region assignment in data setup + def test_add_delete_image_region(self): + # skip region assignment in data setup post_body = self._get_image_params(set_region=False) image = self._data_setup(post_body) test_image_id = image['id'] @@ -167,79 +140,55 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): self.client.add_region_to_image(test_image_id, self.region_id) # image status must show 'Success' when assigned to a region self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # check that image regions array is populated correctly + + # check that region is successfully added _, body = self.client.get_image(test_image_id) image = body["image"] self.assertEqual(image["regions"][0]["name"], self.region_id) - @decorators.idempotent_id('1be2d6fd-57b0-4acf-b895-1996f857739b') - def test_delete_image_region(self): - # setup data for test case - post_body = self._get_image_params() - image = self._data_setup(post_body) - test_image_id = image['id'] - # delete the region then check to confirm image status = "no regions" _, body = self.client.delete_region_from_image(test_image_id, self.region_id) - # image status must show 'no regions' when it has no region assigned self._wait_for_image_status_on_dcp(test_image_id, 'no regions') + # image region array should be empty after the region was removed _, body = self.client.get_image(test_image_id) image = body["image"] self.assertFalse(image["regions"]) @decorators.idempotent_id('0ee68189-66a8-4213-ad68-bc12991c174a') - def test_add_image_tenant(self): - post_body = self._get_image_params() - image = self._data_setup(post_body) - test_image_id = image['id'] - _, body = self.client.get_image(test_image_id) - self.assertNotIn(self.alt_tenant_id, body['image']['customers']) + def test_add_delete_image_tenant(self): + # add alt tenant to self.private_image and check if status = "Success" + self.client.add_customer_to_image(self.private_image['id'], self.alt_tenant_id) + self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') - # add another tenant to image then check if image status = "Success" - self.client.add_customer_to_image(test_image_id, self.alt_tenant_id) - self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # check that image tenants array is populated correctly - _, body = self.client.get_image(test_image_id) + # check that alt tenant successfully added to image tenants array + _, body = self.client.get_image(self.private_image['id']) image = body["image"] self.assertEqual(len(image["customers"]), 2) - self.assertIn(self.alt_tenant_id, body['image']['customers']) + self.assertIn(self.alt_tenant_id, image['customers']) + + # now delete alt_tenant_id and ensure operation is successful + _, body = self.client.delete_customer_from_image(self.private_image['id'], + self.alt_tenant_id) + self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') + + # image region array should no longer contain alt tenant + _, body = self.client.get_image(self.private_image['id']) + image = body["image"] + self.assertNotIn(self.alt_tenant_id, image['customers']) @decorators.idempotent_id('bac99348-6b13-4b30-958b-3c039b27eda3') def test_update_image_tenant(self): - post_body = self._get_image_params() - image = self._data_setup(post_body) - test_image_id = image['id'] - _, body = self.client.get_image(test_image_id) - self.assertNotIn(self.alt_tenant_id, body['image']['customers']) + # replace current tenant in self.private_image with alt tenant + self.client.update_customer(self.private_image['id'], self.alt_tenant_id) + self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success') - # add another tenant to image then check if image status = "Success" - self.client.update_customer(test_image_id, self.alt_tenant_id) - self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # check that image tenants array is populated correctly - _, body = self.client.get_image(test_image_id) + # check that image tenants array contains only alt tenant + _, body = self.client.get_image(self.private_image['id']) image = body["image"] self.assertEqual(len(image["customers"]), 1) - self.assertIn(self.alt_tenant_id, body['image']['customers']) - - @decorators.idempotent_id('0506f23d-2d30-4214-9a4a-003ace86aa7d') - def test_delete_image_tenant(self): - # assign two tenants to image - post_body = self._get_image_params(single_tenant=False) - image = self._data_setup(post_body) - test_image_id = image['id'] - _, body = self.client.get_image(test_image_id) - self.assertIn(self.alt_tenant_id, body['image']['customers']) - - # delete one tenant then check if image status = "Success" - _, body = self.client.delete_customer_from_image(test_image_id, - self.alt_tenant_id) - self._wait_for_image_status_on_dcp(test_image_id, 'Success') - # image region array should be empty after the region was removed - _, body = self.client.get_image(test_image_id) - image = body["image"] - self.assertNotIn(self.alt_tenant_id, body['image']['customers']) + self.assertIn(self.alt_tenant_id, image['customers']) @decorators.idempotent_id('0331e02a-ab52-4341-b676-a02462244277') def test_create_image(self): @@ -283,7 +232,7 @@ class TestTempestIms(ims_base.ImsBaseOrmTest): _, body = self.client.get_image(test_image_id) image = body["image"] self.assertEqual(image["regions"][0]["name"], CONF.identity.region) - self.assertIn(self.alt_tenant_id, body['image']['customers']) + self.assertIn(self.alt_tenant_id, image['customers']) self.assertTrue(image['enabled']) @decorators.idempotent_id('23e2e7e2-5b19-4c66-b35c-7c686a986627') diff --git a/ranger-tempest-plugin/tempest_setup/tempest.conf b/ranger-tempest-plugin/tempest_setup/tempest.conf index 5b23af5d..38eba813 100644 --- a/ranger-tempest-plugin/tempest_setup/tempest.conf +++ b/ranger-tempest-plugin/tempest_setup/tempest.conf @@ -1,7 +1,7 @@ [DEFAULT] debug = true log_file = tempest.log -log_dir = /var/log +log_dir = /var/log/tempest [auth] test_accounts_file = etc/accounts.yaml