Skip to content

test(generation): guard that cancelling an ended job leaves the worker alone - #366

Open
kevin9327 wants to merge 1 commit into
lightningpixel:devfrom
kevin9327:test/cancel-ended-job-keeps-worker
Open

kevin9327 wants to merge 1 commit into
lightningpixel:devfrom
kevin9327:test/cancel-ended-job-keeps-worker

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Follow-up to #341, as suggested there. The fix is already on dev (10cdc15); this PR only adds tests, with no production code changes.

Adds CancelEndedJobTests to api/tests/test_workflow_runs_lifecycle.py, using a fake worker with a live _proc:

  • test_cancelling_a_finished_job_leaves_the_active_worker_alone: runs a job to done through _run_generation, checks that its _job_generators binding was released, then cancel_job leaves the worker running and loaded.
  • test_cancelling_a_failed_run_leaves_the_active_worker_alone: same, for a run that ends in error, cancelled through cancel_run.
  • test_cancelling_an_ended_job_leaves_another_jobs_worker_alone: cancelling an ended job does not kill a worker that is now bound to a different running job.
  • test_cancelling_a_running_job_still_stops_the_worker / test_cancelling_a_running_run_still_stops_the_worker: a running job/run bound in _job_generators still has its worker killed.

Verification (python -m unittest discover -s tests in api/, Python 3.13):

  • dev (221e44e): Ran 222 tests, OK (skipped=2)
  • this branch: Ran 227 tests, OK (skipped=2)
  • With cancel_job reverted to look up the active generator (the pre-10cdc15 behaviour): the 3 ended-job tests fail (worker killed). The existing cross-route test also fails. The running-job tests still pass.
  • With the finally: _job_generators.pop(job_id, None) removed: the 3 ended-job tests fail (binding still present after the job ends).

…r alone

Port the CancelEndedJobTests from lightningpixel#341 onto the _job_generators binding
introduced in 10cdc15. Ended jobs/runs are driven through _run_generation
so the test covers the binding being released, then cancelled via
/generate/cancel and /workflow-runs/{id}/cancel; running jobs/runs bound in
_job_generators must still have their worker stopped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant