usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [6/6] git commit: Fixes to allow Tomcat, Cassanrda and ElasticSearch to work properly in REST tests.
Date Tue, 29 Jul 2014 14:14:02 GMT
Fixes to allow Tomcat, Cassanrda and ElasticSearch to work properly in REST tests.


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

Branch: refs/heads/two-dot-o
Commit: a7b53083cee10bf6a19611a83258241f72a908b5
Parents: eb20781
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Tue Jul 29 10:04:01 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Tue Jul 29 10:04:01 2014 -0400

----------------------------------------------------------------------
 .../src/test/resources/usergrid-test.properties |  3 +++
 .../usergrid/corepersistence/CpSetup.java       |  7 ++++++
 .../persistence/index/impl/EsProvider.java      | 23 +++++++++++++++-----
 stack/pom.xml                                   |  8 +++----
 .../apache/usergrid/rest/TomcatResource.java    | 15 +++++--------
 .../collection/activities/AndOrQueryTest.java   | 12 ++++++++++
 stack/rest/src/test/resources/log4j.properties  | 11 +++++-----
 .../cassandra/ManagementServiceImpl.java        |  2 +-
 .../java/org/apache/usergrid/TomcatMain.java    |  1 +
 9 files changed, 58 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/config/src/test/resources/usergrid-test.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/test/resources/usergrid-test.properties b/stack/config/src/test/resources/usergrid-test.properties
index b820e5c..8388e52 100644
--- a/stack/config/src/test/resources/usergrid-test.properties
+++ b/stack/config/src/test/resources/usergrid-test.properties
@@ -44,6 +44,9 @@ cassandra.writecl=QUORUM
 #Keyspace to use for locking
 cassandra.lock.keyspace=Locks
 
+elasticsearch.embedded=true
+elasticsearch.cluster_name=test_cluster
+
 #Properties to control the number of buckets in the index.
 usergrid.index.defaultbucketsize=20
 usergrid.counter.skipAggregate=false

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index f3cc87c..a940e0a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -120,6 +120,13 @@ public class CpSetup implements Setup {
             cpProps.put("cassandra.port", hosts[0].getPort());
             cpProps.put("cassandra.cluster_name", cass.getProperties().get("cassandra.cluster"));
 
+            String cassRemoteString = (String)cass.getProperties().get("cassandra.use_remote");

+            if ( cassRemoteString != null && cassRemoteString.equals("false")) {
+                cpProps.put("cassandra.embedded", "true");
+            } else {
+                cpProps.put("cassandra.embedded", "false");
+            }
+
             cpProps.put("collections.keyspace.strategy.class", 
                     cass.getProperties().get("cassandra.keyspace.strategy"));
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index 678aae2..58446e4 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -79,10 +79,17 @@ public class EsProvider {
                 }
 
                 Settings settings = ImmutableSettings.settingsBuilder()
-                    .put("node.http.enabled", true)
+
+                    .put("cluster.name", fig.getClusterName())
+
+                    .put("network.publish_host","127.0.0.1")
                     .put("transport.tcp.port", port)
+                    .put("discovery.zen.ping.multicast.enabled","false")
+                    .put("node.http.enabled", false)
+
                     .put("path.logs", tempDir.toString())
                     .put("path.data", tempDir.toString())
+
                     .put("gateway.type", "none")
                     .put("index.store.type", "memory")
                     .put("index.number_of_shards", 1)
@@ -90,7 +97,7 @@ public class EsProvider {
                     .build();
 
                 log.info("-----------------------------------------------------------------------");
-                log.info("Starting ElasticSearch embedded with settings: \n" + settings.getAsMap()
);
+                log.info("Starting ElasticSearch embedded server with settings: \n" + settings.getAsMap()
);
                 log.info("-----------------------------------------------------------------------");
 
                 Node node = NodeBuilder.nodeBuilder().settings(settings)
@@ -109,17 +116,23 @@ public class EsProvider {
                 }
 
                 Settings settings = ImmutableSettings.settingsBuilder()
-                    .put("client.transport.ping_timeout", 2000) // milliseconds
-                    .put("client.transport.nodes_sampler_interval", 100)
+
                     .put("cluster.name", fig.getClusterName())
-                    .put("http.enabled", false)
 
                     // this assumes that we're using zen for host discovery.  Putting an

                     // explicit set of bootstrap hosts ensures we connect to a valid cluster.
                     .put("discovery.zen.ping.unicast.hosts", allHosts)
+                    .put("discovery.zen.ping.multicast.enabled","false")
+                    .put("http.enabled", false) 
+
+                    .put("client.transport.ping_timeout", 2000) // milliseconds
+                    .put("client.transport.nodes_sampler_interval", 100)
+
                     .build();
 
+                log.info("-----------------------------------------------------------------------");
                 log.info("Creating ElasticSearch client with settings: " +  settings.getAsMap());
+                log.info("-----------------------------------------------------------------------");
 
                 Node node = NodeBuilder.nodeBuilder().settings(settings)
                     .client(true).node();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 4e4eee2..4c03904 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -190,13 +190,13 @@
     <module>core</module>
     <module>services</module>
     <module>tools</module>
+    <module>mongo-emulator</module>
+    <module>websocket</module>
     <module>rest</module>
-    <module>test-utils</module>
-    <module>build-tools</module>
     <module>launcher</module>
+    <module>test-utils</module>
     <module>query-validator</module>
-    <module>mongo-emulator</module>
-    <module>websocket</module>
+    <module>build-tools</module>
   </modules>
 
   <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
index d7fd7f3..0da3701 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
@@ -121,7 +121,10 @@ public class TomcatResource extends ExternalResource {
 
         String javaHome = (String)System.getenv("JAVA_HOME");
 
-        ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/java",
+        String logConfig = "-Dlog4j.configuration=file:./src/test/resources/log4j.properties";
+        String maxMemory = "-Xmx5000m";
+
+        ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/java", maxMemory, logConfig,
                 "org.apache.usergrid.TomcatMain", "src/main/webapp", port + "");
 
         // ensure Tomcat gets same classpath we have
@@ -184,14 +187,7 @@ public class TomcatResource extends ExternalResource {
         pw.println("usergrid.sysadmin.login.email=superuser@usergrid.com");
         pw.println("usergrid.sysadmin.login.password=superpassword");
         pw.println("usergrid.sysadmin.login.allowed=true");
-        pw.flush();
-        pw.close();
         
-        pw = new PrintWriter( 
-                new FileWriter( propDirPath + File.separator + "corepersistence.properties"));
-        
-        pw.println("cassandra.hosts=127.0.0.1");
-        pw.println("cassandra.port=" + cassPort);
         pw.println("cassandra.version=1.2");
         pw.println("cassandra.cluster_name=Usergrid");
         pw.println("cassandra.connections=20");
@@ -204,10 +200,11 @@ public class TomcatResource extends ExternalResource {
         
         pw.println("elasticsearch.hosts=127.0.0.1");
         pw.println("elasticsearch.port=" + esPort);
-        pw.println("elasticsearch.cluster_name=usergrid_test");
+        pw.println("elasticsearch.cluster_name=test_cluster");
         pw.println("elasticsearch.index_prefix=usergrid");
         
         pw.println("index.query.limit.default=1000");
+        
         pw.flush();
         pw.close();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
index bf90d4d..5dbce3b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
@@ -74,6 +74,8 @@ public class AndOrQueryTest extends AbstractRestIT {
             }
         }
 
+        this.reindex( context.getAppUuid() );
+
         String errorQuery = "select * where created >= " + created + "AND madeup = true";
         JsonNode incorrectNode = activities.withQuery( errorQuery ).get();
 
@@ -104,6 +106,8 @@ public class AndOrQueryTest extends AbstractRestIT {
             JsonNode activity = activities.create( props );
         }
 
+        this.reindex( context.getAppUuid() );
+
         String query = "select * where not verb = 'go'";
         JsonNode incorrectNode = activities.query( query, "limit", Integer.toString( 10 )
);
 
@@ -133,6 +137,8 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         JsonNode[] correctValues = activities.createEntitiesWithOrdinal( props, numValuesTested
);
 
+        this.reindex( context.getAppUuid() );
+
         String inCorrectQuery = "select * where verb = 'go' and ordinal >= 10 ";
 
         activities.verificationOfQueryResults( correctValues, true, inCorrectQuery );
@@ -148,6 +154,8 @@ public class AndOrQueryTest extends AbstractRestIT {
         JsonNode[] correctValues;
         correctValues = madeupStuff.createEntitiesWithOrdinal( character, 1000 );
 
+        this.reindex( context.getAppUuid() );
+
         String inquisitiveQuery =
                 "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'
ORDER BY " + "Ordinal asc";
 
@@ -166,6 +174,8 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         JsonNode[] correctValues = madeupStuff.createEntitiesWithOrdinal( character, numOfEntities
);
 
+        this.reindex( context.getAppUuid() );
+
         String inquisitiveQuery = "select * where Ordinal >= 0 and Ordinal <= 2000
or WhoHelpedYou = 'Ruff'";
 
         int totalEntitiesContained = madeupStuff.verificationOfQueryResults( correctValues,
true, inquisitiveQuery );
@@ -181,6 +191,8 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         madeupStuff.createEntitiesWithOrdinal( character, 1000 );
 
+        this.reindex( context.getAppUuid() );
+
         String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou
eq 'Ruff'";
 
         int totalEntitiesContained = madeupStuff.countEntities( inquisitiveQuery );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/log4j.properties b/stack/rest/src/test/resources/log4j.properties
index bea288b..a6ab96a 100644
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@ -41,20 +41,21 @@ log4j.logger.org.apache.usergrid.rest.security.AllowAjaxFilter=WARN, stdout
 log4j.logger.me.prettyprint.hector.api.beans.AbstractComposite=ERROR, stdout
 log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DEBUG, stdout
 
-#log4j.logger.org.apache.usergrid=WARN
-log4j.logger.org.apache.usergrid.corepersistence=DEBUG
+log4j.logger.org.apache.usergrid=WARN
+log4j.logger.org.apache.usergrid.corepersistence=INFO
 #log4j.logger.org.apache.usergrid.corepersistence.CpEntityManagerFactory=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpSetup=DEBUG
 #log4j.logger.com.netflix.hystrix=DEBUG
 #log4j.logger.org.antlr=DEBUG
 
 #log4j.logger.org.apache.usergrid.persistence.CollectionIT=DEBUG
-log4j.logger.org.apache.usergrid.persistence.index=DEBUG
 #log4j.logger.org.apache.usergrid.persistence.index.impl=INFO
-#log4j.logger.org.apache.usergrid.persistence.collection=INFO
+log4j.logger.org.apache.usergrid.persistence.index=INFO
+log4j.logger.org.apache.usergrid.persistence.collection=INFO
 #log4j.logger.org.elasticsearch=DEBUG
 
 #log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout
 
-log4j.logger.org.apache.usergrid.rest=INFO
+log4j.logger.org.apache.usergrid.rest=WARN
+log4j.logger.org.apache.usergrid.rest.TomcatResource=INFO
 #log4j.logger.org.usergrid.rest.management=DEBUG

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index b30c99e..4cc5761 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -2864,7 +2864,7 @@ public class ManagementServiceImpl implements ManagementService {
 
     private CredentialsInfo readCreds( UUID appId, UUID ownerId, String ownerType, String
key ) throws Exception {
         EntityManager em = emf.getEntityManager( appId );
-        Entity owner = em.get( new SimpleEntityRef( ownerType, ownerId ) );
+        Entity owner = em.get( ownerId );
         return ( CredentialsInfo ) em.getDictionaryElementValue( owner, DICTIONARY_CREDENTIALS,
key );
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a7b53083/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java
----------------------------------------------------------------------
diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java b/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java
index 2cf353c..371cae9 100644
--- a/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java
+++ b/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java
@@ -40,6 +40,7 @@ public class TomcatMain {
         Tomcat tomcat = new Tomcat();
         tomcat.setBaseDir(dataDir.getAbsolutePath());
         tomcat.setPort(port);
+        tomcat.getConnector().setAttribute("maxThreads", "600");
         tomcat.addWebapp("/", new File(webappsPath).getAbsolutePath());
 
         log.info("-----------------------------------------------------------------");


Mime
View raw message