Fix failing after refactoring CLI test for execution
After refactoring tests need to wait a little bit more time before execution will be in 'SUCCESS' state, that's why it was needed to add extra method that will check execution state and wait for 'Success'. Change-Id: I4c85d227c171d4b819dd288a00c7fb32258f11ba Closes-Bug: #1435263
This commit is contained in:
@@ -13,6 +13,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
from tempest_lib import exceptions
|
||||||
|
|
||||||
from mistralclient.tests.functional.cli import base
|
from mistralclient.tests.functional.cli import base
|
||||||
|
|
||||||
@@ -161,3 +164,29 @@ class MistralClientTestBase(base.MistralCLIAuth, base.MistralCLIAltAuth):
|
|||||||
f.write(file_body)
|
f.write(file_body)
|
||||||
f.close()
|
f.close()
|
||||||
self.addCleanup(os.remove, file_name)
|
self.addCleanup(os.remove, file_name)
|
||||||
|
|
||||||
|
def wait_execution_success(self, exec_id, timeout=180):
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
ex = self.mistral_admin('execution-get', params=exec_id)
|
||||||
|
exec_state = self.get_value_of_field(ex, 'State')
|
||||||
|
|
||||||
|
expected_states = ['SUCCESS', 'RUNNING']
|
||||||
|
|
||||||
|
while exec_state != 'SUCCESS':
|
||||||
|
if time.time() - start_time > timeout:
|
||||||
|
msg = ("Execution exceeds timeout {0} to change state "
|
||||||
|
"to SUCCESS. Execution: {1}".format(timeout, ex))
|
||||||
|
raise exceptions.TimeoutException(msg)
|
||||||
|
|
||||||
|
ex = self.mistral_admin('execution-get', params=exec_id)
|
||||||
|
exec_state = self.get_value_of_field(ex, 'State')
|
||||||
|
|
||||||
|
if exec_state not in expected_states:
|
||||||
|
msg = ("Execution state %s is not in expected "
|
||||||
|
"states: %s" % (exec_state, expected_states))
|
||||||
|
raise exceptions.TempestException(msg)
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
return True
|
||||||
|
@@ -301,10 +301,8 @@ class ExecutionCLITests(base_v2.MistralClientTestBase):
|
|||||||
"%s input task_name" % self.reverse_wf['Name'])
|
"%s input task_name" % self.reverse_wf['Name'])
|
||||||
exec_id = self.get_value_of_field(execution, 'ID')
|
exec_id = self.get_value_of_field(execution, 'ID')
|
||||||
|
|
||||||
execution = self.mistral_admin(
|
result = self.wait_execution_success(exec_id)
|
||||||
'execution-get', params=exec_id)
|
self.assertTrue(result)
|
||||||
exec_state = self.get_value_of_field(execution, 'State')
|
|
||||||
self.assertEqual('SUCCESS', exec_state)
|
|
||||||
|
|
||||||
def test_execution_update(self):
|
def test_execution_update(self):
|
||||||
execution = self.execution_create(self.direct_wf['Name'])
|
execution = self.execution_create(self.direct_wf['Name'])
|
||||||
|
Reference in New Issue
Block a user