Fix some race conditions in mistral CI
We recently had two issues in CI, this commit tries to fix them. Closes-Bug: #2051040 Change-Id: I05d850344c653bc858b4565673606531da803342 Signed-off-by: Arnaud M <arnaud.morin@gmail.com> BonneNuitLesPetits Change-Id: Ife23f809674dfaaa83fb752c22d77bcc30aa044e
This commit is contained in:
parent
0e03f2db5e
commit
a3e8f5b043
@ -499,11 +499,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
# Note: We need to reread execution to access related tasks.
|
||||
wf_ex = db_api.get_workflow_execution(wf_ex.id)
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
# If wait_before is 0 start the task immediately without delay.
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.await_workflow_success(wf_ex.id)
|
||||
|
||||
def test_wait_before_policy_from_var_negative_number(self):
|
||||
@ -568,7 +563,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
self.await_task_delayed(task_ex.id, delay=0.5)
|
||||
@ -586,7 +580,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
try:
|
||||
@ -621,7 +614,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
self.await_task_delayed(task_ex.id, delay=0.5)
|
||||
@ -642,7 +634,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
try:
|
||||
@ -695,7 +686,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
self.await_task_delayed(task_ex.id, delay=0.5)
|
||||
@ -730,7 +720,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
try:
|
||||
@ -787,7 +776,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
self.await_task_delayed(task_ex.id, delay=0.5)
|
||||
@ -825,7 +813,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
self.assertDictEqual({}, task_ex.runtime_context)
|
||||
|
||||
try:
|
||||
@ -1476,8 +1463,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.await_task_success(task_ex.id)
|
||||
|
||||
self.await_workflow_success(wf_ex.id)
|
||||
@ -1502,10 +1487,15 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
# NOTE(amorin) we used to test the task state here
|
||||
# but this is not possible because we cannot be sure the task is
|
||||
# actually IDLE, RUNNING or even ERROR (because it's suppose to fail)
|
||||
# It depends on the server load / latency
|
||||
# So now, we will only await for it to be in error
|
||||
# See lp-2051040
|
||||
self.await_task_error(task_ex.id)
|
||||
|
||||
# And workflow
|
||||
self.await_workflow_error(wf_ex.id)
|
||||
|
||||
# Wait until timeout exceeds.
|
||||
@ -1531,8 +1521,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.await_task_error(task_ex.id)
|
||||
|
||||
self.await_workflow_error(wf_ex.id)
|
||||
@ -1567,8 +1555,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = wf_ex.task_executions[0]
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.await_task_success(task_ex.id)
|
||||
|
||||
self.await_workflow_success(wf_ex.id)
|
||||
@ -1675,8 +1661,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = self._assert_single_item(task_execs, name='task1')
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.await_workflow_paused(wf_ex.id)
|
||||
|
||||
self._sleep(1)
|
||||
@ -1716,8 +1700,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = self._assert_single_item(task_execs, name='task1')
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
# Verify wf paused by pause-before
|
||||
self.await_workflow_paused(wf_ex.id)
|
||||
|
||||
@ -1731,8 +1713,6 @@ class PoliciesTest(base.EngineTestCase):
|
||||
|
||||
task_ex = db_api.get_task_execution(task_ex.id)
|
||||
|
||||
self.assertEqual(states.IDLE, task_ex.state)
|
||||
|
||||
self.engine.resume_workflow(wf_ex.id)
|
||||
|
||||
with db_api.transaction():
|
||||
|
@ -905,6 +905,17 @@ class SubworkflowPauseResumeTest(base.EngineTestCase):
|
||||
wf_1_task_1_action_exs[0].id
|
||||
)
|
||||
|
||||
# NOTE(amorin) we need to await the wf to make sure it's actually
|
||||
# running and avoid race condition with IDLE state
|
||||
# See lp-2051040
|
||||
self.await_workflow_state(wf_2_ex_1.id, states.RUNNING)
|
||||
|
||||
with db_api.transaction():
|
||||
# Get again now that it's running
|
||||
wf_2_ex_1 = db_api.get_workflow_execution(
|
||||
wf_1_task_1_action_exs[0].id
|
||||
)
|
||||
|
||||
wf_2_ex_1_task_execs = wf_2_ex_1.task_executions
|
||||
|
||||
wf_2_ex_1_task_1_ex = self._assert_single_item(
|
||||
@ -912,6 +923,12 @@ class SubworkflowPauseResumeTest(base.EngineTestCase):
|
||||
name='task1'
|
||||
)
|
||||
|
||||
# And wait for the task to be RUNNING
|
||||
self.await_task_running(wf_2_ex_1_task_1_ex.id)
|
||||
|
||||
with db_api.transaction():
|
||||
wf_execs = db_api.get_workflow_executions()
|
||||
|
||||
wf_2_ex_1_task_1_action_exs = db_api.get_action_executions(
|
||||
task_execution_id=wf_2_ex_1_task_1_ex.id
|
||||
)
|
||||
|
7
tox.ini
7
tox.ini
@ -38,6 +38,13 @@ allowlist_externals =
|
||||
bash
|
||||
commands = bash run_tests.sh -N --db-type postgresql
|
||||
|
||||
[testenv:unit-sqlite]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
passenv = ZUUL_PROJECT
|
||||
allowlist_externals =
|
||||
bash
|
||||
commands = bash run_tests.sh -N --db-type sqlite
|
||||
|
||||
[testenv:unit-mysql]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
passenv = ZUUL_PROJECT
|
||||
|
Loading…
x
Reference in New Issue
Block a user