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>
This commit is contained in:
Arnaud M 2024-01-24 00:37:47 +01:00
parent 0b7c4cd0f6
commit 5b088a7ad6
3 changed files with 31 additions and 25 deletions

View File

@ -501,9 +501,6 @@ class PoliciesTest(base.EngineTestCase):
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 +565,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 +582,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 +616,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 +636,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 +688,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 +722,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 +778,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 +815,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 +1465,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 +1489,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 +1523,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 +1557,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 +1663,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 +1702,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 +1715,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():

View File

@ -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
)

View File

@ -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