NASA-PDS / pds4-information-model

The software tools and data necessary for generating the Information Model including PDS4 ontology, data, and information model.
https://nasa-pds.github.io/pds4-information-model/
Other
11 stars 7 forks source link

Add current LDDTool tests to existing Cucumber Framework #786

Closed jordanpadams closed 3 weeks ago

jordanpadams commented 4 months ago

💡 Description

Build out test suite with tests from TestRail

⚔️ Parent Epic / Related Tickets

No response

miguelp1986 commented 4 months ago

@jordanpadams I'm getting some errors when running mvn clean test from the root directory, which has worked before. Not sure what changed to make this fail.

>>  FATAL ERROR Configuration file does not exist. [config.properties]
>>  FATAL ERROR Required data file was not found: /Users/MPena/repositories/pds4-information-model/model-lddtool/model-ontology/src/ontology/Data/UpperModel.pont

It is incorrectly looking for /model-ontology/src/ontology/Data/UpperModel.pont within the model-lddtool directory instead of the root directory.

My latest code is on https://github.com/NASA-PDS/pds4-information-model/tree/i786

jordanpadams commented 4 months ago

@miguelp1986 hmmmm. I'm not sure what is going on here. The main branch still works with mvn clean test, so not sure why the changes you proposed break. You may need to change an environment variable for the tests to run? the LDDTool code relies on -Ddata.home=${PARENT_DIR}/Data to find that directory, so you may need to set that somewhere in your code. https://github.com/NASA-PDS/pds4-information-model/blob/main/model-lddtool/src/main/resources/bin/lddtool#L67C15-L67C45

miguelp1986 commented 4 months ago

@jordanpadams that was exactly the issue thank you.

miguelp1986 commented 4 months ago

@jordanpadams I'm seeing a StackOverflowError when running 2 tests with Cucumber which, when ran individually, do not cause a StackOverflowError. Looks like its running out of stack space.

java.lang.RuntimeException: DMDocument error
    at cucumber.StepDefs.run_lddtool(StepDefs.java:53)
    at ✽.lddtool is run(classpath:features/integration.feature:8)
Caused by: java.lang.StackOverflowError
    at gov.nasa.pds.model.plugin.LDDDOMParser.checkAllSubclasses(LDDDOMParser.java:2184)
    at gov.nasa.pds.model.plugin.LDDDOMParser.checkAllSubclasses(LDDDOMParser.java:2193)
    at gov.nasa.pds.model.plugin.LDDDOMParser.checkAllSubclasses(LDDDOMParser.java:2193)

I'm seeing at least 100 lines of this. Looking at the function LDDDOMParser.checkAllSubclasses(), that function is recursively being called in a loop if (lDOMProp.hasDOMObject != null && lDOMProp.hasDOMObject instanceof DOMClass).

I could use some help figuring out how to clean up resources after running each test in Cucumber here. I'm thinking that might prevent the StackOverflowError.

tloubrieu-jpl commented 4 months ago

@miguelp1986 is going to increase the memory in the JVM for the cucumber test to work but otherwise the framework is now setup and works.

Next step is to add the tests for each of the requirements, but there are 34 for the full Information Model repository. Miguel will extract the one specifically associated with the LDD-tools, starting with the high and critical.

@miguelp1986 is going to make a PR with 1 or 2 tests as soon as the JVM memory issue is fixed.

miguelp1986 commented 4 months ago

@jordanpadams @tloubrieu-jpl We should still try to clean up memory after each test case. We're going to be adding lots of tests, so I'm not sure just upping the memory allocated to the JVM will be enough. This is what's being done for Validate's Cucumber tests. Problem is, I don't know what to grab in order to clear up memory for lddtool.

jordanpadams commented 4 months ago

@miguelp1986 I'm sure there is a memory leak or some data objects that are not being appropriately "cleansed" somewhere in the code in order to optimize some of the memory.

jordanpadams commented 4 months ago

@miguelp1986 here are some possibilities: https://github.com/NASA-PDS/pds4-information-model/security/code-scanning?query=is%3Aopen+branch%3Amain+%22resource+leak%22

@al-niessner has some JVM profiling tools that he has used for tracking resources to see if any of these fixes actually help at all.

miguelp1986 commented 4 months ago

@jordanpadams maxing out the JVM memory is not fixing the issue. I tried clearing out some resources but that didn't work either. I will take a look at the resource leak reports to see if that will help.

jordanpadams commented 4 months ago

@miguelp1986 based upon the stub of the error log appears to be an infinite loop?

jordanpadams commented 4 months ago

@miguelp1986 I am not going to have some time to debug this for a bit. If you are blocked, I would just recommend moving onto other tasks you may have.

miguelp1986 commented 4 months ago

@miguelp1986 based upon the stub of the error log appears to be an infinite loop?

@jordanpadams Yes it looks that way. Strange that it only occurs when running more than one test.

jordanpadams commented 4 months ago

@miguelp1986 the guess off the top of my head is there is some singleton being used in the code, which needs a reset. I will try to take a look sometime this weekend or next

jshughes commented 3 months ago

@jordanpadams @miguelp1986 I am not exactly sure what you are looking for, but as for singletons, you might want to check the following since they involved large blocks of data.

DMDocument static MasterDOMInfoModel masterDOMInfoModel; static LDDDOMParser primaryLDDDOMModel; static ArrayList LDDDOMModelArr;

Also, now that a couple refactoring tasks are complete, feel free to suggest something to focus on for the next task. Does reducing the number of static variables make sense?

jordanpadams commented 2 months ago

Partially completed via https://github.com/NASA-PDS/pds4-information-model/pull/800, but we will need to retroactively go back and add all previous tests.

jordanpadams commented 3 weeks ago

Calling this done for now per https://github.com/NASA-PDS/pds4-information-model/pull/817