NOAA-OWP / wres

Code and scripts for the Water Resources Evaluation Service
Other
2 stars 1 forks source link

As a developer, I want all unit tests that read/write files from/to the host file system to be replaced with files in an in-memory file system #253

Open epag opened 3 weeks ago

epag commented 3 weeks ago

Author Name: James (James) Original Redmine Issue: 89047, https://vlab.noaa.gov/redmine/issues/89047 Original Date: 2021-03-08


Given a unit test that reads or writes to a file When I implement that unit test Then it should read or write to a file in an in-memory file system

( In order to ensure, among other things, that the test is fully encapsulated within the unit test code. )


Redmine related issue(s): 96033, 111117


epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2021-03-08T11:47:44Z


A reading example is @MetricProcessorByTimeEnsemblePairsTest.java@, which reads from @wres-metrics/testinput@. A writing example is @CommaSeparatedScoreWriterTest.java@, which writes to @java.io.tmp@ on the host.

Not a high priority, but these examples should be replaced or removed as refactoring becomes necessary or deprecation completes.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T15:39:32Z


There are very few of these left now. A couple left in @wres-io@, a couple in @wres-metrics@ and one in @wres-util@, but that's about it. The ones in @wres-io@ are easy enough to remove, but the others are harder.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T16:41:21Z


Going to remove some of the easier ones that remain.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T17:22:10Z


Hmmm, the wrds threshold reading is a bit brittle and doesn't play nicely with an in-memory file system. Seeing whether I can fix it. There's quite a lot of legacy calls to @java.io@ rather than @java.nio@, which seems to be the issue with file-like sources.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T17:29:47Z


Seems fixable, fixing it.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T17:37:06Z


Fixed. Managed to remove @wres-io/testinput@, which is nice.

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T17:47:08Z


Checking the system tests in case any of those touch wrds threshold reading and will then push. There are no other simple cases to address - the remaining instances will require different test data sources, mostly (which is no bad thing because the datasets under @wres-metrics/testinput@ are too big anyway).

epag commented 3 weeks ago

Original Redmine Comment Author Name: James (James) Original Date: 2022-12-28T17:59:58Z


Progress in commit:wres|91de61fb295c99aac6299a668792e51b7074ce9d.

Remaining items will take longer.