Skip to content

Commit

Permalink
fixed a bug in db module that was probably responsible for messing up…
Browse files Browse the repository at this point in the history
… logs
  • Loading branch information
apdavison committed Nov 10, 2023
1 parent 0b56743 commit 5d155d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/simqueue/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async def update_log(job_id, log):
ins = logs.insert().values(job_id=job_id, content=log)
await database.execute(ins)
else:
ins = logs.update().where(jobs.c.id == job_id).values(content=log)
ins = logs.update().where(logs.c.job_id == job_id).values(content=log)
await database.execute(ins)

return
Expand Down
20 changes: 20 additions & 0 deletions api/simqueue/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ async def test_job_lifetime(database_connection, adequate_quota, mocker, provide
"""

mocker.patch("simqueue.data_repositories.download_file_to_tmp_dir", fake_download)
# first we check the job queue is empty
# if an error in a previous test run has left a submitted job, it may not be
# in that case, we set all submitted jobs to "error"
async with AsyncClient(app=app, base_url="http://test") as client:
response0 = await client.get(
f"/jobs/?status=submitted&hardware_platform={TEST_PLATFORM}", headers=provider_auth
)
assert response0.status_code == 200
queued_jobs = response0.json()
if len(queued_jobs) > 0:
for leftover_job in queued_jobs:
response00 = await client.put(
leftover_job["resource_uri"],
json={
"status": "error",
"log": "Job was left over from previous test failure.",
},
headers=provider_auth,
)
assert response00.status_code == 200

# user submits a job
initial_job_data = {
Expand Down

0 comments on commit 5d155d5

Please sign in to comment.