Fix multinode tempest test failure
Change-Id: Ibb5cbb93d53ff45d66ab4f0c0d4b12e908170d35
This commit is contained in:
@@ -36,6 +36,11 @@ CONF = config.CONF
|
||||
class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
"""Base class for Infrastructure Optimization API tests."""
|
||||
|
||||
# States where the object is waiting for some event to perform a transition
|
||||
IDLE_STATES = ('RECOMMENDED', 'FAILED', 'SUCCEEDED', 'CANCELLED')
|
||||
# States where the object can only be DELETED (end of its life-cycle)
|
||||
FINISHED_STATES = ('FAILED', 'SUCCEEDED', 'CANCELLED', 'SUPERSEDED')
|
||||
|
||||
@classmethod
|
||||
def setup_credentials(cls):
|
||||
cls._check_network_config()
|
||||
@@ -142,6 +147,11 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
|
||||
return audit.get('state') == 'SUCCEEDED'
|
||||
|
||||
@classmethod
|
||||
def has_audit_finished(cls, audit_uuid):
|
||||
_, audit = cls.client.show_audit(audit_uuid)
|
||||
return audit.get('state') in cls.FINISHED_STATES
|
||||
|
||||
# ### ACTION PLANS ### #
|
||||
|
||||
def delete_action_plan(self, action_plan_uuid):
|
||||
|
||||
@@ -148,24 +148,31 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
|
||||
try:
|
||||
self.assertTrue(test.call_until_true(
|
||||
func=functools.partial(
|
||||
self.has_audit_succeeded, audit['uuid']),
|
||||
self.has_audit_finished, audit['uuid']),
|
||||
duration=600,
|
||||
sleep_for=2
|
||||
))
|
||||
except ValueError:
|
||||
self.fail("The audit has failed!")
|
||||
|
||||
_, finished_audit = self.client.show_audit(audit['uuid'])
|
||||
if finished_audit.get('state') in ('FAILED', 'CANCELLED'):
|
||||
self.fail("The audit ended in unexpected state: %s!",
|
||||
finished_audit.get('state'))
|
||||
|
||||
_, action_plans = self.client.list_action_plans(
|
||||
audit_uuid=audit['uuid'])
|
||||
action_plan = action_plans['action_plans'][0]
|
||||
|
||||
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
||||
|
||||
if action_plan['state'] in ('SUPERSEDED', 'SUCCEEDED'):
|
||||
# This means the action plan is superseded so we cannot trigger it,
|
||||
# or it is empty.
|
||||
return
|
||||
|
||||
# Execute the action by changing its state to PENDING
|
||||
_, updated_ap = self.client.update_action_plan(
|
||||
action_plan['uuid'],
|
||||
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
|
||||
)
|
||||
_, updated_ap = self.client.start_action_plan(action_plan['uuid'])
|
||||
|
||||
self.assertTrue(test.call_until_true(
|
||||
func=functools.partial(
|
||||
|
||||
@@ -42,21 +42,26 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
|
||||
_, audit = self.create_audit(audit_template['uuid'])
|
||||
|
||||
self.assertTrue(test.call_until_true(
|
||||
func=functools.partial(self.has_audit_succeeded, audit['uuid']),
|
||||
func=functools.partial(self.has_audit_finished, audit['uuid']),
|
||||
duration=30,
|
||||
sleep_for=.5
|
||||
))
|
||||
|
||||
self.assertTrue(self.has_audit_succeeded(audit['uuid']))
|
||||
|
||||
_, action_plans = self.client.list_action_plans(
|
||||
audit_uuid=audit['uuid'])
|
||||
action_plan = action_plans['action_plans'][0]
|
||||
|
||||
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
||||
|
||||
if action_plan['state'] in ['SUPERSEDED', 'SUCCEEDED']:
|
||||
# This means the action plan is superseded so we cannot trigger it,
|
||||
# or it is empty.
|
||||
return
|
||||
|
||||
# Execute the action by changing its state to PENDING
|
||||
_, updated_ap = self.client.update_action_plan(
|
||||
action_plan['uuid'],
|
||||
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
|
||||
)
|
||||
_, updated_ap = self.client.start_action_plan(action_plan['uuid'])
|
||||
|
||||
self.assertTrue(test.call_until_true(
|
||||
func=functools.partial(
|
||||
|
||||
Reference in New Issue
Block a user