This is an automated email from the ASF dual-hosted git repository. thomasm pushed a commit to branch OAK-12122 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit e7f225fcf5c6cae093e074b76693028181b16b9f Author: Thomas Mueller <[email protected]> AuthorDate: Tue Mar 3 15:41:17 2026 +0100 OAK-12122: add fixed seed and improve logging in DataStoreCommandTest - Use Random(42) in prepareData for reproducible test data - Add logFilesInDump when expected file is missing, listing all files with sizes Made-with: Cursor --- .../jackrabbit/oak/run/DataStoreCommandTest.java | 38 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java index 5bdc3fa0b8..366b1e61ca 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java @@ -177,7 +177,7 @@ public class DataStoreCommandTest { Data data = new Data(); List<Integer> toBeDeleted = new ArrayList<>(); - Random rand = new Random(); + Random rand = new Random(42); for (int i = 0; i < numMaxDeletions; i++) { int n = rand.nextInt(numBlobs); if (!toBeDeleted.contains(n)) { @@ -201,7 +201,7 @@ public class DataStoreCommandTest { } for (int i = 0; i < numBlobs; i++) { List<String> valuesList = new ArrayList<String>(map.keySet()); - int randomIndex = new Random().nextInt(valuesList.size()); + int randomIndex = rand.nextInt(valuesList.size()); String pathRoot = valuesList.get(randomIndex); @@ -901,12 +901,44 @@ public class DataStoreCommandTest { private static void assertFileEquals(File dump, String prefix, Set<String> blobsAdded, String dirPrefix) throws IOException { File file = (dirPrefix == null) ? filterFiles(dump, prefix) : filterFiles(dump, dirPrefix, prefix); - Assert.assertNotNull(file); + if (file == null || !file.exists()) { + logFilesInDump(dump, prefix); + } + Assert.assertNotNull("Expected file with prefix " + prefix + " in " + dump.getAbsolutePath(), file); Assert.assertTrue(file.exists()); assertEquals(blobsAdded, FileIOUtils.readStringsAsSet(new FileInputStream(file), true)); } + private static void logFilesInDump(File dump, String prefix) { + StringBuilder sb = new StringBuilder(); + sb.append("Expected file with prefix \"").append(prefix).append("\" not found in ") + .append(dump.getAbsolutePath()).append(". Contents:"); + if (!dump.exists()) { + sb.append(" directory does not exist"); + } else { + appendFilesWithSizes(sb, dump, ""); + } + log.warn(sb.toString()); + } + + private static void appendFilesWithSizes(StringBuilder sb, File dir, String indent) { + File[] files = dir.listFiles(); + if (files == null) { + sb.append(indent).append(" (unreadable)"); + return; + } + for (File f : files) { + if (f.isDirectory()) { + sb.append("\n").append(indent).append(f.getName()).append("/"); + appendFilesWithSizes(sb, f, indent + " "); + } else { + sb.append("\n").append(indent).append(f.getName()) + .append(" (").append(f.length()).append(" bytes)"); + } + } + } + private static void assertFileNull(File dump, String prefix) { File file = filterFiles(dump, prefix); Assert.assertNull(file);
