-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongodb DAO Update #112
Mongodb DAO Update #112
Conversation
The goal is to have the mongodb driver to something > 6.0.
deprication warnings.
Most important for us is adding the 'COLLECTION_ID=' because sometimes the test data doesn't have the 'doi' as a key and we change it to the '_id' value, which is always available in mongodb. In general we don't understand where the .env is really used in production. When using docker, docker-compose or kubernetes, we would specify all environment variable specifically anyway. Like in '-e' or the environment tag in docker compose.
- Using then/catch with mongdb.connect. - Using the Promise returned by library calls instead of creating our own Promise. - It seems that MongoClient.filter is no longer used in the 6.0 mongodb library. So we change to 'any'. Is of course less type save.
for the 'pino' package.
if necessary. Adding an example on how to start the docker container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a part from minor changes, it looks good, thanks!
I see there are some npm upgrades, but the node version is still fairly old. I guess, once this is merged, we could open another PR doing the node upgrade in the dockerfile
But most important: the tests fail, so they need to be fixed. In principle, it would be good to have tests for the mongo functions, but it's quite some work I guess
a) Using tsx instead of tsc. Didn't get the mocha to work with tsc. b) Fixing the the expected return from the oai-pmh API calles. - Lower case to the proper answer - Removing date structures before the comparison. c) Reading the dotenv part first before loading the test. Mostly to get the proper LOG_LEVEL value. d) The PUT of the 'test' record into the DB is not defined by the V2 oai-pmh protocol and the return of the insertOne mongodb call changed. That is reflected in the fixtures ... record-doi.ts file.
If fixed the Tests. The way the tests are done are a bit fragile. The response to the API calls are not checked against XML spec of XMl namespace but are a char to char comparison.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
DB_USER | Database Username | none | ||
DB_PASS | Database Password | none | ||
DB_URL | [<user>:<password>@]<host>:<port>/<dbName>| none | ||
DATABASE | Publication Database | dacat-next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to new scicat namings in a follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok will do later.
it('should wait awhile before continuing', function(done) { | ||
this.timeout(61000); // Optional: set timeout for this test to 61 seconds | ||
setTimeout(function() { | ||
// Your test logic here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently a no-op test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But it creates a 10 second delay which might not be very elegant. But I had to make sure that the oai-pmh-service part had a chance to connect to the mongodb server. Otherwise all tests fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. 2 minor comments, in addition to Bjorn's.
Just a side note. In principle this PR should include tests for the modified functions (as they aren't there already). The existing tests don't really test the mongo functionality as they mock their behaviour. I am fine mergining without, anyway these changes are mostly using mongo native functionalities that we assume have been tested by mongo
… errors during the githup workflow
…ding error message during compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some more comments, but it's almost ready I think.
I am unsure I understand why the tests changes were needed
@@ -1,6 +1,10 @@ | |||
name: CI | |||
|
|||
on: [pull_request] | |||
on: | |||
push: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this ca be on PR only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I wanted to make sure that the test/deploy works on your side.
I think the push to ghcr is failing because it's happening from a fork |
.github/workflows/deploy.yml
Outdated
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64/v8 | ||
push: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we set this to true only on push to master? in this way, we avoid the permission error when coming from a fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be enough to evaluate the true false condition in the push field.
push: ${{ github.event_name. == 'push' }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I misunderstood. I fixed with 077150a. Seems to work for 'push' on my branch and 'pr' on the scicat master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np! thanks for the changes! I would be fine merging now, do you plan any other change or is it good to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not planning any other changes in this PR so we are good to go from my side. Thanks a lot for your help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx!
Main Objective:
The goal of this pull request is to prepare for adding new formats to the OAI PMH provider in addition to Panosc, dc and openaire. As a first step we would like to get the mongodb DAO and the entire package updated to the most recent version.
The pull request consists of various commits with the corresponding explanation.
Some additional remarks:
We are running:
npm --version : 10.5.1
node --version: v22.0.0
A) on 'npm install':
When doing a npm install, you will find WARNINGS on 'inflight' and 'glob'. They are hard to fix because they are loaded from gulp. But they are not so important as they are only used for the installation while using gulp. The actual services is not using them.
B) I didn't touch the CI/ESS part. I don't know why they have the private directory.
C) We only updated 'production/.env' to add the key 'COLLECTION_ID'. This is only important when not using the COLLECTION_ID='doi'. As a general remark: When running docker, docker-compose or kubernetes, you will overwrite those values anyway, so the content is not that important.
D) We are working on the workflow part now, as Carlo wants us to push a docker image to ghcr.io from within a .githup/workflow.
E) Works for us
F) I checked the functionality by building the docker container by the Dockerfile and running it within scicat-live. The following REST calls produce the correct output:
http://localhost:3000/
http://localhost:3000/scicat/oai?verb=Identify
http://localhost:3000/scicat/oai?verb=ListMetadataFormats
http://localhost:3000/scicat/oai?verb=GetRecord&identifier=1&metadataPrefix=oai_dc
http://localhost:3000/scicat/oai?verb=ListIdentifiers&metadataPrefix=oai_dc
http://localhost:3000/scicat/oai?verb=ListRecords&metadataPrefix=oai_dc
The same is true for the '/panosc/oai' and '/openaire/oai' URL. I must admit, I didn't try to 'PUT' a record, because records are added through the backend-next/frontend system and PUT is not mentioned in the README.md.
We are happy to improve the pull request. We might not be 100% compliant with your coding rules.
-p.