Skip to content

Commit 7de010a

Browse files
authored
Merge pull request #495 from ryuwd/patch-3
fix (JobParametersDB): Ensure index names are lowercase in case the VO has capital letters
2 parents b72c103 + 78b3c88 commit 7de010a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

diracx-db/src/diracx/db/os/job_parameters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class JobParametersDB(BaseOSDB):
2525

2626
def index_name(self, vo, doc_id: int) -> str:
2727
split = int(int(doc_id) // 1e6)
28-
return f"{self.index_prefix}_{vo}_{split}m"
28+
# The index name must be lowercase or opensearchpy will throw.
29+
return f"{self.index_prefix}_{vo.lower()}_{split}m"
2930

3031
def upsert(self, vo, doc_id, document):
3132
document = {

diracx-db/tests/opensearch/test_search.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ async def prefilled_db(request):
105105
impl = request.param
106106
async with resolve_fixtures_hack(request, impl) as dummy_opensearch_db:
107107
await dummy_opensearch_db.upsert("dummyvo", 798811211, DOC1)
108-
await dummy_opensearch_db.upsert("dummyvo", 998811211, DOC2)
108+
# the following line tests if the index name is made properly lowercase in case
109+
# the VO has capital letters e.g. "diracAdmin"
110+
await dummy_opensearch_db.upsert("dummyVO", 998811211, DOC2)
109111
await dummy_opensearch_db.upsert("dummyvo", 798811212, DOC3)
110112

111113
# Force a refresh to make sure the documents are available

0 commit comments

Comments
 (0)