-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
2 deletions.
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
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
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
81 changes: 81 additions & 0 deletions
81
extensions/gubbins/gubbins-routers/tests/test_gubbins_job_manager.py
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import pytest | ||
from diracx.core.models import JobStatus | ||
from fastapi.testclient import TestClient | ||
|
||
pytestmark = pytest.mark.enabled_dependencies( | ||
[ | ||
"AuthSettings", | ||
# CAUTION !!! | ||
# You need to put both the original AND your extended one | ||
"JobDB", | ||
"GubbinsJobDB", | ||
# | ||
"JobLoggingDB", | ||
"WMSAccessPolicy", | ||
"ConfigSource", | ||
"TaskQueueDB", | ||
] | ||
) | ||
|
||
|
||
TEST_JDL = """ | ||
Arguments = "jobDescription.xml -o LogLevel=INFO"; | ||
Executable = "dirac-jobexec"; | ||
JobGroup = jobGroup; | ||
JobName = jobName; | ||
JobType = User; | ||
LogLevel = INFO; | ||
OutputSandbox = | ||
{ | ||
Script1_CodeOutput.log, | ||
std.err, | ||
std.out | ||
}; | ||
Priority = 1; | ||
Site = ANY; | ||
StdError = std.err; | ||
StdOutput = std.out; | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def normal_user_client(client_factory): | ||
with client_factory.normal_user() as client: | ||
yield client | ||
|
||
|
||
@pytest.fixture | ||
def valid_job_id(normal_user_client: TestClient): | ||
""" | ||
Copied from the vanila tests | ||
This ensures that the submission route works | ||
""" | ||
job_definitions = [TEST_JDL] | ||
r = normal_user_client.post("/api/jobs/", json=job_definitions) | ||
assert r.status_code == 200, r.json() | ||
assert len(r.json()) == 1 | ||
return r.json()[0]["JobID"] | ||
|
||
|
||
def test_gubbins_job_router(normal_user_client, valid_job_id): | ||
""" | ||
Basically like diracx test_delete_job_valid_job_id | ||
except that the job does not go into DELETED status, | ||
as the method is intercepted by the DB | ||
""" | ||
|
||
# We search for the job | ||
r = normal_user_client.get(f"/api/jobs/{valid_job_id}/status") | ||
assert r.status_code == 200, r.json() | ||
assert r.json()[str(valid_job_id)]["Status"] == JobStatus.RECEIVED | ||
|
||
# We delete the job, and here we expect that nothing | ||
# actually happened | ||
r = normal_user_client.delete(f"/api/jobs/{valid_job_id}") | ||
assert r.status_code == 200, r.json() | ||
|
||
r = normal_user_client.get(f"/api/jobs/{valid_job_id}/status") | ||
assert r.status_code == 200, r.json() | ||
# The job would normally be deleted | ||
assert r.json()[str(valid_job_id)]["Status"] == JobStatus.RECEIVED |