You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/06/23 15:42:24 UTC

svn commit: r1687055 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java

Author: reschke
Date: Tue Jun 23 13:42:23 2015
New Revision: 1687055

URL: http://svn.apache.org/r1687055
Log:
OAK-3025: add test case simulating batched import of nodes

Added:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java   (with props)

Added: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java?rev=1687055&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java Tue Jun 23 13:42:23 2015
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.jcr;
+
+import static org.junit.Assume.assumeTrue;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Emulates behavior similar to an import of many nodes (batched).
+ *
+ * These tests are disabled by default due to their long running time. On the command line
+ * specify {@code -DPackageImportIT=true} to enable them.
+ */
+
+public class PackageImportIT extends AbstractRepositoryTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PackageImportIT.class);
+    private static final boolean ENABLED = Boolean.getBoolean(PackageImportIT.class.getSimpleName());
+
+    public PackageImportIT(NodeStoreFixture fixture) {
+        super(fixture);
+        assumeTrue(ENABLED);
+    }
+
+    private static final String TEST_NODE = "import-test";
+    private static final String TEST_PATH = '/' + TEST_NODE;
+
+    private static int DURATION = Integer.getInteger("import.duration", 10000);
+    private static int BATCHSIZE = Integer.getInteger("import.batchsize", 1024);
+    private static boolean NOTREFERENCEABLE = Boolean.getBoolean("import.notreferenceable");
+
+    private Node testNode;
+
+    @Before
+    public void setup() throws RepositoryException {
+        Session session = getAdminSession();
+        Node root = session.getRootNode();
+        testNode = root.addNode(TEST_NODE);
+        session.save();
+        LOG.info("Starting test for{}. Duration: {}, batch size: {}, referenceable: {}, update.limit: {}.", super.fixture, DURATION,
+                BATCHSIZE, !NOTREFERENCEABLE, Integer.getInteger("update.limit"));
+    }
+
+    @After
+    public void tearDown() throws RepositoryException {
+        Session s = testNode.getSession();
+        s.removeItem(TEST_PATH);
+        s.save();
+    }
+
+    @Test
+    public void testImport() throws RepositoryException {
+        long start = System.currentTimeMillis();
+        long until = start + DURATION;
+        long total = 0;
+
+        while (System.currentTimeMillis() < until) {
+            start = System.currentTimeMillis();
+            String cname = String.format("fld-%x", start);
+
+            Node container = testNode.addNode(cname, JcrConstants.NT_FOLDER);
+            for (int i = 0; i < BATCHSIZE; i++) {
+                Node f = container.addNode("f" + i, JcrConstants.NT_FILE);
+                if (!NOTREFERENCEABLE) {
+                    f.addMixin(JcrConstants.MIX_REFERENCEABLE);
+                }
+                Node c = f.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_UNSTRUCTURED);
+                c.setProperty("foo", "bar");
+            }
+            testNode.getSession().save();
+            long elapsed = System.currentTimeMillis() - start;
+            LOG.info("Saved {} nodes ({}) in {}ms ({})", BATCHSIZE, NOTREFERENCEABLE ? "not referenceable" : "referenceable",
+                    elapsed, super.fixture);
+            total += BATCHSIZE;
+        }
+        LOG.info("A total of {} nodes were saved ({}).", total, super.fixture);
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java
------------------------------------------------------------------------------
    svn:eol-style = native