On 26/04/2023 10.16, Emanuele Giuseppe Esposito wrote:
Pause the job while draining so that pause_count will be
increased and bdrv_drain_all_end() won't reset it to 0, so the
job will not continue.

With this fix, the test is not flaky anymore.

Additionally remove useless aiocontext lock around bdrv_drain_all_end()
in test_complete_in_standby().

Fixes: b6903cbe3a2 "tests/unit/test-blockjob: Disable
complete_in_standby test"
Suggested-by: Hanna Czenczek <hre...@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eespo...@redhat.com>
---
  tests/unit/test-blockjob.c | 17 +++++++----------
  1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c
index a130f6fefb..46d720aeee 100644
--- a/tests/unit/test-blockjob.c
+++ b/tests/unit/test-blockjob.c
@@ -488,11 +488,15 @@ static void test_complete_in_standby(void)
      bdrv_drain_all_begin();
      assert_job_status_is(job, JOB_STATUS_STANDBY);
+ /*
+     * Increase pause_count so that the counter is
+     * unbalanced and job won't resume
+     */
+    job_pause(job);
+
      /* Lock the IO thread to prevent the job from being run */

I guess the above comment should now be removed, too?

-    aio_context_acquire(ctx);
      /* This will schedule the job to resume it */
      bdrv_drain_all_end();
-    aio_context_release(ctx);

 Thomas


Reply via email to