Skip to content

Commit

Permalink
fixup! Issue 28 Finetune parallelized /jobs requests
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Oct 5, 2023
1 parent 7e8d172 commit 9bfd638
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def get_user_jobs(self, user_id: str) -> Union[List[BatchJobMetadata], dict]:
except Exception as e:
_log.error(f"get_user_jobs: skipping job with parse issue: {e!r}", exc_info=True)
for backend_id, exc in results.failures.items():
_log.warning(f"Failed to get job listing from backend {backend_id!r}: {result!r}")
_log.warning(f"Failed to get job listing from backend {backend_id!r}: {exc!r}")
federation_missing.add(backend_id)

if self.partitioned_job_tracker:
Expand Down
31 changes: 31 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,37 @@ def test_list_jobs_basic(self, api100, requests_mock, backend1, backend2):
"links": [],
}

def test_list_jobs_auth(self, api100, requests_mock, backend1, backend2):
def b1_get_jobs(request, context):
assert request.headers["Authorization"] == TEST_USER_AUTH_HEADER["Authorization"]
return {
"jobs": [
{"id": "job03", "status": "running", "created": "2021-06-03T12:34:56Z"},
{"id": "job08", "status": "running", "created": "2021-06-08T12:34:56Z", "title": "Job number 8."},
]
}

def b2_get_jobs(request, context):
assert request.headers["Authorization"] == TEST_USER_AUTH_HEADER["Authorization"]
return {
"jobs": [
{"id": "job05", "status": "running", "created": "2021-06-05T12:34:56Z"},
]
}

requests_mock.get(backend1 + "/jobs", json=b1_get_jobs)
requests_mock.get(backend2 + "/jobs", json=b2_get_jobs)
api100.set_auth_bearer_token(token=TEST_USER_BEARER_TOKEN)
res = api100.get("/jobs").assert_status_code(200).json
assert res == {
"jobs": [
{"id": "b1-job03", "status": "running", "created": "2021-06-03T12:34:56Z"},
{"id": "b1-job08", "status": "running", "created": "2021-06-08T12:34:56Z", "title": "Job number 8."},
{"id": "b2-job05", "status": "running", "created": "2021-06-05T12:34:56Z"},
],
"links": [],
}

@pytest.mark.parametrize("b2_oidc_pid", ["egi", "aho"])
def test_list_jobs_oidc_pid_mapping(self, config, requests_mock, backend1, backend2, b2_oidc_pid):
# Override /credentials/oidc of backend2 before building flask app and ApiTester
Expand Down

0 comments on commit 9bfd638

Please sign in to comment.