This is an automated email from the ASF dual-hosted git repository.

reschke 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 ed1274c878 OAK-10641: DocumentStore: improve test coverage for large 
properties / documents (#1299)
ed1274c878 is described below

commit ed1274c87866eaa7b7ef67bee5027150871fc09c
Author: Julian Reschke <[email protected]>
AuthorDate: Thu Feb 8 15:32:19 2024 +0100

    OAK-10641: DocumentStore: improve test coverage for large properties / 
documents (#1299)
---
 .../plugins/document/BasicDocumentStoreTest.java   | 77 +++++++++++++++++++++-
 1 file changed, 75 insertions(+), 2 deletions(-)

diff --git 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
index 933e456b10..7bb094936e 100644
--- 
a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
+++ 
b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
@@ -495,7 +495,7 @@ public class BasicDocumentStoreTest extends 
AbstractDocumentStoreTest {
     @Test
     public void testMaxProperty() {
         int min = 0;
-        int max = 1024 * 1024 * 8;
+        int max = 1024 * 1024 * 32;
         int test = 0;
         int last = 0;
 
@@ -522,7 +522,80 @@ public class BasicDocumentStoreTest extends 
AbstractDocumentStoreTest {
             }
         }
 
-        LOG.info("max prop length for " + super.dsname + " was " + last);
+        LOG.info("max prop length (create) for " + super.dsname + " was " + 
last);
+    }
+
+    @Test
+    public void testMaxUpdateProperty() {
+        int min = 0;
+        int max = 1024 * 1024 * 32;
+        int test = 0;
+        int last = 0;
+
+        while (max - min >= 256) {
+            if (test == 0) {
+                test = max; // try largest first
+            } else {
+                test = (max + min) / 2;
+            }
+            String id = this.getClass().getName() + ".testMaxUpdateProperty-" 
+ test;
+            UpdateOp up = new UpdateOp(id, true);
+            super.ds.create(Collection.NODES, Collections.singletonList(up));
+
+            String pval = generateString(test, true);
+            up.set("foo", pval);
+            try {
+                NodeDocument doc = super.ds.findAndUpdate(Collection.NODES, 
up);
+                if (doc != null) {
+                    // check that we really can read it
+                    NodeDocument findme = super.ds.find(Collection.NODES, id, 
0);
+                    assertNotNull("failed to retrieve previously stored 
document", findme);
+                    super.ds.remove(Collection.NODES, id);
+                    min = test;
+                    last = test;
+                } else {
+                    max = test;
+                }
+            }
+            catch (DocumentStoreException ex) {
+                LOG.debug("trying prop length (update) for " + super.dsname, 
ex);
+                max = test;
+                super.ds.remove(Collection.NODES, id);
+            }
+        }
+
+        LOG.info("max prop length (update) for " + super.dsname + " was " + 
last);
+    }
+
+    @Test
+    public void testMaxAddProperty() {
+
+        String id = this.getClass().getName() + ".testMaxAddProperty";
+        UpdateOp up = new UpdateOp(id, true);
+        super.ds.create(Collection.NODES, Collections.singletonList(up));
+        String exception = null;
+
+        int i = 0;
+        for (i = 0; i < 32 && exception == null; i++) {
+            String pval = generateString(1024 * 1024, true);
+            String pname = String.format("foo%02d", i);
+            up.set(pname, pval);
+            try {
+                NodeDocument doc = super.ds.findAndUpdate(Collection.NODES, 
up);
+                if (doc != null) {
+                    // check that we really can read it
+                    NodeDocument findme = super.ds.find(Collection.NODES, id, 
0);
+                    assertNotNull("failed to retrieve previously stored 
document", findme);
+                    assertNotNull(findme.get(pname));
+                }
+            } catch (Throwable ex) {
+                LOG.error("trying to add " + i + "th 1MB property " + 
super.dsname + ": " + ex.getMessage(), ex);
+                exception = ex.getMessage();
+            }
+        }
+
+        super.ds.remove(Collection.NODES, id);
+        LOG.info("max number of 1MB property additions for " + super.dsname + 
" was " + i + " (" + exception + ")");
     }
 
     @Test

Reply via email to