Changes image creation/deletion in sanity_check to be atomic..
Right now, image creation/deletion is done at the class level in ImageTestCase. Also, in TestSuiteImage relies on self.repair_image to clean up the class-level image through the UI. This has several potential points of failure: - self.repair_image is not called via self.addCleanup: if the test fails before repair_image is called, the image is not restored. - self.repair_image is done via UI: this can obviously fail, because Selenium should never be used to reliably clean up a resource. - self.image.id is used in many different classes that inherit from ImageTestCase: this can result in failures in other test suites. This patch changes self.image to be test-level, created in setUp instead of setUpClass and deleted in tearDown instead of tearDownClass. This is an example of a log that shows multiple tests failing across different test suites because the class-level image (probably) was already deleted and thus not found: https://murano-ci.mirantis.com/logs/25/424525/1/check/gate-murano-dashboard-ubuntu/ca45725/ Change-Id: I0c8628c7fdf182cc512c16faa30f1dd763b8f08e
This commit is contained in:
parent
6b00791ffb
commit
3bf38434fe
|
@ -437,13 +437,15 @@ class ImageTestCase(PackageBase):
|
|||
glance_endpoint = cls.service_catalog.url_for(service_type='image')
|
||||
cls.glance = gclient.Client('1', endpoint=glance_endpoint,
|
||||
session=cls.keystone_client.session)
|
||||
cls.image_title = 'New Image ' + str(time.time())
|
||||
cls.image = cls.upload_image(cls.image_title)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(ImageTestCase, cls).tearDownClass()
|
||||
cls.glance.images.delete(cls.image.id)
|
||||
def setUp(self):
|
||||
super(ImageTestCase, self).setUp()
|
||||
self.image_title = self.gen_random_resource_name('test-image', 15)
|
||||
self.image = self.upload_image(self.image_title)
|
||||
|
||||
def tearDown(self):
|
||||
super(ImageTestCase, self).tearDown()
|
||||
self.glance.images.delete(self.image.id)
|
||||
|
||||
@classmethod
|
||||
def upload_image(cls, title):
|
||||
|
@ -464,16 +466,6 @@ class ImageTestCase(PackageBase):
|
|||
self.driver.find_element_by_xpath(
|
||||
".//*[@value = '{0}']".format(element)).click()
|
||||
|
||||
def repair_image(self):
|
||||
self.driver.find_element_by_id(
|
||||
'marked_images__action_mark_image').click()
|
||||
self.select_from_list('image', self.image.id)
|
||||
self.fill_field(by.By.ID, 'id_title', self.image_title)
|
||||
self.select_from_list('type', 'linux')
|
||||
self.select_and_click_element('Mark Image')
|
||||
self.check_element_on_page(by.By.XPATH,
|
||||
consts.TestImage.format(self.image_title))
|
||||
|
||||
|
||||
class FieldsTestCase(PackageBase):
|
||||
def check_error_message_is_present(self, error_message):
|
||||
|
|
|
@ -791,8 +791,6 @@ class TestSuiteImage(base.ImageTestCase):
|
|||
self.select_and_click_element('Mark Image')
|
||||
self.check_element_on_page(by.By.XPATH, c.TestImage.format(new_title))
|
||||
|
||||
self.repair_image()
|
||||
|
||||
def test_check_image_info(self):
|
||||
"""Test check ability to view image details
|
||||
|
||||
|
@ -823,7 +821,6 @@ class TestSuiteImage(base.ImageTestCase):
|
|||
self.wait_for_alert_message()
|
||||
self.check_element_not_on_page(by.By.XPATH,
|
||||
c.TestImage.format(self.image_title))
|
||||
self.repair_image()
|
||||
|
||||
def test_delete_multiple_images(self):
|
||||
"""Test ability to delete multiple images.
|
||||
|
@ -894,8 +891,6 @@ class TestSuiteImage(base.ImageTestCase):
|
|||
self.check_element_not_on_page(
|
||||
by.By.XPATH, c.TestImage.format(default_image_title))
|
||||
|
||||
self.repair_image() # Restore the class-level image that was deleted.
|
||||
|
||||
|
||||
class TestSuiteFields(base.FieldsTestCase):
|
||||
def test_check_domain_name_field_validation(self):
|
||||
|
|
Loading…
Reference in New Issue