Skip to content
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

Merged
merged 27 commits into from
Jul 25, 2024
Merged

Mongodb DAO Update #112

merged 27 commits into from
Jul 25, 2024

Conversation

PatrickFuhrmann-HTWBerlin
Copy link
Contributor

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:

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.

The goal is to have the mongodb driver to something > 6.0.
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.
if necessary.
Adding an example on how to start the docker container.
Copy link
Collaborator

@minottic minottic left a 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

package.json Outdated Show resolved Hide resolved
gulpfile.js Outdated Show resolved Hide resolved
gulpfile.js Show resolved Hide resolved
src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
ENVIRONMENT_README.md Outdated Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
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.
@PatrickFuhrmann-HTWBerlin
Copy link
Contributor Author

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.

  • I got the test to succeed in my repository but don't know if it works in the scicat one.
  • I took the deploy.yml from BE as suggested but removed the ESS pipeline for now.

Copy link

@bpedersen2 bpedersen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

.github/workflows/deploy.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
DB_USER | Database Username | none
DB_PASS | Database Password | none
DB_URL | [<user>:<password>@]<host>:<port>/<dbName>| none
DATABASE | Publication Database | dacat-next

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will do later.

package.json Outdated Show resolved Hide resolved
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

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@minottic minottic left a 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

src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
src/providers/scicat-provider/dao/mongo-dao.ts Outdated Show resolved Hide resolved
@PatrickFuhrmann-HTWBerlin
Copy link
Contributor Author

I had to fix two more problems:

  • c16411c: On githup (not on my mac M1 and not on my ARM reference) the node:18-alpine produced errors. This doesn't happen with the node:18-slim.
  • 0c81791: Using the stricter and more typesafe Filter<> over Filter syntax to satisfy the gulp ts compiler.

Copy link
Collaborator

@minottic minottic left a 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:
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Dockerfile Show resolved Hide resolved
test/routes.ts Outdated Show resolved Hide resolved
test/fixtures/returns/panosc.returns.ts Outdated Show resolved Hide resolved
@minottic
Copy link
Collaborator

I think the push to ghcr is failing because it's happening from a fork

with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: true
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think we can:

  • eac0a72 : made the push dependent on push to master.
  • 372bfc7: forgot to change the trigger back to master.

Copy link
Collaborator

@minottic minottic Jul 25, 2024

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' }}

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@minottic minottic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx!

@minottic minottic merged commit a42f7a0 into SciCatProject:master Jul 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants