jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1534706 - in /jackrabbit/oak/trunk/oak-run/src/main: java/org/apache/jackrabbit/oak/benchmark/ resources/ resources/org/apache/jackrabbit/oak/fixture/
Date Tue, 22 Oct 2013 17:18:31 GMT
Author: angela
Date: Tue Oct 22 17:18:31 2013
New Revision: 1534706

URL: http://svn.apache.org/r1534706
Log:
OAK-527: benchmark tests

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
    jackrabbit/oak/trunk/oak-run/src/main/resources/deepTree_everyone.xml
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
    jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1534706&r1=1534705&r2=1534706&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Tue Oct 22 17:18:31 2013
@@ -141,6 +141,11 @@ public class BenchmarkRunner {
                     itemsToRead.value(options),
                     bgReaders.value(options),
                     report.value(options)),
+            new ManyUserReadTest(
+                    runAsAdmin.value(options),
+                    itemsToRead.value(options),
+                    bgReaders.value(options),
+                    report.value(options)),
             ReadManyTest.linear("LinearReadEmpty", 1, ReadManyTest.EMPTY),
             ReadManyTest.linear("LinearReadFiles", 1, ReadManyTest.FILES),
             ReadManyTest.linear("LinearReadNodes", 1, ReadManyTest.NODES),

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java?rev=1534706&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ManyUserReadTest.java
Tue Oct 22 17:18:31 2013
@@ -0,0 +1,109 @@
+/*
+ * 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.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.security.Privilege;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
+
+/**
+ * UserTest... TODO
+ */
+public class ManyUserReadTest extends ReadDeepTreeTest {
+
+    private final int numberOfUsers = 1000;
+    private final int numberOfMembers = 10;
+
+    protected ManyUserReadTest(boolean runAsAdmin, int itemsToRead, int bgReaders, boolean
doReport) {
+        super(runAsAdmin, itemsToRead, bgReaders, doReport);
+    }
+
+    @Override
+    protected void createDeepTree() throws Exception {
+        super.createDeepTree();
+
+        UserManager userManager = ((JackrabbitSession) adminSession).getUserManager();
+        for (int i = 0; i < numberOfUsers; i++) {
+            User user = userManager.createUser("user"+i, "user"+i);
+            AccessControlUtils.addAccessControlEntry(adminSession, user.getPath(), user.getPrincipal(),
new String[] {Privilege.JCR_ALL}, true);
+
+            Node userNode = adminSession.getNode(user.getPath());
+            Node n = userNode.addNode("public");
+            n.setProperty("prop", "value");
+            String path = n.getPath();
+            AccessControlUtils.addAccessControlEntry(adminSession, path, EveryonePrincipal.getInstance(),
new String[]{Privilege.JCR_READ}, true);
+            allPaths.add(path);
+            allPaths.add(path + "/prop");
+
+            Group g = userManager.createGroup("group" + i);
+            AccessControlUtils.addAccessControlEntry(adminSession, g.getPath(), g.getPrincipal(),
new String[] {Privilege.JCR_READ}, true);
+
+            n = userNode.addNode("semi");
+            n.setProperty("prop", "value");
+            path = n.getPath();
+            AccessControlUtils.addAccessControlEntry(adminSession, path, g.getPrincipal(),
new String[]{Privilege.JCR_READ}, true);
+            allPaths.add(path);
+            allPaths.add(path + "/prop");
+
+            userNode.addNode("private").setProperty("prop", "value");
+            adminSession.save();
+        }
+        System.out.println("Setup "+numberOfUsers+" users");
+
+        for (int i = 0; i < numberOfUsers; i++) {
+            Group g = (Group) userManager.getAuthorizable("group"+i);
+            for (int j = 0; j < numberOfMembers; j++) {
+                g.addMember(userManager.getAuthorizable("user" + getIndex()));
+            }
+            adminSession.save();
+        }
+
+        System.out.println("Setup group membership ("+numberOfMembers+" members per group)");
+        System.out.println("All Paths : " + allPaths.size());
+
+        AccessControlUtils.denyAllToEveryone(adminSession, "/rep:security/rep:authorizables");
+        adminSession.save();
+
+    }
+
+    @Override
+    protected String getImportFileName() {
+        return "deepTree_everyone.xml";
+    }
+
+    protected Session getTestSession() {
+        if (runAsAdmin) {
+            return loginWriter();
+        } else {
+            String userId = "user" + getIndex();
+            SimpleCredentials sc = new SimpleCredentials(userId, userId.toCharArray());
+            return login(sc);
+        }
+    }
+
+    private int getIndex() {
+        return (int) Math.floor(numberOfUsers * Math.random());
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java?rev=1534706&r1=1534705&r2=1534706&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
Tue Oct 22 17:18:31 2013
@@ -88,7 +88,7 @@ public class ReadDeepTreeTest extends Ab
         long start = System.currentTimeMillis();
         if (!rn.hasNode(testNodeName)) {
             testRoot = adminSession.getRootNode().addNode(testNodeName, "nt:unstructured");
-            InputStream in = getClass().getClassLoader().getResourceAsStream("deepTree.xml");
+            InputStream in = getClass().getClassLoader().getResourceAsStream(getImportFileName());
             adminSession.importXML(testRoot.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
             adminSession.save();
         } else {
@@ -112,6 +112,10 @@ public class ReadDeepTreeTest extends Ab
         System.out.println("All paths: " + allPaths.size());
     }
 
+    protected String getImportFileName() {
+        return "deepTree.xml";
+    }
+
     protected void visitingNode(Node node, int i) throws RepositoryException {
         allPaths.add(node.getPath());
     }

Added: jackrabbit/oak/trunk/oak-run/src/main/resources/deepTree_everyone.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/resources/deepTree_everyone.xml?rev=1534706&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/resources/deepTree_everyone.xml (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/resources/deepTree_everyone.xml Tue Oct 22 17:18:31
2013
@@ -0,0 +1 @@

[... 3 lines stripped ...]
Modified: jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml?rev=1534706&r1=1534705&r2=1534706&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/resources/org/apache/jackrabbit/oak/fixture/repository.xml
Tue Oct 22 17:18:31 2013
@@ -47,7 +47,7 @@
             security manager:
             class: FQN of class implementing the JackrabbitSecurityManager interface
         -->
-        <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" workspaceName="security">
+        <SecurityManager class="org.apache.jackrabbit.core.UserPerWorkspaceSecurityManager">
             <!--
             workspace access:
             class: FQN of class implementing the WorkspaceAccessManager interface



Mime
View raw message