ERDDAP build and unit testing changes #115
Replies: 4 comments 16 replies
-
I fully agree that making the tests easy for contributors to run is critical to supporting multiple developers and that the current test set up is too complicated for many of the tests. Generally I prefer pull requests focused on changing one thing at a time in order to keep them smaller. To that end, I’d prefer updates to the tests first to be more easily runnable (this probably includes the change from filesystem to classpath lookup). After the tests are executing successfully, I’d be in support of other changes. One thing to keep in mind is that the current TestAll file is a critical part of building the distributed war file. We should also clarify what changes to the tests you would be making. Does this include using JUnit? Will test code be moved out of class files into the test/java directory? Will tests that talk to a local server be changed to use the new servlet? Will tests that talk to an external ERDDAP be updated to use the servlet? Will tests that talk to external servers (like THREDDS) be updated to use mock data? Given how ERDDAP is currently reliant on filesystem lookup and the TestAll file, I want to do manual verification the war file built after these changes has no user visible differences (except being smaller if all of the test code/data is no longer included). Lastly, I believe folks at Axiom had similar thoughts to your proposal. I’d like to have them chime in on this proposal as well. I think they may have had a slightly different folder structure as their desired end result. |
Beta Was this translation helpful? Give feedback.
-
In the end, I leave decisions about this to Chris. I know my preferences are different than the younger generation of developers. But my questions and comments are:
|
Beta Was this translation helpful? Give feedback.
-
First, I wholeheartedly agree that moving to a (more) standard directory structure and build methodology will lower the barrier of entry for new developers, make the ERDDAP codebase more robust and portable, increase confidence that changes to the code or dependencies behave as expected, etc. I hear the concerns about the potential negative impacts of overly aggressive refactoring, but I think much of what is being discussed here can be accomplished without drastic changes to the existing ERDDAP code. I put together a demonstration PR to show how Axiom has handled adding unit tests to the upstream ERDDAP while making as few changes as possible. To be clear, I am not necessarily advocating for the approach shown here to be adopted or to be the end goal. A standard Maven directory structure and surgical changes to the ERDDAP code to increase flexibility/remove assumptions as Clifford outlined above is surely the most correct and least surprising approach. Given that he's already got this working against 2.18 I think some step-wise PRs against In the meantime, here's an PR how we've approached adding tests, which also shows an approach to separate unit tests requiring (potentially failing/slow/etc) remote resources in to a separate execution profile using jUnit categories. The overall approach is that we stage the build assets into a In the pom there are long lists of resources to include for both If nothing else this shows the hoops that have to be jumped through/pain points to add portable tests and build methodology with the existing layout. |
Beta Was this translation helpful? Give feedback.
-
Based on the comments here, I’m onboard with going ahead and getting pull requests from @clifford-harms to start making the proposed changes. It sounds like the changes will be smaller than I was initially expecting and will help move towards a better developer onboarding experience. |
Beta Was this translation helpful? Give feedback.
-
I wanted to kick off a discussion about implementing some changes to Erddap to see what you guys think before I do the work and fire off some pull requests.
What I would like to do:
Why
My organization would like to begin contributing to Erddap, and it looks like there are others interested as well. The ability to easily execute unit tests, either in suite or individually, is essential to maintaining a quality baseline with multiple contributors. Tests that are difficult to execute or require extensive setup don't get executed often.
Proposed Changes
Move to a maven standard structure for a java web application, as below:
The
lib
directory would be for installation of problematic jars (i.e. netcdfALL) that cannot be reliably retained from remote repositories. All non-java source files would be moved to an identical package structure insrc/main/resources
.The next step (a separate merge request) would be to make Erddap instantiable in unit tests, so that in addition to basic unit tests, tests can be created against a n actual running erddap servlet. This would involve:
EDStatic.java
static initialization into a staticEDStatic.init()
method. This method can be invoked to initialize erddap when desired, instead of it happening at class definition. So you could initialize Erddap in a unit test, or a web context listener.Small subsets of test data can be version controlled in
test/resources
(compressed) in support of unit tests. Inclusions to this test dataset do have to be made carefully to prevent size from becoming an issue.The end result is an ERDDAP that builds easily, can be extensively unit tested, with no changes to how organizations deploy/use ERDDAP.
I have done all of this successfully against ERDDAP v2.18 for my organization, and would be happy to port it to your main HEAD, but I wanted to make sure there was no immediate opposition to these types of changes prior to doing the work to create a merge request.
Beta Was this translation helpful? Give feedback.
All reactions