diff options
Diffstat (limited to 'openstack_dashboard/test/integration_tests/tests/test_images.py')
-rw-r--r-- | openstack_dashboard/test/integration_tests/tests/test_images.py | 233 |
1 files changed, 137 insertions, 96 deletions
diff --git a/openstack_dashboard/test/integration_tests/tests/test_images.py b/openstack_dashboard/test/integration_tests/tests/test_images.py index f2d9f109a..8065eaa92 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_images.py +++ b/openstack_dashboard/test/integration_tests/tests/test_images.py @@ -11,14 +11,16 @@ # under the License. import pytest -from openstack_dashboard.test.integration_tests import decorators from openstack_dashboard.test.integration_tests import helpers from openstack_dashboard.test.integration_tests.regions import messages +from openstack_dashboard.test.integration_tests.pages.project.\ + compute.instancespage import InstancesPage +from openstack_dashboard.test.integration_tests.pages.project.\ + volumes.volumespage import VolumesPage -@decorators.config_option_required('image.panel_type', 'legacy', - message="Angular Panels not tested") -class TestImagesLegacy(helpers.TestCase): + +class TestImagesBasicAngular(helpers.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.IMAGE_NAME = helpers.gen_random_resource_name("image") @@ -27,30 +29,10 @@ class TestImagesLegacy(helpers.TestCase): def images_page(self): return self.home_pg.go_to_project_compute_imagespage() - -@decorators.config_option_required('image.panel_type', 'angular', - message="Legacy Panels not tested") -class TestImagesAngular(helpers.TestCase): - @property - def images_page(self): - # FIXME(tsufiev): had to return angularized version of Images Page - # object with the horrendous hack below because it's not so easy to - # wire into the Navigation machinery and tell it to return an '*NG' - # version of ImagesPage class if one adds '_ng' suffix to - # 'go_to_compute_imagespage()' method. Yet that's how it should work - # (or rewrite Navigation module completely). - from openstack_dashboard.test.integration_tests.pages.project.\ - compute.imagespage import ImagesPageNG - self.home_pg.go_to_project_compute_imagespage() - return ImagesPageNG(self.driver, self.CONFIG) - def test_basic_image_browse(self): images_page = self.images_page self.assertEqual(images_page.header.text, 'Images') - -class TestImagesBasic(TestImagesLegacy): - """Login as demo user""" def image_create(self, local_file=None, **kwargs): images_page = self.images_page if local_file: @@ -58,8 +40,10 @@ class TestImagesBasic(TestImagesLegacy): image_file=local_file, **kwargs) else: - images_page.create_image(self.IMAGE_NAME, **kwargs) - self.assertTrue(images_page.find_message_and_dismiss(messages.INFO)) + images_page.create_image(self.IMAGE_NAME, + image_source_type='url', + **kwargs) + self.assertTrue(images_page.find_message_and_dismiss(messages.SUCCESS)) self.assertFalse(images_page.find_message_and_dismiss(messages.ERROR)) self.assertTrue(images_page.is_image_present(self.IMAGE_NAME)) self.assertTrue(images_page.is_image_active(self.IMAGE_NAME)) @@ -72,30 +56,30 @@ class TestImagesBasic(TestImagesLegacy): self.assertFalse(images_page.find_message_and_dismiss(messages.ERROR)) self.assertFalse(images_page.is_image_present(self.IMAGE_NAME)) - @pytest.mark.skip(reason="Bug 1595335") - def test_image_create_delete(self): + def test_image_create_delete_from_local_file(self): """tests the image creation and deletion functionalities: - * creates a new image from horizon.conf http_image + * creates a new image from a generated file * verifies the image appears in the images table as active * deletes the newly created image * verifies the image does not appear in the table after deletion """ - self.image_create() - self.image_delete(self.IMAGE_NAME) + with helpers.gen_temporary_file() as file_name: + self.image_create(local_file=file_name) + self.image_delete(self.IMAGE_NAME) - def test_image_create_delete_from_local_file(self): + # Run when Glance configuration and policies allow setting locations. + @pytest.mark.skip(reason="IMAGES_ALLOW_LOCATION = False") + def test_image_create_delete_from_url(self): """tests the image creation and deletion functionalities: - * downloads image from horizon.conf stated in http_image - * creates the image from the downloaded file + * creates a new image from horizon.conf http_image * verifies the image appears in the images table as active * deletes the newly created image * verifies the image does not appear in the table after deletion """ - with helpers.gen_temporary_file() as file_name: - self.image_create(local_file=file_name) - self.image_delete(self.IMAGE_NAME) + self.image_create() + self.image_delete(self.IMAGE_NAME) def test_images_pagination(self): """This test checks images pagination @@ -115,23 +99,51 @@ class TestImagesBasic(TestImagesLegacy): 9) Click 'Prev' and check results (should be the same as for step5) 10) Go to user settings page and restore 'Items Per Page' """ + default_image_list = self.CONFIG.image.images_list + + images_page = self.images_page + + # delete any old images except default ones + images_page.wait_until_image_present(default_image_list[0]) + image_list = images_page.images_table.get_column_data( + name_column='Name') + garbage = [i for i in image_list if i not in default_image_list] + if garbage: + images_page.delete_images(garbage) + self.assertTrue( + images_page.find_message_and_dismiss(messages.SUCCESS)) + items_per_page = 1 + images_count = 2 + images_names = ["{0}_{1}".format(self.IMAGE_NAME, item) + for item in range(images_count)] + for image_name in images_names: + with helpers.gen_temporary_file() as file_name: + images_page.create_image(image_name, image_file=file_name) + self.assertTrue( + images_page.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse( + images_page.find_message_and_dismiss(messages.ERROR)) + self.assertTrue(images_page.is_image_present(image_name)) + first_page_definition = {'Next': True, 'Prev': False, 'Count': items_per_page, 'Names': [default_image_list[0]]} second_page_definition = {'Next': True, 'Prev': True, 'Count': items_per_page, - 'Names': [default_image_list[1]]} + 'Names': [images_names[0]]} third_page_definition = {'Next': False, 'Prev': True, 'Count': items_per_page, - 'Names': [default_image_list[2]]} + 'Names': [images_names[1]]} settings_page = self.home_pg.go_to_settings_usersettingspage() settings_page.change_pagesize(items_per_page) settings_page.find_message_and_dismiss(messages.SUCCESS) images_page = self.images_page + if not images_page.is_image_present(default_image_list[0]): + images_page.wait_until_image_present(default_image_list[0]) images_page.images_table.assert_definition(first_page_definition) images_page.images_table.turn_next_page() @@ -150,6 +162,20 @@ class TestImagesBasic(TestImagesLegacy): settings_page.change_pagesize() settings_page.find_message_and_dismiss(messages.SUCCESS) + images_page = self.images_page + images_page.wait_until_image_present(default_image_list[0]) + images_page.delete_images(images_names) + self.assertTrue(images_page.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse(images_page.find_message_and_dismiss(messages.ERROR)) + + +class TestImagesAdminAngular(helpers.AdminTestCase, TestImagesBasicAngular): + """Login as admin user""" + + @property + def images_page(self): + return self.home_pg.go_to_admin_compute_imagespage() + def test_update_image_metadata(self): """Test update image metadata @@ -168,9 +194,6 @@ class TestImagesBasic(TestImagesLegacy): 'metadata2': helpers.gen_random_resource_name("value")} with helpers.gen_temporary_file() as file_name: - # TODO(tsufiev): had to add non-empty description to an image, - # because description is now considered a metadata and we want - # the metadata in a newly created image to be valid images_page = self.image_create(local_file=file_name, description='test description') images_page.add_custom_metadata(self.IMAGE_NAME, new_metadata) @@ -203,21 +226,24 @@ class TestImagesBasic(TestImagesLegacy): # Check that Delete action is not available in the action list. # The below action will generate exception since the bind fails. # But only ValueError with message below is expected here. - with self.assertRaisesRegex(ValueError, 'Could not bind method'): + message = "Could not bind method 'delete_image_via_row_action' " \ + "to action control 'Delete Image'" + with self.assertRaisesRegex(ValueError, message): images_page.delete_image_via_row_action(self.IMAGE_NAME) - # Try to delete image. That should not be possible now. - images_page.delete_image(self.IMAGE_NAME) - self.assertFalse( - images_page.find_message_and_dismiss(messages.SUCCESS)) - self.assertTrue( - images_page.find_message_and_dismiss(messages.ERROR)) - self.assertTrue(images_page.is_image_present(self.IMAGE_NAME)) + # Edit image to make it not protected again and delete it. + images_page = self.images_page images_page.edit_image(self.IMAGE_NAME, protected=False) self.assertTrue( images_page.find_message_and_dismiss(messages.SUCCESS)) + self.assertFalse( + images_page.find_message_and_dismiss(messages.ERROR)) + self.image_delete(self.IMAGE_NAME) + self.assertFalse( + images_page.find_message_and_dismiss(messages.ERROR)) + self.assertFalse(images_page.is_image_present(self.IMAGE_NAME)) def test_edit_image_description_and_name(self): """tests that image description is editable @@ -264,9 +290,53 @@ class TestImagesBasic(TestImagesLegacy): self.assertSequenceTrue(results) self.image_delete(new_image_name) + self.assertFalse( + images_page.find_message_and_dismiss(messages.ERROR)) + self.assertFalse(images_page.is_image_present(self.IMAGE_NAME)) + def test_filter_images(self): + """This test checks filtering of images + + Steps: + 1) Login to Horizon dashboard as admin user + 2) Go to Admin -> Compute -> Images + 3) Use filter by Image Name + 4) Check that filtered table has one image only (which name is + equal to filter value) + 5) Check that no other images in the table + 6) Clear filter and set nonexistent image name. Check that 0 rows + are displayed + """ + default_image_list = self.CONFIG.image.images_list + images_page = self.images_page + + images_page.filter(default_image_list[0]) + self.assertTrue(images_page.is_image_present(default_image_list[0])) + for image in default_image_list[1:]: + self.assertFalse(images_page.is_image_present(image)) + + images_page = self.images_page + nonexistent_image_name = "{0}_test".format(self.IMAGE_NAME) + images_page.filter(nonexistent_image_name) + self.assertEqual(images_page.images_table.rows, []) + + images_page.filter('') + + +class TestImagesAdvancedAngular(helpers.TestCase): + + @property + def images_page(self): + return self.home_pg.go_to_project_compute_imagespage() + + def volumes_page(self): + self.home_pg.go_to_project_volumes_volumespage() + return VolumesPage(self.driver, self.CONFIG) + + def instances_page(self): + self.home_pg.go_to_project_compute_instancespage() + return InstancesPage(self.driver, self.CONFIG) -class TestImagesAdvanced(TestImagesLegacy): """Login as demo user""" def test_create_volume_from_image(self): """This test case checks create volume from image functionality: @@ -282,18 +352,23 @@ class TestImagesAdvanced(TestImagesLegacy): source_image = self.CONFIG.image.images_list[0] target_volume = "created_from_{0}".format(source_image) - volumes_page = images_page.create_volume_from_image( + images_page.create_volume_from_image( source_image, volume_name=target_volume) self.assertTrue( - volumes_page.find_message_and_dismiss(messages.INFO)) + images_page.find_message_and_dismiss(messages.INFO)) self.assertFalse( - volumes_page.find_message_and_dismiss(messages.ERROR)) + images_page.find_message_and_dismiss(messages.ERROR)) + + volumes_page = self.volumes_page() + self.assertTrue(volumes_page.is_volume_present(target_volume)) self.assertTrue(volumes_page.is_volume_status(target_volume, 'Available')) volumes_page.delete_volume(target_volume) volumes_page.find_message_and_dismiss(messages.SUCCESS) volumes_page.find_message_and_dismiss(messages.ERROR) + + volumes_page = self.volumes_page() self.assertTrue(volumes_page.is_volume_deleted(target_volume)) def test_launch_instance_from_image(self): @@ -310,56 +385,22 @@ class TestImagesAdvanced(TestImagesLegacy): images_page = self.images_page source_image = self.CONFIG.image.images_list[0] target_instance = "created_from_{0}".format(source_image) - instances_page = images_page.launch_instance_from_image( - source_image, target_instance) + + images_page.launch_instance_from_image(source_image, target_instance) self.assertTrue( - instances_page.find_message_and_dismiss(messages.SUCCESS)) + images_page.find_message_and_dismiss(messages.INFO)) self.assertFalse( - instances_page.find_message_and_dismiss(messages.ERROR)) + images_page.find_message_and_dismiss(messages.ERROR)) + + instances_page = self.instances_page() self.assertTrue(instances_page.is_instance_active(target_instance)) + instances_page = self.instances_page() actual_image_name = instances_page.get_image_name(target_instance) self.assertEqual(source_image, actual_image_name) instances_page.delete_instance(target_instance) self.assertTrue( - instances_page.find_message_and_dismiss(messages.SUCCESS)) + instances_page.find_message_and_dismiss(messages.INFO)) self.assertFalse( instances_page.find_message_and_dismiss(messages.ERROR)) self.assertTrue(instances_page.is_instance_deleted(target_instance)) - - -class TestImagesAdmin(helpers.AdminTestCase, TestImagesLegacy): - """Login as admin user""" - @property - def images_page(self): - return self.home_pg.go_to_admin_compute_imagespage() - - def test_image_create_delete(self): - super().test_image_create_delete() - - def test_filter_images(self): - """This test checks filtering of images - - Steps: - 1) Login to Horizon dashboard as admin user - 2) Go to Admin -> Compute -> Images - 3) Use filter by Image Name - 4) Check that filtered table has one image only (which name is - equal to filter value) - 5) Check that no other images in the table - 6) Clear filter and set nonexistent image name. Check that 0 rows - are displayed - """ - images_list = self.CONFIG.image.images_list - images_page = self.images_page - - images_page.images_table.filter(images_list[0]) - self.assertTrue(images_page.is_image_present(images_list[0])) - for image in images_list[1:]: - self.assertFalse(images_page.is_image_present(image)) - - nonexistent_image_name = "{0}_test".format(self.IMAGE_NAME) - images_page.images_table.filter(nonexistent_image_name) - self.assertEqual(images_page.images_table.rows, []) - - images_page.images_table.filter('') |