@@ -449,7 +449,7 @@ def test_cancel_task_group(pulpcore_bindings, dispatch_task_group, gen_user):
449449
450450
451451@pytest .mark .parallel
452- def test_immediate_task_without_resource_locking (pulpcore_bindings , dispatch_task , monitor_task ):
452+ def test_immediate_task_doesnt_require_resource (pulpcore_bindings , dispatch_task , monitor_task ):
453453 """
454454 GIVEN a task with no resource requirements
455455
@@ -495,7 +495,7 @@ def test_immediate_task_without_resource_locking(pulpcore_bindings, dispatch_tas
495495
496496
497497@pytest .mark .parallel
498- def test_immediate_task_with_resources_locking (pulpcore_bindings , dispatch_task , monitor_task ):
498+ def test_immediate_task_requires_resource (pulpcore_bindings , dispatch_task , monitor_task ):
499499 """
500500 GIVEN an async task requiring busy resources
501501
@@ -508,15 +508,17 @@ def test_immediate_task_with_resources_locking(pulpcore_bindings, dispatch_task,
508508 THEN an error is raised
509509
510510 3
511- WHEN dispatching as immediate
512511 AND it takes longer than timeout
513512 THEN an error is raised
514513 """
515514 LT_TIMEOUT = IMMEDIATE_TIMEOUT / 2
516515 GT_TIMEOUT = IMMEDIATE_TIMEOUT + 1
516+ LONG_RUNNING = 3
517517
518518 # Case 1
519- dispatch_task ("pulpcore.app.tasks.test.sleep" , args = (3 ,), exclusive_resources = ["XYZ" ])
519+ dispatch_task (
520+ "pulpcore.app.tasks.test.sleep" , args = (LONG_RUNNING ,), exclusive_resources = ["XYZ" ]
521+ )
520522 task_href = dispatch_task (
521523 "pulpcore.app.tasks.test.asleep" ,
522524 args = (LT_TIMEOUT ,),
@@ -528,7 +530,9 @@ def test_immediate_task_with_resources_locking(pulpcore_bindings, dispatch_task,
528530 assert task .worker is not None
529531
530532 # Case 2
531- dispatch_task ("pulpcore.app.tasks.test.sleep" , args = (LT_TIMEOUT ,), exclusive_resources = ["XYZ" ])
533+ dispatch_task (
534+ "pulpcore.app.tasks.test.sleep" , args = (LONG_RUNNING ,), exclusive_resources = ["XYZ" ]
535+ )
532536 with pytest .raises (PulpTaskError ):
533537 task_href = dispatch_task (
534538 "pulpcore.app.tasks.test.asleep" ,
@@ -540,9 +544,15 @@ def test_immediate_task_with_resources_locking(pulpcore_bindings, dispatch_task,
540544 monitor_task (task_href )
541545
542546 # Case 3
547+ dispatch_task (
548+ "pulpcore.app.tasks.test.sleep" , args = (LONG_RUNNING ,), exclusive_resources = ["XYZ" ]
549+ )
543550 with pytest .raises (PulpTaskError ) as ctx :
544551 task_href = dispatch_task (
545- "pulpcore.app.tasks.test.asleep" , args = (GT_TIMEOUT ,), immediate = True
552+ "pulpcore.app.tasks.test.asleep" ,
553+ args = (GT_TIMEOUT ,),
554+ immediate = True ,
555+ exclusive_resources = ["XYZ" ],
546556 )
547557 monitor_task (task_href )
548558 assert "task timed out after" in ctx .value .task .error ["description" ]
0 commit comments