jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1502567 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: AbstractTest.java BenchmarkRunner.java FlatTreeWithAceForSamePrincipalTest.java
Date Fri, 12 Jul 2013 14:07:00 GMT
Author: angela
Date: Fri Jul 12 14:07:00 2013
New Revision: 1502567

URL: http://svn.apache.org/r1502567
Log:
OAK-887 : test (slightly modified test based on patch provided by antonio sanso)

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/FlatTreeWithAceForSamePrincipalTest.java
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java?rev=1502567&r1=1502566&r2=1502567&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
Fri Jul 12 14:07:00 2013
@@ -239,6 +239,25 @@ abstract class AbstractTest extends Benc
             throw new RuntimeException(e);
         }
     }
+    
+    /**
+    * Returns a new session for the given user
+    * that will be automatically closed once
+    * all the iterations of this test have been executed.
+    * 
+    * @param credentials the user credentials
+    * @return user session
+    */
+   protected Session login(Credentials credentials) {
+       try {
+           Session session = repository.login(credentials);
+           sessions.add(session);
+           return session;
+       } catch (RepositoryException e) {
+           throw new RuntimeException(e);
+       }
+   }
+    
 
     /**
      * Returns a new writer session that will be automatically closed once

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=1502567&r1=1502566&r2=1502567&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
Fri Jul 12 14:07:00 2013
@@ -85,6 +85,7 @@ public class BenchmarkRunner {
             new CreateNodesBenchmark(),
             new ManyNodes(),
             new ObservationTest(),
+            new FlatTreeWithAceForSamePrincipalTest(),
             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/FlatTreeWithAceForSamePrincipalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/FlatTreeWithAceForSamePrincipalTest.java?rev=1502567&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/FlatTreeWithAceForSamePrincipalTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/FlatTreeWithAceForSamePrincipalTest.java
Fri Jul 12 14:07:00 2013
@@ -0,0 +1,85 @@
+/*
+ * 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 java.security.Principal;
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.security.AccessControlManager;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
+import org.h2.util.Profiler;
+
+public class FlatTreeWithAceForSamePrincipalTest extends AbstractTest {
+
+	private Session reader;
+    Profiler profiler = new Profiler();
+
+	@Override
+	protected void beforeSuite() throws Exception {
+
+		long start = System.currentTimeMillis();
+		Session writer = loginWriter();
+
+		UserManager userManager = ((JackrabbitSession) writer).getUserManager();
+        String userId = "test";
+		Principal userPrincipal = userManager.createUser(userId, userId).getPrincipal();
+
+		AccessControlManager acm = writer.getAccessControlManager();
+		JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acm, "/");
+		acl.addEntry(userPrincipal, AccessControlUtils.privilegesFromNames(acm, PrivilegeConstants.JCR_READ),
true);
+		acm.setPolicy("/", acl);
+
+		Node a = writer.getRootNode().addNode("a");
+		for (int i = 1; i < 10000; i++) {
+			a.addNode("node" + i);
+			acl = AccessControlUtils.getAccessControlList(acm, "/a/node"+i);
+			acl.addEntry(userPrincipal, AccessControlUtils.privilegesFromNames(acm, PrivilegeConstants.JCR_READ),
true);
+			acm.setPolicy("/a/node"+i, acl);
+		}
+
+		writer.save();
+		reader = login(new SimpleCredentials(userId, userId.toCharArray()));
+
+		profiler.startCollecting();
+		
+		long end = System.currentTimeMillis();
+		System.out.println("time "+(end - start));
+	}
+
+	@Override
+	protected void runTest() throws Exception {
+		Node n = reader.getNode("/a");
+ 		for (int i = 1; i < 10000; i++) {
+			n.getNode("node" + i);
+		}
+	}
+
+	protected void afterTest() throws Exception {
+		 
+	}
+
+	protected void afterSuite() throws Exception {
+		 
+	}
+
+}



Mime
View raw message