You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/01/23 17:30:45 UTC

incubator-usergrid git commit: Updated to use method fork counts

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-273 b61349865 -> 4402feb17


Updated to use method fork counts

Updated service tests to support parallelism


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

Branch: refs/heads/USERGRID-273
Commit: 4402feb17072ef386280d7c9e58d4cd017b49904
Parents: b613498
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Jan 23 09:30:43 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Jan 23 09:30:43 2015 -0700

----------------------------------------------------------------------
 stack/services/pom.xml                          |  11 +-
 .../org/apache/usergrid/ServiceITSetupImpl.java |  19 +--
 .../apache/usergrid/management/EmailFlowIT.java |   3 +
 .../security/tokens/TokenServiceIT.java         |   4 +-
 .../test/resources/usergrid-test-context.xml    | 128 +++++++++----------
 .../setup/ConcurrentProcessSingleton.java       |   8 ++
 6 files changed, 93 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index dd94eb7..0683e5d 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -88,10 +88,11 @@
                 <storage-config>${basedir}/src/test/conf</storage-config>
                 <target.directory>${project.build.directory}</target.directory>
               </systemPropertyVariables>
-              <parallel>classes</parallel>
-              <forkCount>${services.it.forkCount}</forkCount>
-              <reuseForks>${services.it.reuseForks}</reuseForks>
-              <argLine>-Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}</argLine>
+                <parallel>methods</parallel>
+               <forkCount>${usergrid.it.forkCount}</forkCount>
+               <threadCount>${usergrid.it.threads}</threadCount>
+               <reuseForks>true</reuseForks>
+              <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}</argLine>
               <includes>
                 <include>**/*IT.java</include>
                 <include>**/*Test.java</include>
@@ -280,7 +281,7 @@
       <!-- Testing and Logging Dependencies -->
     <dependency>
       <!--
-      Do not remove this slf4j-api dependency remove even though pulled 
+      Do not remove this slf4j-api dependency remove even though pulled
       in transitively. If not present IntelliJ IDEA wigs out.
       -->
       <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
index a990bbb..7187afb 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
@@ -33,6 +33,7 @@ import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 import org.apache.usergrid.security.providers.SignInProviderFactory;
 import org.apache.usergrid.security.tokens.TokenService;
 import org.apache.usergrid.services.ServiceManagerFactory;
+import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 
 
 /** A {@link org.junit.rules.TestRule} that sets up services. */
@@ -60,13 +61,13 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
 
     protected void before( Description description ) throws Throwable {
         super.before( description );
-        managementService =  SpringResource.getInstance().getBean( ManagementService.class );
-        applicationCreator =  SpringResource.getInstance().getBean( ApplicationCreator.class );
-        tokenService =  SpringResource.getInstance().getBean( TokenService.class );
-        providerFactory =  SpringResource.getInstance().getBean( SignInProviderFactory.class );
-        properties =  SpringResource.getInstance().getBean( PropertiesFactoryBean.class ).getObject();
-        smf =  SpringResource.getInstance().getBean( ServiceManagerFactory.class );
-        exportService =  SpringResource.getInstance().getBean( ExportService.class );
+        managementService =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( ManagementService.class );
+        applicationCreator =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( ApplicationCreator.class );
+        tokenService =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( TokenService.class );
+        providerFactory =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( SignInProviderFactory.class );
+        properties =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( PropertiesFactoryBean.class ).getObject();
+        smf =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( ServiceManagerFactory.class );
+        exportService =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( ExportService.class );
 
         LOG.info( "Test setup complete..." );
     }
@@ -92,7 +93,7 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
 
     @Override
     public CassandraService getCassSvc() {
-        return  SpringResource.getInstance().getBean( CassandraService.class );
+        return  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( CassandraService.class );
     }
 
 
@@ -107,7 +108,7 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
 
     public ServiceManagerFactory getSmf() {
         if ( smf == null ) {
-            smf =  SpringResource.getInstance().getBean( ServiceManagerFactory.class );
+            smf =  ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( ServiceManagerFactory.class );
         }
 
         return smf;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index d3763b2..dee21a7 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -50,6 +50,8 @@ import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 
+import net.jcip.annotations.NotThreadSafe;
+
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.apache.usergrid.TestHelper.uniqueApp;
 import static org.apache.usergrid.TestHelper.uniqueEmail;
@@ -89,6 +91,7 @@ import static org.junit.Assert.assertTrue;
  * <p/>
  * Hence there can be race conditions between test methods in this class.
  */
+@NotThreadSafe
 public class EmailFlowIT {
     private static final Logger LOG = LoggerFactory.getLogger( EmailFlowIT.class );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
index 69bb0e2..cdf50a2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/security/tokens/TokenServiceIT.java
@@ -56,8 +56,8 @@ public class TokenServiceIT {
 
     static Logger log = LoggerFactory.getLogger( TokenServiceIT.class );
 
-    // app-level data generated only once
-    private static UserInfo adminUser;
+    // app-level data generated only once per test
+    private UserInfo adminUser;
 
     @Rule
     public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/services/src/test/resources/usergrid-test-context.xml
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-test-context.xml b/stack/services/src/test/resources/usergrid-test-context.xml
index 1a1720b..f6d750d 100644
--- a/stack/services/src/test/resources/usergrid-test-context.xml
+++ b/stack/services/src/test/resources/usergrid-test-context.xml
@@ -1,64 +1,64 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="
-	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
-	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
-
-    <bean id="properties"
-          class="org.springframework.beans.factory.config.PropertiesFactoryBean">
-        <property name="singleton" value="true" />
-        <property name="ignoreResourceNotFound" value="true" />
-        <property name="locations">
-            <list>
-                <value>classpath:/usergrid-default.properties</value>
-                <value>classpath:/usergrid-test.properties</value>
-                <value>${usergrid-custom-spring-test-properties}</value>
-            </list>
-        </property>
-    </bean>
-
-    <import resource="classpath:/usergrid-services-context.xml" />
-
-    <bean id="setup" class="org.apache.usergrid.corepersistence.HybridSetup">
-        <constructor-arg ref="properties"/>
-        <constructor-arg ref="entityManagerFactory"/>
-        <constructor-arg ref="cassandraService"/>
-    </bean>
-
-    <!-- The default schema manager -->
-    <!-- refer to a named schemaManager from the DataControl annotation thusly -->
-    <bean id="coreManager" class="org.apache.usergrid.persistence.CoreSchemaManager">
-        <constructor-arg ref="setup"/>
-        <constructor-arg ref="cassandraCluster"/>
-    </bean>
-
-    <bean id="binaryStore" class="org.apache.usergrid.services.assets.data.LocalFileBinaryStore">
-        <property name="reposLocation" value="${usergrid.temp.files}"/>
-    </bean>
-
-    <!--<bean id="binaryStore" class="org.apache.usergrid.services.assets.data.S3BinaryStore">-->
-    <!--<constructor-arg name="accessId" value="xx" />-->
-    <!--<constructor-arg name="secretKey" value="xx" />-->
-    <!--<constructor-arg name="bucketName" value="xx" />-->
-    <!--</bean>-->
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+    <bean id="properties"
+          class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+        <property name="singleton" value="true" />
+        <property name="ignoreResourceNotFound" value="true" />
+        <property name="locations">
+            <list>
+                <value>classpath:/usergrid-default.properties</value>
+                <value>classpath:/usergrid-test.properties</value>
+                <value>${usergrid-custom-spring-test-properties}</value>
+            </list>
+        </property>
+    </bean>
+
+    <import resource="classpath:/usergrid-services-context.xml" />
+
+    <bean id="setup" class="org.apache.usergrid.corepersistence.CpSetup">
+        <constructor-arg ref="entityManagerFactory"/>
+        <constructor-arg ref="cassandraService"/>
+        <constructor-arg ref="injector"/>
+    </bean>
+
+    <!-- The default schema manager -->
+    <!-- refer to a named schemaManager from the DataControl annotation thusly -->
+    <bean id="coreManager" class="org.apache.usergrid.persistence.CoreSchemaManager">
+        <constructor-arg ref="setup"/>
+        <constructor-arg ref="cassandraCluster"/>
+    </bean>
+
+    <bean id="binaryStore" class="org.apache.usergrid.services.assets.data.LocalFileBinaryStore">
+        <property name="reposLocation" value="${usergrid.temp.files}"/>
+    </bean>
+
+    <!--<bean id="binaryStore" class="org.apache.usergrid.services.assets.data.S3BinaryStore">-->
+    <!--<constructor-arg name="accessId" value="xx" />-->
+    <!--<constructor-arg name="secretKey" value="xx" />-->
+    <!--<constructor-arg name="bucketName" value="xx" />-->
+    <!--</bean>-->
+
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4402feb1/stack/test-utils/src/main/java/org/apache/usergrid/setup/ConcurrentProcessSingleton.java
----------------------------------------------------------------------
diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/setup/ConcurrentProcessSingleton.java b/stack/test-utils/src/main/java/org/apache/usergrid/setup/ConcurrentProcessSingleton.java
index 1ccbbef..adc9fda 100644
--- a/stack/test-utils/src/main/java/org/apache/usergrid/setup/ConcurrentProcessSingleton.java
+++ b/stack/test-utils/src/main/java/org/apache/usergrid/setup/ConcurrentProcessSingleton.java
@@ -73,20 +73,26 @@ public class ConcurrentProcessSingleton {
     private void startSystem() {
         try {
 
+            logger.info( "Trying to get a lock to setup system" );
             //we have a lock, so init the system
             if ( lock.tryLock() ) {
 
+                logger.info( "Lock acquired, setting up system" );
 
                 final SchemaManager schemaManager = SpringResource.getInstance().getBean( SchemaManager.class );
 
 
                 //maybe delete existing column families and indexes
                 if ( CLEAN_STORAGE ) {
+                    logger.info("Destroying current database");
                     schemaManager.destroy();
                 }
 
                 //create our schema
+                logger.info("Creating database");
                 schemaManager.create();
+
+                logger.info("Populating database");
                 schemaManager.populateBaseData();
 
 
@@ -95,7 +101,9 @@ public class ConcurrentProcessSingleton {
             }
 
 
+            logger.info( "Waiting for setup to complete" );
             barrier.await( ONE_MINUTE );
+            logger.info( "Setup to complete" );
 
             lock.maybeReleaseLock();
         }