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

Consider adding test that loads memo file from previous release #4237

Open
melissalinkert opened this issue Sep 11, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@melissalinkert
Copy link
Member

#4234 highlights that there can be cases where memo file loading breaks in a way that our current tests do not catch. Catching these issues by eye in code review is possible, but very easy to overlook.

One approach would be to store memo files generated from the previous released version in https://github.com/openmicroscopy/data_repo_config. Then we could add a test similar to https://github.com/ome/bioformats/blob/develop/components/test-suite/src/loci/tests/testng/FormatReaderTest.java#L2943 that reads the stored memo file.

@melissalinkert melissalinkert added the enhancement New feature or request label Sep 11, 2024
@sbesson
Copy link
Member

sbesson commented Sep 13, 2024

A good starting point for this might be the logic in

String cacheDir = configTree.getCacheDirectory();
if (cacheDir != null) {
LOGGER.debug("Loading memo from populated cache");
File dir = new File(cacheDir);
if (!dir.exists() || !dir.isDirectory() || !dir.canRead()) {
result(testName, false, "Cached memo directory does not exist");
}
File currentFile = new File(reader.getCurrentFile());
String relativeName = "." + currentFile.getName() + ".bfmemo";
File expectedMemo = new File(cacheDir, currentFile.getParent());
expectedMemo = new File(expectedMemo, relativeName);
if (expectedMemo.exists()) {
memo = new Memoizer(0, dir);
// do not allow an existing memo file to be overwritten
memo.skipSave(true);
memo.setId(reader.getCurrentFile());
if (!memo.isLoadedFromMemo()) {
result(testName, false, "Existing memo file could not be loaded");
}
memo.openBytes(0, 0, 0, 1, 1);
memo.close();
}
else {
LOGGER.warn("Missing memo file {}; passing test anyway", expectedMemo);
}
}
.

This feature was been introduced in #3159 to identify whether the included changes are backwards-incompatible with memo files created by the previous release of Bio-Formats and decide whether the next release should increment the patch or minor version.
Functionality was also introduced to create cache files for all configured datasets included in the nightly repository tests. The location of this cache directory could be passed to the Ant target via -Dtestng.cacheDirectory.

Something that might need to be reviewed if we are looking into reusing the existing logic is that testMemoFileUsage would currently fail if there are any backwards-incompatible serialization changes that invalidate the previous memo file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants