-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17390 from davelopez/cancel_deleted_user_jobs
Cancel all active jobs when the user is deleted
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,18 @@ | |
from galaxy_test.base.api_asserts import assert_object_id_error | ||
from galaxy_test.base.decorators import ( | ||
requires_admin, | ||
requires_new_history, | ||
requires_new_user, | ||
) | ||
from galaxy_test.base.populators import skip_without_tool | ||
from galaxy_test.base.populators import ( | ||
DatasetPopulator, | ||
skip_without_tool, | ||
) | ||
|
||
TEST_USER_EMAIL = "[email protected]" | ||
TEST_USER_EMAIL_INDEX_DELETED = "[email protected]" | ||
TEST_USER_EMAIL_DELETE = "[email protected]" | ||
TEST_USER_EMAIL_DELETE_CANCEL_JOBS = "[email protected]" | ||
TEST_USER_EMAIL_PURGE = "[email protected]" | ||
TEST_USER_EMAIL_UNDELETE = "[email protected]" | ||
TEST_USER_EMAIL_SHOW = "[email protected]" | ||
|
@@ -129,6 +134,45 @@ def test_undelete_user(self): | |
undeleted_user = self._get(f"users/{user['id']}", admin=True).json() | ||
assert undeleted_user["deleted"] is False, undeleted_user | ||
|
||
@requires_admin | ||
@requires_new_user | ||
@requires_new_history | ||
@skip_without_tool("cat_data_and_sleep") | ||
def test_delete_user_cancel_all_jobs(self): | ||
dataset_populator = DatasetPopulator(self.galaxy_interactor) | ||
with self._different_user(TEST_USER_EMAIL_DELETE_CANCEL_JOBS): | ||
user_id = self._get_current_user_id() | ||
history_id = dataset_populator.new_history() | ||
hda_id = dataset_populator.new_dataset(history_id)["id"] | ||
|
||
inputs = { | ||
"input1": {"src": "hda", "id": hda_id}, | ||
"sleep_time": 6000, | ||
} | ||
run_response = dataset_populator.run_tool_raw( | ||
"cat_data_and_sleep", | ||
inputs, | ||
history_id, | ||
) | ||
self._assert_status_code_is_ok(run_response) | ||
|
||
job_id = run_response.json()["jobs"][0]["id"] | ||
|
||
# Wait a bit for the job to be ready | ||
expected_job_states = ["new", "queued", "running"] | ||
dataset_populator.wait_for_job(job_id, ok_states=expected_job_states) | ||
|
||
# Get the job state | ||
job_response = self._get(f"jobs/{job_id}").json() | ||
assert job_response["state"] in expected_job_states, job_response | ||
|
||
# Delete user will cancel all jobs | ||
self._delete(f"users/{user_id}", admin=True) | ||
|
||
# Get the job state again (this time as admin), it should be deleting | ||
job_response = self._get(f"jobs/{job_id}", admin=True).json() | ||
assert job_response["state"] == "deleting", job_response | ||
|
||
@requires_new_user | ||
def test_information(self): | ||
user = self._setup_user(TEST_USER_EMAIL) | ||
|