usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [16/50] [abbrv] usergrid git commit: Minor improvements to tests.
Date Mon, 11 Jul 2016 15:35:26 GMT
Minor improvements to tests.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/4394a206
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/4394a206
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/4394a206

Branch: refs/heads/release-2.1.1
Commit: 4394a206afbf8cfdf38b2bf541749b550564f15c
Parents: 58fc657
Author: Dave Johnson <snoopdave@apache.org>
Authored: Fri Jun 17 12:45:24 2016 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Fri Jun 17 12:45:24 2016 -0400

----------------------------------------------------------------------
 .../uniquevalues/UniqueValuesServiceTest.java   |  9 +++--
 .../apache/usergrid/rest/UniqueValuesIT.java    | 36 ++++++++++++++------
 .../rest/UniqueValuesPerformanceIT.java         |  4 +--
 3 files changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/4394a206/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
index 341f604..94d98f5 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
@@ -56,6 +56,10 @@ public class UniqueValuesServiceTest {
 
     private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
+    int numThreads = 6;
+    int poolSize = 5;
+    int numUsers = 100;
+
     @Before
     public void initAkka() {
         if ( !startedAkka.getAndSet( true ) ) {
@@ -77,7 +81,6 @@ public class UniqueValuesServiceTest {
         final AtomicInteger successCounter = new AtomicInteger( 0 );
         final AtomicInteger errorCounter = new AtomicInteger( 0 );
 
-        int numUsers = 100;
         Multimap<String, Entity> usersCreated =
             generateDuplicateUsers( numUsers, successCounter, errorCounter );
 
@@ -110,12 +113,12 @@ public class UniqueValuesServiceTest {
         Multimap<String, Entity> usersCreated =
                 Multimaps.synchronizedListMultimap( ArrayListMultimap.create() );
 
-        ExecutorService execService = Executors.newFixedThreadPool( 10 );
+        ExecutorService execService = Executors.newFixedThreadPool( poolSize );
 
         for (int i = 0; i < numUsers; i++) {
 
             // multiple threads simultaneously trying to create a user with the same propertyName
-            for (int j = 0; j < 5; j++) {
+            for (int j = 0; j < numThreads; j++) {
                 String username = "user_" + i;
 
                 execService.submit( () -> {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4394a206/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesIT.java
index aa9acfe..448e4fd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesIT.java
@@ -28,6 +28,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.ProcessingException;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.Entity;
@@ -35,6 +36,7 @@ import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import java.net.ConnectException;
 import java.text.DecimalFormat;
 import java.util.Collection;
 import java.util.concurrent.ExecutorService;
@@ -65,13 +67,13 @@ public class UniqueValuesIT {
     public void testDuplicatePrevention() throws Exception {
 
         int numThreads = 6;
-        int poolsize = 40;
-        int numUsers = 100;
+        int poolSize = 40;
+        int numUsers = 400;
 
         Multimap<String, Form> usersCreated = Multimaps.synchronizedMultimap( HashMultimap.create()
);
         Multimap<String, Form> dupsRejected = Multimaps.synchronizedMultimap( HashMultimap.create()
);
 
-        ExecutorService execService = Executors.newFixedThreadPool( poolsize );
+        ExecutorService execService = Executors.newFixedThreadPool( poolSize );
 
         Client client = ClientBuilder.newClient();
 
@@ -81,14 +83,15 @@ public class UniqueValuesIT {
 
         final AtomicBoolean failed = new AtomicBoolean(false);
 
-        String randomizer = RandomStringUtils.randomAlphanumeric( 8 );
 
-        String[] targetHosts = {"http://localhost:8080","http://localhost:9090"};
+        String[] targetHosts = {"http://macsnoopdave2013:8080","http://macsnoopdave2010:9090"};
 
         for (int i = 0; i < numUsers; i++) {
 
             if ( failed.get() ) { break; }
 
+            String randomizer = RandomStringUtils.randomAlphanumeric( 8 );
+
             // multiple threads simultaneously trying to create a user with the same propertyName
             for (int j = 0; j < numThreads; j++) {
 
@@ -100,35 +103,46 @@ public class UniqueValuesIT {
                 execService.submit( () -> {
 
                     Form form = new Form();
-                    form.param( "name", username );
+                    //form.param( "name", username );
                     form.param( "username", username );
-                    form.param( "email", username + "@example.org" );
+                    form.param( "email",
+                        username + RandomStringUtils.randomAlphanumeric( 8 ) + "@example.org"
);
                     form.param( "password", "s3cr3t" );
 
                     Timer.Context time = responses.time();
                     try {
                         WebTarget target = client.target( host ).path( "/management/users"
);
 
-                        //logger.info("Posting user {} to host {}", propertyName, host);
+                        //logger.info("Posting user {} to host {}", username, host);
 
                         Response response = target.request()
                             .post( Entity.entity( form, MediaType.APPLICATION_FORM_URLENCODED
));
 
+                        String responseAsString = response.readEntity( String.class );
+
                         if ( response.getStatus() == 200 || response.getStatus() == 201 )
{
                             usersCreated.put( username, form );
                             successCounter.incrementAndGet();
 
-                        } else if ( response.getStatus() == 400 ) {
+                        } else if ( response.getStatus() == 400
+                                && responseAsString.contains("DuplicateUniquePropertyExistsException"))
{
                             dupsRejected.put( username, form );
                             dupCounter.incrementAndGet();
 
                         } else {
-                            String responseAsString = response.readEntity( String.class );
                             logger.error("User creation failed status {} message {}",
-                                    response.getStatus(), responseAsString );
+                                response.getStatus(), responseAsString );
                             errorCounter.incrementAndGet();
                         }
 
+                    } catch ( ProcessingException e ) {
+                        errorCounter.incrementAndGet();
+                        if ( e.getCause() instanceof ConnectException ) {
+                            logger.error("Error connecting to " + host);
+                        } else {
+                            logger.error( "Error", e );
+                        }
+
                     } catch ( Exception e ) {
                         errorCounter.incrementAndGet();
                         logger.error("Error", e);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4394a206/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesPerformanceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesPerformanceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesPerformanceIT.java
index 790eee9..6350755 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesPerformanceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/UniqueValuesPerformanceIT.java
@@ -63,7 +63,7 @@ public class UniqueValuesPerformanceIT {
     public void testBasicOperation() throws Exception {
 
         int numUsers = 1000;
-        int numThreads = 1000;
+        int numThreads = 100;
         int poolsize = 50;
 
         ExecutorService execService = Executors.newFixedThreadPool( poolsize );
@@ -75,7 +75,7 @@ public class UniqueValuesPerformanceIT {
 
         String randomizer = RandomStringUtils.randomAlphanumeric( 8 );
 
-        String[] targetHosts = {"http://localhost:8080","http://localhost:9090"};
+        String[] targetHosts = {"http://macsnoopdave2013:8080","http://macsnoopdave2010:9090"};
 
         final MetricRegistry metrics = new MetricRegistry();
         final Timer responses = metrics.timer( name( UniqueValuesPerformanceIT.class, "responses"
) );


Mime
View raw message