Fix explicit waiting if instance has error status
This patches includes: - don't wait instance launching if instance in error status - add missed assertTrue to validate notification messages - check that message is present and is displayed Change-Id: If731751fa4deabdeebe373748b169ac7ac617f8c Closes-Bug: #1569941
This commit is contained in:
parent
755d07cbdf
commit
65eb9e9b8c
@ -95,10 +95,10 @@ class BaseWebObject(unittest.TestCase):
|
||||
"""
|
||||
if not timeout:
|
||||
timeout = self.explicit_wait
|
||||
wait.WebDriverWait(self.driver, timeout, poll_frequency).until(
|
||||
return wait.WebDriverWait(self.driver, timeout, poll_frequency).until(
|
||||
predicate)
|
||||
|
||||
def _wait_till_text_present_in_element(self, element, text, timeout=None):
|
||||
def _wait_till_text_present_in_element(self, element, texts, timeout=None):
|
||||
"""Waiting for a text to appear in a certain element very often is
|
||||
actually waiting for a _different_ element with a different text to
|
||||
appear in place of an old element. So a way to avoid capturing stale
|
||||
@ -108,11 +108,17 @@ class BaseWebObject(unittest.TestCase):
|
||||
to avoid problems with cell being replaced with totally different
|
||||
element by Javascript
|
||||
"""
|
||||
if not isinstance(texts, (list, tuple)):
|
||||
texts = (texts,)
|
||||
|
||||
def predicate(_):
|
||||
elt = element() if hasattr(element, '__call__') else element
|
||||
return self._is_text_visible(elt, text)
|
||||
for text in texts:
|
||||
if self._is_text_visible(elt, text):
|
||||
return text
|
||||
return False
|
||||
|
||||
self._wait_until(predicate, timeout)
|
||||
return self._wait_until(predicate, timeout)
|
||||
|
||||
def _wait_till_element_visible(self, element, timeout=None):
|
||||
self._wait_until(lambda x: self._is_element_displayed(element),
|
||||
|
@ -55,9 +55,10 @@ class BasePage(pageobject.PageObject):
|
||||
|
||||
def find_message_and_dismiss(self, message_level=messages.SUCCESS):
|
||||
message = messages.MessageRegion(self.driver, self.conf, message_level)
|
||||
if message.exists():
|
||||
is_message_present = message.exists()
|
||||
if is_message_present:
|
||||
message.close()
|
||||
return message.exists()
|
||||
return is_message_present
|
||||
|
||||
def change_project(self, name):
|
||||
self.topbar.user_dropdown_project.click_on_project(name)
|
||||
|
@ -157,8 +157,8 @@ class ImagesPage(basepage.BaseNavigationPage):
|
||||
|
||||
def is_image_active(self, name):
|
||||
row = self._get_row_with_image_name(name)
|
||||
return self.images_table.is_cell_status(
|
||||
lambda: row.cells[IMAGES_TABLE_STATUS_COLUMN], 'Active')
|
||||
return bool(self.images_table.wait_cell_status(
|
||||
lambda: row.cells[IMAGES_TABLE_STATUS_COLUMN], 'Active'))
|
||||
|
||||
def wait_until_image_active(self, name):
|
||||
self._wait_until(lambda x: self.is_image_active(name))
|
||||
|
@ -118,7 +118,10 @@ class InstancesPage(basepage.BaseNavigationPage):
|
||||
def cell_getter():
|
||||
row = self._get_row_with_instance_name(name)
|
||||
return row and row.cells[self.INSTANCES_TABLE_STATUS_COLUMN]
|
||||
return self.instances_table.is_cell_status(cell_getter, 'Active')
|
||||
|
||||
status = self.instances_table.wait_cell_status(cell_getter,
|
||||
('Active', 'Error'))
|
||||
return status == 'Active'
|
||||
|
||||
def _get_source_name(self, instance, boot_source,
|
||||
conf):
|
||||
|
@ -100,8 +100,8 @@ class VolumesnapshotsPage(basepage.BaseNavigationPage):
|
||||
|
||||
def is_volume_snapshot_available(self, name):
|
||||
row = self._get_row_with_volume_snapshot_name(name)
|
||||
return self.volumesnapshots_table.is_cell_status(
|
||||
lambda: row.cells[self.SNAPSHOT_TABLE_STATUS_COLUMN], 'Available')
|
||||
return bool(self.volumesnapshots_table.wait_cell_status(
|
||||
lambda: row.cells[self.SNAPSHOT_TABLE_STATUS_COLUMN], 'Available'))
|
||||
|
||||
def get_volume_name(self, snapshot_name):
|
||||
row = self._get_row_with_volume_snapshot_name(snapshot_name)
|
||||
|
@ -144,8 +144,8 @@ class VolumesPage(basepage.BaseNavigationPage):
|
||||
|
||||
def is_volume_status(self, name, status):
|
||||
row = self._get_row_with_volume_name(name)
|
||||
return self.volumes_table.is_cell_status(
|
||||
lambda: row.cells[self.VOLUMES_TABLE_STATUS_COLUMN], status)
|
||||
return bool(self.volumes_table.wait_cell_status(
|
||||
lambda: row.cells[self.VOLUMES_TABLE_STATUS_COLUMN], status))
|
||||
|
||||
def is_volume_deleted(self, name):
|
||||
return self.volumes_table.is_row_deleted(
|
||||
|
@ -107,5 +107,5 @@ class NetworksPage(basepage.BaseNavigationPage):
|
||||
|
||||
def is_network_active(self, name):
|
||||
row = self._get_row_with_network_name(name)
|
||||
return self.networks_table.is_cell_status(
|
||||
lambda: row.cells[self.NETWORKS_TABLE_STATUS_COLUMN], 'Active')
|
||||
return bool(self.networks_table.wait_cell_status(
|
||||
lambda: row.cells[self.NETWORKS_TABLE_STATUS_COLUMN], 'Active'))
|
||||
|
@ -39,7 +39,7 @@ class MessageRegion(baseregion.BaseRegion):
|
||||
self._turn_on_implicit_wait()
|
||||
|
||||
def exists(self):
|
||||
return bool(self.src_elem)
|
||||
return self._is_element_displayed(self.src_elem)
|
||||
|
||||
def close(self):
|
||||
self._get_element(*self._close_locator).click()
|
||||
|
@ -158,12 +158,14 @@ class TableRegion(baseregion.BaseRegion):
|
||||
return True
|
||||
return True
|
||||
|
||||
def is_cell_status(self, cell_getter, status):
|
||||
def wait_cell_status(self, cell_getter, statuses):
|
||||
if not isinstance(statuses, (list, tuple)):
|
||||
statuses = (statuses,)
|
||||
try:
|
||||
self._wait_till_text_present_in_element(cell_getter, status)
|
||||
return self._wait_till_text_present_in_element(cell_getter,
|
||||
statuses)
|
||||
except exceptions.TimeoutException:
|
||||
return False
|
||||
return True
|
||||
|
||||
def is_next_link_available(self):
|
||||
try:
|
||||
|
@ -74,12 +74,14 @@ class TestInstances(helpers.TestCase):
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize(items_per_page)
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
|
||||
instances_page = self.home_pg.go_to_compute_instancespage()
|
||||
instances_page.create_instance(self.INSTANCE_NAME,
|
||||
instance_count=instance_count)
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_active(instance_list[1]))
|
||||
|
||||
instances_page = self.instances_page
|
||||
@ -96,12 +98,14 @@ class TestInstances(helpers.TestCase):
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize()
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
|
||||
instances_page = self.instances_page
|
||||
for instance_name in instance_list:
|
||||
instances_page.delete_instance(instance_name)
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_deleted(instance_name))
|
||||
|
||||
def test_instances_pagination_and_filtration(self):
|
||||
@ -139,12 +143,14 @@ class TestInstances(helpers.TestCase):
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize(items_per_page)
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
|
||||
instances_page = self.home_pg.go_to_compute_instancespage()
|
||||
instances_page.create_instance(self.INSTANCE_NAME,
|
||||
instance_count=instance_count)
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_active(instance_list[1]))
|
||||
|
||||
instances_page = self.instances_page
|
||||
@ -164,12 +170,14 @@ class TestInstances(helpers.TestCase):
|
||||
|
||||
settings_page = self.home_pg.go_to_settings_usersettingspage()
|
||||
settings_page.change_pagesize()
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
settings_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
|
||||
instances_page = self.instances_page
|
||||
for instance_name in instance_list:
|
||||
instances_page.delete_instance(instance_name)
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_deleted(instance_name))
|
||||
|
||||
def test_filter_instances(self):
|
||||
@ -194,6 +202,8 @@ class TestInstances(helpers.TestCase):
|
||||
instances_page = self.home_pg.go_to_compute_instancespage()
|
||||
instances_page.create_instance(self.INSTANCE_NAME,
|
||||
instance_count=instance_count)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_active(instance_list[0]))
|
||||
|
||||
instances_page = self.instances_page
|
||||
@ -215,7 +225,8 @@ class TestInstances(helpers.TestCase):
|
||||
|
||||
for instance in instance_list:
|
||||
instances_page.delete_instance(instance)
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS)
|
||||
self.assertTrue(
|
||||
instances_page.find_message_and_dismiss(messages.SUCCESS))
|
||||
self.assertTrue(instances_page.is_instance_deleted(instance))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user