jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1025979 - in /jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance: AddGroupMembersTest.java CreateUserTest.java GroupGetMembersTest.java GroupMemberLookupTest.java
Date Thu, 21 Oct 2010 12:51:09 GMT
Author: mduerig
Date: Thu Oct 21 12:51:09 2010
New Revision: 1025979

URL: http://svn.apache.org/viewvc?rev=1025979&view=rev
Log:
JCR-2727: Add user manager performance tests
Applied Jukka's patch with some modifications

Modified:
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AddGroupMembersTest.java
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/CreateUserTest.java
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupGetMembersTest.java
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupMemberLookupTest.java

Modified: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AddGroupMembersTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AddGroupMembersTest.java?rev=1025979&r1=1025978&r2=1025979&view=diff
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AddGroupMembersTest.java
(original)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AddGroupMembersTest.java
Thu Oct 21 12:51:09 2010
@@ -21,48 +21,48 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 
-import javax.jcr.Session;
-
 import java.security.Principal;
 
 public class AddGroupMembersTest extends AbstractTest {
+
+    private static final int SCALE = getScale(100);
+
     private static final Principal GROUP_PRINCIPAL = new Principal() {
         public String getName() {
             return "test_group";
         }
     };
 
-    private Session session;
     private UserManager userMgr;
-    private int userCount;
     private Group group;
-    private User currentUser;
+    private User[] users = new User[SCALE];
+    private int userCount;
 
     @Override
     protected void beforeSuite() throws Exception {
-        session = getRepository().login(getCredentials());
-        userMgr = ((JackrabbitSession) session).getUserManager();
+        userMgr = ((JackrabbitSession) loginWriter()).getUserManager();
         group = userMgr.createGroup(GROUP_PRINCIPAL);
     }
 
     @Override
     protected void beforeTest() throws Exception {
-        currentUser = userMgr.createUser("user_" + userCount, "pass");
-        userCount++;
+        for (int i = 0; i < users.length; i++, userCount++) {
+            users[i] = userMgr.createUser("user_" + userCount, "pass");
+        }
     }
 
     @Override
     protected void runTest() throws Exception {
-        group.addMember(currentUser);
+        for (User user : users) {
+            group.addMember(user);
+        }
     }
 
     @Override
     protected void afterSuite() throws Exception {
-        for (int k = 0; k < userCount; k++) {
-            userMgr.getAuthorizable("user_" + k).remove();
+        for (int i = 0; i < userCount; i++) {
+            userMgr.getAuthorizable("user_" + i).remove();
         }
-        group.remove();
-        session.logout();
     }
 
 }

Modified: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/CreateUserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/CreateUserTest.java?rev=1025979&r1=1025978&r2=1025979&view=diff
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/CreateUserTest.java
(original)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/CreateUserTest.java
Thu Oct 21 12:51:09 2010
@@ -19,31 +19,30 @@ package org.apache.jackrabbit.performanc
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.UserManager;
 
-import javax.jcr.Session;
-
 public class CreateUserTest extends AbstractTest {
-    private Session session;
+
+    private static final int SCALE = getScale(100);
+
     private UserManager userMgr;
     private int userCount;
 
     @Override
     protected void beforeSuite() throws Exception {
-        session = getRepository().login(getCredentials());
-        userMgr = ((JackrabbitSession) session).getUserManager();
+        userMgr = ((JackrabbitSession) loginWriter()).getUserManager();
     }
 
     @Override
     protected void runTest() throws Exception {
-        userMgr.createUser("user_" + userCount, "pass");
-        userCount++;
+        for (int i = 0; i < SCALE; i++, userCount++) {
+            userMgr.createUser("user_" + userCount, "pass");
+        }
     }
 
     @Override
     protected void afterSuite() throws Exception {
-        for (int k = 0; k < userCount; k++) {
-            userMgr.getAuthorizable("user_" + k).remove();
+        for (int i = 0; i < userCount; i++) {
+            userMgr.getAuthorizable("user_" + i).remove();
         }
-        session.logout();
     }
 
 }

Modified: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupGetMembersTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupGetMembersTest.java?rev=1025979&r1=1025978&r2=1025979&view=diff
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupGetMembersTest.java
(original)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupGetMembersTest.java
Thu Oct 21 12:51:09 2010
@@ -20,27 +20,25 @@ import org.apache.jackrabbit.api.Jackrab
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.UserManager;
 
-import javax.jcr.Session;
-
 import java.security.Principal;
 import java.util.Iterator;
 
 public class GroupGetMembersTest extends AbstractTest {
-    private static int USER_COUNT = 2000;
+
+    private static final int USER_COUNT = getScale(2000);
+
     private static final Principal GROUP_PRINCIPAL = new Principal() {
         public String getName() {
             return "test_group";
         }
     };
 
-    private Session session;
     private UserManager userMgr;
     private Group group;
 
     @Override
     protected void beforeSuite() throws Exception {
-        session = getRepository().login(getCredentials());
-        userMgr = ((JackrabbitSession) session).getUserManager();
+        userMgr = ((JackrabbitSession) loginWriter()).getUserManager();
         group = userMgr.createGroup(GROUP_PRINCIPAL);
         for (int k = 0; k < USER_COUNT; k++) {
             group.addMember(userMgr.createUser("user_" + k, "pass"));
@@ -64,7 +62,6 @@ public class GroupGetMembersTest extends
             userMgr.getAuthorizable("user_" + k).remove();
         }
         group.remove();
-        session.logout();
     }
 
 }

Modified: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupMemberLookupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupMemberLookupTest.java?rev=1025979&r1=1025978&r2=1025979&view=diff
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupMemberLookupTest.java
(original)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/GroupMemberLookupTest.java
Thu Oct 21 12:51:09 2010
@@ -17,17 +17,17 @@
 package org.apache.jackrabbit.performance;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.user.Authorizable;
 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 javax.jcr.Session;
-
 import java.security.Principal;
 import java.util.Random;
 
 public class GroupMemberLookupTest extends AbstractTest {
-    private static int USER_COUNT = 2000;
+
+    private static final int USER_COUNT = getScale(2000);
+
     private static final Principal GROUP_PRINCIPAL = new Principal() {
         public String getName() {
             return "test_group";
@@ -36,39 +36,33 @@ public class GroupMemberLookupTest exten
 
     private final Random rng = new Random();
 
-    private Session session;
-    private UserManager userMgr;
     private Group group;
-    private Authorizable user;
+    private User[] users;
 
     @Override
     protected void beforeSuite() throws Exception {
-        session = getRepository().login(getCredentials());
-        userMgr = ((JackrabbitSession) session).getUserManager();
+        UserManager userMgr = ((JackrabbitSession) loginWriter()).getUserManager();
         group = userMgr.createGroup(GROUP_PRINCIPAL);
-        for (int k = 0; k < USER_COUNT; k++) {
-            group.addMember(userMgr.createUser("user_" + k, "pass"));
+        users = new User[USER_COUNT];
+        for (int i = 0; i < users.length; i++) {
+            users[i] = userMgr.createUser("user_" + i, "pass");
+            group.addMember(users[i]);
         }
     }
 
     @Override
-    protected void beforeTest() throws Exception {
-        String id = "user_" + rng.nextInt(USER_COUNT);
-        user = userMgr.getAuthorizable(id);
-    }
-
-    @Override
     protected void runTest() throws Exception {
-        group.isMember(user);
+        for (int i = 0; i < 1000; i++) {
+            group.isMember(users[rng.nextInt(users.length)]);
+        }
     }
 
     @Override
     protected void afterSuite() throws Exception {
-        for (int k = 0; k < USER_COUNT; k++) {
-            userMgr.getAuthorizable("user_" + k).remove();
+        for (User user : users) {
+            user.remove();
         }
         group.remove();
-        session.logout();
     }
 
 }



Mime
View raw message