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

Add logical metadata file validation, fixes #98 #101

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

djjuhasz
Copy link
Contributor

  • Add the logical metadata file to the expected SIP structure for AIP type SIPs
  • Validate the logical metadata file against the PREMIS v3 XSD
  • Move the logical metadata file to the "metadata/" directory when transforming the SIP for delivery to preservation

Refs #98

Add the logical metadata file to the expected SIP structure for the AIP
SIP types. Update activities related to SIP structure: identify SIP,
validate files, validate structure, and verify manifest.
@djjuhasz djjuhasz changed the title Add logical metadata file SIP validation, fixes #98 Add logical metadata file validation, fixes #98 Dec 17, 2024
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 77.88462% with 23 lines in your changes missing coverage. Please review.

Project coverage is 61.86%. Comparing base (b0ec45d) to head (3d770f1).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/activities/validate_premis.go 73.91% 8 Missing and 4 partials ⚠️
cmd/worker/workercmd/cmd.go 0.00% 4 Missing ⚠️
internal/workflow/preprocessing.go 81.81% 3 Missing and 1 partial ⚠️
internal/activities/transform_sip.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
+ Coverage   61.22%   61.86%   +0.64%     
==========================================
  Files          32       35       +3     
  Lines        2174     2347     +173     
==========================================
+ Hits         1331     1452     +121     
- Misses        742      780      +38     
- Partials      101      115      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djjuhasz djjuhasz force-pushed the dev/issue-98-verify-logical-md-file-exists branch 2 times, most recently from 2b01003 to 9e9f87c Compare December 17, 2024 18:32
@djjuhasz djjuhasz requested a review from mcantelon December 17, 2024 18:35
@djjuhasz djjuhasz self-assigned this Dec 17, 2024
@djjuhasz djjuhasz linked an issue Dec 17, 2024 that may be closed by this pull request
Copy link
Contributor

@mcantelon mcantelon left a comment

Choose a reason for hiding this comment

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

This seems great! I had one question (for my own curiosity), but see any issues... the embedding of the PREMIS XSD is slick.

},
{
name: "Returns a file not found failure",
validator: newFakeValidator().WithErr(errors.New("file not found")),
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the pros and cons of having a mock object return a file not found error versus testing with a non-existent file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcantelon I think the main pro of using a mock validator is that the tests are not dependent on xmllint being installed in the test environment. Unfortunately I negated that advantage by using the real "xmllint" validator in the first test, and sure enough that test failed in CI until I added xmllint to the CI runner. 🤔 The mock validator is also faster (though I'm sure the difference isn't noticeable in these small test cases), and allows more control over the return values.

I think the main con of using a mock validator is if there is some integration issue between the ValidatePREMIS activity and xmlvalidate.XMLLintValidator then it won't be caught by these unit tests. Ideally integration issues would be caught by integration tests, but we don't have any integration tests for this project. :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Good points! Yeah, integration tests definitely seem like they'd be handy (but also potentially a lot of work to create/maintain at this stage).

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've decided to remove the xmllint dependency in the first test here. The deciding factor for me is that the tests should not fail if a developer runs them locally without xmllint installed.

internal/activities/validate_premis_test.go Show resolved Hide resolved
internal/activities/validate_structure.go Show resolved Hide resolved
internal/premis/xsdv3.go Show resolved Hide resolved
internal/sip/sip.go Show resolved Hide resolved
Refs #98.

Add an activity to validate the logical metadata PREMIS XML file against
a local copy of the PREMIS v3 XSD. To avoid downloading the PREMIS XSD
every time the activity runs I've embedded a local copy of the XSD in
the worker Go binary, and write the contents to a file on disk so it can
be loaded by xmllint.
Refs #98.

Move the logical metadata file to the metadata directory when
transforming the SIP.
@djjuhasz djjuhasz force-pushed the dev/issue-98-verify-logical-md-file-exists branch from 978519f to 3d770f1 Compare December 18, 2024 19:55
@djjuhasz djjuhasz merged commit 32fdee0 into main Dec 18, 2024
9 checks passed
@djjuhasz djjuhasz deleted the dev/issue-98-verify-logical-md-file-exists branch December 18, 2024 20:00
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.

Problem: migration packages will now contain a logical metadata file
2 participants