This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 64613eaec3 OAK-12122: add fixed seed and improve logging in
DataStoreCommandTest (#2781)
64613eaec3 is described below
commit 64613eaec33b2bc816f2c4300b76435cdb303c4b
Author: Thomas Mueller <[email protected]>
AuthorDate: Fri Mar 6 08:53:24 2026 +0100
OAK-12122: add fixed seed and improve logging in DataStoreCommandTest
(#2781)
* OAK-12122: add fixed seed and improve logging in DataStoreCommandTest
Made-with: Cursor
* Apply suggestion from @rishabhdaim
Co-authored-by: Rishabh Kumar <[email protected]>
---------
Co-authored-by: Rishabh Kumar <[email protected]>
---
.../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..dc8d082f55 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);
+ }
+
+ 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);