directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: cleanup jmeter createsess funcs
Date Sun, 20 Mar 2016 18:50:46 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 10876a33b -> ff50d8f1e


cleanup jmeter createsess funcs


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/ff50d8f1
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/ff50d8f1
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/ff50d8f1

Branch: refs/heads/master
Commit: ff50d8f1e0f98f845fc3713e5fe40f7244519f26
Parents: 10876a3
Author: Shawn McKinney <smckinney@apache.org>
Authored: Sun Mar 20 11:58:54 2016 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Sun Mar 20 11:58:54 2016 -0500

----------------------------------------------------------------------
 .../core/jmeter/AccelCreateSession.java         | 58 ++++++++++----------
 1 file changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ff50d8f1/src/test/java/org/apache/directory/fortress/core/jmeter/AccelCreateSession.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/jmeter/AccelCreateSession.java
b/src/test/java/org/apache/directory/fortress/core/jmeter/AccelCreateSession.java
index f320b76..8dc2649 100644
--- a/src/test/java/org/apache/directory/fortress/core/jmeter/AccelCreateSession.java
+++ b/src/test/java/org/apache/directory/fortress/core/jmeter/AccelCreateSession.java
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.fortress.core.jmeter;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.directory.fortress.core.*;
 import org.apache.directory.fortress.core.SecurityException;
 import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
@@ -39,13 +40,12 @@ import static org.junit.Assert.*;
  */
 public class AccelCreateSession extends AbstractJavaSamplerClient
 {
-
-    private boolean echoRequest = false;
-    private boolean returnResult = false;
     private AccelMgr accelMgr;
     private static final org.slf4j.Logger LOG = LoggerFactory.getLogger( AccelCreateSession.class
);
     private static int count = 0;
+    private int key = 0;
     private int ctr = 0;
+    private String userId = "";
 
     /**
      * Description of the Method
@@ -59,27 +59,25 @@ public class AccelCreateSession extends AbstractJavaSamplerClient
         try
         {
             sampleResult.sampleStart();
-            assertNotNull( accelMgr );
-            String message = "AC CreateSession TID: " + getThreadId() + " #:" + ctr++;
-            LOG.debug( message );
+            //String message = "FT CreateSession TID: " + getThreadId() + " UID:" + userId
+ " CTR:" + ctr++;
+            //LOG.info( message );
             //System.out.println( message );
+            assertNotNull( accelMgr );
             Session session;
             User user = new User();
             // positive test case:
-            user.setUserId( "rbacuser1" );
+            user.setUserId( userId );
             user.setPassword( "secret".toCharArray() );
             session = accelMgr.createSession( user, false );
             assertNotNull( session );
             assertTrue( session.isAuthenticated() );
             sampleResult.sampleEnd();
             sampleResult.setBytes(1);
-            sampleResult.setResponseMessage("test completed");
+            sampleResult.setResponseMessage("AC test completed TID: " + getThreadId() + "
UID: " + userId);
             sampleResult.setSuccessful(true);
-            //accelMgr.deleteSession( session );
         }
         catch ( org.apache.directory.fortress.core.SecurityException se )
         {
-            se.printStackTrace();
             System.out.println( "ThreadId:" + getThreadId() + "Error running test: " + se
);
             se.printStackTrace();
             sampleResult.setSuccessful( false );
@@ -89,29 +87,22 @@ public class AccelCreateSession extends AbstractJavaSamplerClient
     }
 
     /**
-     * @param threadId
-     * @return
-     */
-    synchronized private String getKey( long threadId )
-    {
-        return threadId + "-" + count++;
-    }
-
-
-    private String getThreadId()
-    {
-        return "" + Thread.currentThread().getId();
-    }
-
-    /**
      * Description of the Method
      *
      * @param samplerContext Description of the Parameter
      */
     public void setupTest( JavaSamplerContext samplerContext )
     {
-        getKey( Thread.currentThread().getId() );
-        String message = "AC SETUP CreateSession TID: " + getThreadId();
+        ctr = 0;
+        if( StringUtils.isEmpty( userId ))
+        {
+            // Load userids are format:  loadtestuserN - where N is a number between 0 and
99.
+            // i.e. loadtestuser0,  loadtestuser1,  ... loadtestuser99
+            // N is threadid mod 100.
+            key = getKey();
+            userId = "loadtestuser" + key % 100;
+        }
+        String message = "AC SETUP CreateSession TID: " + getThreadId() + " UID: " + userId;
         LOG.info( message );
         System.out.println( message );
         try
@@ -120,12 +111,12 @@ public class AccelCreateSession extends AbstractJavaSamplerClient
         }
         catch ( SecurityException se )
         {
-            se.printStackTrace();
-            System.out.println( "AC SETUP ThreadId:" + getThreadId() + "Error setup test:
" + se );
+            System.out.println( "ThreadId:" + getThreadId() + "FT SETUP Error: " + se );
             se.printStackTrace();
         }
     }
 
+
     /**
      * Description of the Method
      *
@@ -137,5 +128,14 @@ public class AccelCreateSession extends AbstractJavaSamplerClient
         LOG.info( message );
         System.out.println( message );
     }
+
+    synchronized private int getKey( )
+    {
+        return ++count;
+    }
+    private String getThreadId()
+    {
+        return "" + Thread.currentThread().getId();
+    }
 }
 


Mime
View raw message