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 support to utilize both online and local schema/schematron files #632

Merged
merged 16 commits into from
May 3, 2023

Conversation

al-niessner
Copy link
Contributor

@al-niessner al-niessner commented Apr 19, 2023

🗒️ Summary

There was a simple bug preventing the code from doing what is desired. Fixed the bug, then added 4 tests:

  1. should work as is
  2. provide -x to override with local copy of schema that will generate a single error
  3. provide -S to override with local copy of schematron that will generate a single error
  4. provide both -x and -S to generate one error because the XSD error prevents the schematron.

⚙️ Test Data and/or Report

No Overrides Success

$ validate -S src/test/resources/github599/PDS4_PDS_1I00.sch -t src/test/resources/github599/AREA_Camelot_1radii.xml

PDS Validate Tool Report

Configuration:
   Version                       3.3.0-SNAPSHOT
   Date                          2023-04-24T19:00:22Z

Parameters:
   Targets                       [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]
   Severity Level                WARNING
   Recurse Directories           true
   File Filters Used             [*.xml, *.XML]
   Data Content Validation       on
   Product Level Validation      on
   Max Errors                    100000
   Registered Contexts File      /home/niessner/Projects/PDS/validate/src/main/resources/util/registered_context_products.json



Product Level Validation Results

  PASS: file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml
      WARNING  [warning.label.schematron]   line 48, 35: The value Spacecraft for attribute Observing_System_Component.type is deprecated and should not be used.
        1 product validation(s) completed
Apr 24, 2023 12:00:27 PM gov.nasa.pds.tools.validate.task.ValidationTask execute
INFO: Validation complete for location 'file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml'

Summary:

  0 error(s)
  1 warning(s)

  Product Validation Summary:
    1          product(s) passed
    0          product(s) failed
    0          product(s) skipped

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped

  Message Types:
    1            warning.label.schematron

End of Report

Override Schema Failure:

$ validate -x src/test/resources/github599/PDS4_PDS_1I00.xsd -t src/test/resources/github599/AREA_Camelot_1radii.xml

PDS Validate Tool Report

Configuration:
   Version                       3.3.0-SNAPSHOT
   Date                          2023-04-24T18:47:48Z

Parameters:
   Targets                       [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]
   User Specified Schemas        [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/PDS4_PDS_1I00.xsd]
   Severity Level                WARNING
   Recurse Directories           true
   File Filters Used             [*.xml, *.XML]
   Data Content Validation       on
   Product Level Validation      on
   Max Errors                    100000
   Registered Contexts File      /home/niessner/Projects/PDS/validate/src/main/resources/util/registered_context_products.json



Product Level Validation Results

  FAIL: file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml
      ERROR  [error.label.schema]   line 12, 25: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://pds.nasa.gov/pds4/pds/v1":logical_identifier}'. One of '{"http://pds.nasa.gov/pds4/pds/v1":logical_id}' is expected.
        1 product validation(s) completed
Apr 24, 2023 11:47:50 AM gov.nasa.pds.tools.validate.task.ValidationTask execute
INFO: Validation complete for location 'file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml'

Summary:

  1 error(s)
  0 warning(s)

  Product Validation Summary:
    0          product(s) passed
    1          product(s) failed
    0          product(s) skipped

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped

  Message Types:
    1            error.label.schema

End of Report

Override Schematron Failure

$ validate -S src/test/resources/github599/PDS4_PDS_1I00.sch  -t src/test/resources/github599/AREA_Camelot_1radii.xml

PDS Validate Tool Report

Configuration:
   Version                       3.3.0-SNAPSHOT
   Date                          2023-04-24T18:54:19Z

Parameters:
   Targets                       [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]
   User Specified Schematrons    [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/PDS4_PDS_1I00.sch]
   Severity Level                WARNING
   Recurse Directories           true
   File Filters Used             [*.xml, *.XML]
   Data Content Validation       on
   Product Level Validation      on
   Max Errors                    100000
   Registered Contexts File      /home/niessner/Projects/PDS/validate/src/main/resources/util/registered_context_products.json



Product Level Validation Results

  FAIL: file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml
      WARNING  [warning.label.schematron]   line 48, 35: The value Spacecraft for attribute Observing_System_Component.type is deprecated and should not be used.
      ERROR  [error.label.schematron]   line 50, 15: The attribute pds:Observing_System_Component/pds:type must be equal to one of the following values 'Airborne', 'Aircraft', 'Artificial Illumination', 'Balloon', 'Computer', 'Facility', 'Host', 'Instrument', 'Laboratory', 'Literature Search', 'Naked Eye', 'Observatory', 'Spacecraft', 'Suborbital Rocket', 'Telescope'.
        1 product validation(s) completed
Apr 24, 2023 11:54:23 AM gov.nasa.pds.tools.validate.task.ValidationTask execute
INFO: Validation complete for location 'file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml'

Summary:

  1 error(s)
  1 warning(s)

  Product Validation Summary:
    0          product(s) passed
    1          product(s) failed
    0          product(s) skipped

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped

  Message Types:
    1            error.label.schematron
    1            warning.label.schematron

End of Report

Override Schema+Schematron Failure

$ validate -S src/test/resources/github599/PDS4_PDS_1I00.sch -x src/test/resources/github599/PDS4_PDS_1I00.xsd -t src/test/resources/github599/AREA_Camelot_1radii.xml

PDS Validate Tool Report

Configuration:
   Version                       3.3.0-SNAPSHOT
   Date                          2023-04-24T18:55:51Z

Parameters:
   Targets                       [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]
   User Specified Schemas        [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/PDS4_PDS_1I00.xsd]
   User Specified Schematrons    [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/PDS4_PDS_1I00.sch]
   Severity Level                WARNING
   Recurse Directories           true
   File Filters Used             [*.xml, *.XML]
   Data Content Validation       on
   Product Level Validation      on
   Max Errors                    100000
   Registered Contexts File      /home/niessner/Projects/PDS/validate/src/main/resources/util/registered_context_products.json



Product Level Validation Results

  FAIL: file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml
      ERROR  [error.label.schema]   line 12, 25: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://pds.nasa.gov/pds4/pds/v1":logical_identifier}'. One of '{"http://pds.nasa.gov/pds4/pds/v1":logical_id}' is expected.
      WARNING  [warning.label.schematron]   line 48, 35: The value Spacecraft for attribute Observing_System_Component.type is deprecated and should not be used.
      ERROR  [error.label.schematron]   line 50, 15: The attribute pds:Observing_System_Component/pds:type must be equal to one of the following values 'Airborne', 'Aircraft', 'Artificial Illumination', 'Balloon', 'Computer', 'Facility', 'Host', 'Instrument', 'Laboratory', 'Literature Search', 'Naked Eye', 'Observatory', 'Spacecraft', 'Suborbital Rocket', 'Telescope'.
        1 product validation(s) completed
Apr 24, 2023 11:55:53 AM gov.nasa.pds.tools.validate.task.ValidationTask execute
INFO: Validation complete for location 'file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml'

Summary:

  2 error(s)
  1 warning(s)

  Product Validation Summary:
    0          product(s) passed
    1          product(s) failed
    0          product(s) skipped

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped

  Message Types:
    1            error.label.schematron
    1            error.label.schema
    1            warning.label.schematron

End of Report

♻️ Related Issues

Closes #599

Copy link
Member

@nutjob4life nutjob4life left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@nutjob4life nutjob4life left a comment

Choose a reason for hiding this comment

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

Approved … again! 👍

@nutjob4life
Copy link
Member

Maybe this PR should be marked as a draft? There have been a lot of commits since my first two approvals 🤷

@al-niessner al-niessner marked this pull request as draft April 19, 2023 21:09
@al-niessner
Copy link
Contributor Author

@nutjob4life Sorry but the cucumber file is giving me lots of grief for reasons my eye is having a very hard detecting. I probably should write a script to check that the features file is going to be interpreted well enough.

@nutjob4life
Copy link
Member

@al-niessner no worries, no rush!

@al-niessner
Copy link
Contributor Author

@jordanpadams @nutjob4life @tloubrieu-jpl

Who is the expert on cucumber and the validate tests that run in Jenkins? I am getting a different result from the command line and Jenkins.

On mine:

Parameters:
   Targets                       [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]
   User Specified Schemas        [file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/PDS4_PDS_1I00.xsd]
><...snip...><
  FAIL: file:/home/niessner/Projects/PDS/validate/src/test/resources/github599/AREA_Camelot_1radii.xml
      ERROR  [error.label.schema]   line 12, 25: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://pds.nasa.gov/pds4/pds/v1":logical_identifier}'. One of '{"http://pds.nasa.gov/pds4/pds/v1":logical_id}' is expected.

but on Jenkins

[file:/home/runner/work/validate/validate/src/test/resources/github599/AREA_Camelot_1radii.xml]","userSpecifiedSchemas":"[file:/home/runner/work/validate/validate/src/test/resources/github599/PDS4_PDS_1I00.xsd]","severityLevel":"WARNING","recurseDirectories":"true","fileFiltersUsed":"[*.xml, *.XML]","dataContentValidation":"on","productLevelValidation":"on","maxErrors":"100000","registeredContextsFile":"/home/runner/work/validate/validate/src/main/resources/util/registered_context_products.json"},"productLevelValidationResults":[{"status":"PASS","label":"file:/home/runner/work/validate/validate/src/test/resources/github599/AREA_Camelot_1radii.xml","messages":[{"severity":"WARNING","type":"warning.label.schematron","line":48,"column":35,"message":"The value Spacecraft for attribute Observing_System_Component.type is deprecated and should not be used."}],"fragments":[],"dataContents":[]}],"summary":{"totalProducts":1,"totalErrors":0,"totalWarnings":1,"messageTypes":[{"messageType":"warning.label.schematron","total":1}]}} ==> expected: <0> but was: <1>

It seems that -x is overriding downloading but not whatever is happening on Jenkins runs. Who is the expert to help sort this out -- I am going to take a wild stab and say it is testing defined a schema dir in core.properties and it is not being overridden?

Do we want to ignore this (not add the unit tests and just trust me) or pursue to its grizzly end? Moving to another ticket until then...

@jordanpadams
Copy link
Member

@al-niessner we have experienced this weirdness on occasion with the ordering of the tests in cucumber. for whatever reason cucumber does not flush the java cache between tests (even if we try to force it), so it is using previous test information and throwing errors. maybe play around with the ordering of tests in the features file? maybe move it to the very bottom?

@al-niessner
Copy link
Contributor Author

al-niessner commented Apr 19, 2023 via email

@al-niessner al-niessner marked this pull request as ready for review April 24, 2023 19:01
@jordanpadams jordanpadams changed the title Issue 599: override schema/schematron via -x and -S respectively Add support to utilize both online and local schema/schematron files May 3, 2023
@jordanpadams jordanpadams merged commit 0fecc57 into main May 3, 2023
@jordanpadams jordanpadams deleted the issue_599 branch May 3, 2023 02:11
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.

As a user, I want to be able to use both online and local schema/schematron files.
3 participants