You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/07/07 20:16:40 UTC
[23/50] [abbrv] git commit: REST tests now run without OOM errors
because Tomcat is forked as a separate process. Also simplified how tests are
run by removing concurrency (for now). Still needs some work and it might be
better for us to fork Cassandra a
REST tests now run without OOM errors because Tomcat is forked as a separate process. Also simplified how tests are run by removing concurrency (for now). Still needs some work and it might be better for us to fork Cassandra and ElasticSearch instead; seems like they might be easier to setup.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b5194e7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b5194e7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b5194e7c
Branch: refs/heads/two-dot-o
Commit: b5194e7c6f82cb483bf0741eb7f95e04f537ba02
Parents: 188cbc9
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Jun 27 15:25:25 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Jun 27 15:25:25 2014 -0400
----------------------------------------------------------------------
.../corepersistence/CpRelationManager.java | 5 +
.../persistence/index/impl/EsProvider.java | 54 +-
stack/rest/pom.xml | 1120 +++++++++---------
.../apache/usergrid/rest/AbstractRestIT.java | 3 +-
.../java/org/apache/usergrid/rest/ITSetup.java | 15 +-
.../apache/usergrid/rest/TomcatResource.java | 203 +++-
stack/test-utils/pom.xml | 472 ++++----
.../java/org/apache/usergrid/TomcatMain.java | 56 +
8 files changed, 1061 insertions(+), 867 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 80e6c0c..333ffc8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -1529,6 +1529,11 @@ public class CpRelationManager implements RelationManager {
org.apache.usergrid.persistence.model.entity.Entity e =
ecm.load( cr.getId() ).toBlockingObservable().last();
+// if ( e == null ) {
+// logger.error("Entity {}:{} not found", cr.getId().getType(), cr.getId().getUuid());
+// continue;
+// }
+
if ( cr.getVersion().compareTo( e.getVersion()) < 0 ) {
logger.debug("Stale version uuid:{} type:{} version:{}",
new Object[] {cr.getId().getUuid(), cr.getId().getType(), cr.getVersion()});
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/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 376f606..d696737 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
@@ -18,17 +18,6 @@
*/
package org.apache.usergrid.persistence.index.impl;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
-import org.apache.usergrid.persistence.index.IndexFig;
-
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.File;
@@ -36,9 +25,18 @@ import java.io.IOException;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
+import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
+import org.apache.usergrid.persistence.index.IndexFig;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * Provides access to ElasticSearch client.
+ * Provides access to ElasticSearch client and, optionally, embedded ElasticSearch for testing.
*/
@Singleton
public class EsProvider {
@@ -70,6 +68,8 @@ public class EsProvider {
int port = AvailablePortFinder.getNextAvailable(2000);
+ System.setProperty("EMBEDDED_ES_PORT", port+"");
+
File tempDir;
try {
tempDir = getTempDirectory();
@@ -83,28 +83,44 @@ public class EsProvider {
.put("transport.tcp.port", port)
.put("path.logs", tempDir.toString())
.put("path.data", tempDir.toString())
- .put("gateway.type", "none").put("index.store.type", "memory")
+ .put("gateway.type", "none")
+ .put("index.store.type", "memory")
.put("index.number_of_shards", 1)
- .put("index.number_of_replicas", 1).build();
+ .put("index.number_of_replicas", 1)
+ .build();
log.info("-----------------------------------------------------------------------");
- log.info("Starting ElasticSearch embedded with settings: " + settings.getAsMap());
+ log.info("Starting ElasticSearch embedded with settings: \n" + settings.getAsMap() );
log.info("-----------------------------------------------------------------------");
- Node node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
+ Node node = NodeBuilder.nodeBuilder().settings(settings)
+ .clusterName( fig.getClusterName() ).node();
+
newClient = node.client();
- } else { // build client that connects to all hosts
+
+ } else { // build client that connects to all configured hosts
final String hosts = fig.getHosts();
+ String allHosts = "";
+ String SEP = "";
+ for (String host : fig.getHosts().split(",")) {
+ allHosts = SEP + host + ":" + fig.getPort();
+ SEP = ",";
+ }
+
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.ping_timeout", 2000) // milliseconds
- .put("client.transport.nodes_sampler_interval", 100).put("http.enabled", false)
+ .put("client.transport.nodes_sampler_interval", 100)
+ .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", hosts).build();
+ .put("discovery.zen.ping.unicast.hosts", allHosts)
+ .build();
+
+ log.info("Creating ElasticSearch client with settings: " + settings.getAsMap());
Node node = NodeBuilder.nodeBuilder().settings(settings)
.clusterName(fig.getClusterName())
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index cd3858c..5f2af18 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -17,587 +17,547 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>usergrid-rest</artifactId>
- <packaging>war</packaging>
- <name>Usergrid REST</name>
- <description>REST web services for Usergrid system.</description>
-
- <!-- Override these properties in an active profile within your settings.xml -->
- <properties>
- <!-- If you got the resources, max parallelism = 6 forks -->
- <rest.it.forkCount>3</rest.it.forkCount>
- <core.it.suite.concurrency>1</core.it.suite.concurrency>
- </properties>
-
- <profiles>
- <profile>
- <id>unit</id>
- <activation>
- <property>
- <name>unit</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
- <forkMode>once</forkMode>
- <!-- TODO: make this into a small configuration but based on settings.xml -->
- <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</argLine>
-
- <includes>
- <include>**/RestTestSuite.java</include>
- <include>**/*Test.java</include>
- </includes>
- <excludes>
- <exclude>**/*IT.java</exclude>
- <exclude>**/*ITSuite.java</exclude>
- <!-- TODO - add these suites too -->
- <!-- <exclude>**/*Test.java</exclude> -->
- <exclude>**/ConcurrentRest*Suite.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
-
- <parallel>classes</parallel>
- <forkCount>${rest.it.forkCount}</forkCount>
- <reuseForks>false</reuseForks>
- <perCoreThreadCount>false</perCoreThreadCount>
- <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
- </argLine>
-
- <includes>
- <include>**/RestTestSuite.java</include>
- <include>**/RestITSuite.java</include>
- <include>**/*IT.java</include>
- <include>**/*Test.java</include>
- </includes>
- <excludes>
- <exclude>**/*Concurrent*Suite.java</exclude>
- <exclude>**/ActivityResourceIT.java</exclude>
- <exclude>**/AdminEmailEncodingIT.java</exclude>
- <exclude>**/ApplicationRequestCounterIT.java</exclude>
- <exclude>**/AssetResourceIT.java</exclude>
- <exclude>**/BasicIT.java</exclude>
- <exclude>**/CollectionsResourceIT.java</exclude>
- <exclude>**/ContentTypeResourceIT.java</exclude>
- <exclude>**/DevicesResourceIT.java</exclude>
- <exclude>**/EventsResourceIT.java</exclude>
- <exclude>**/GroupResourceIT.java</exclude>
- <exclude>**/OrganizationResourceIT.java</exclude>
- <exclude>**/OrganizationsResourceIT.java</exclude>
- <exclude>**/OwnershipResourceIT.java</exclude>
- <exclude>**/PagingResourceIT.java</exclude>
- <exclude>**/PermissionsResourceIT.java</exclude>
- <exclude>**/UserResourceIT.java</exclude>
- <exclude>**/UsersOrganizationsResourceIT.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>scott</id>
- <activation>
- <property>
- <name>unit-concurrent</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
-
- <parallel>classes</parallel>
- <forkCount>${rest.it.forkCount}</forkCount>
- <reuseForks>false</reuseForks>
- <perCoreThreadCount>false</perCoreThreadCount>
- <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
- </argLine>
-
- <includes>
- <include>**/RestTestSuite.java</include>
- <include>**/RestITSuite.java</include>
- <include>**/ManagementResourceIT.java</include>
- <include>**/ApplicationResourceIT.java</include>
- </includes>
- <excludes>
- <exclude>**/*Test.java</exclude>
- <exclude>**/*Concurrent*Suite.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>unit-concurrent</id>
- <activation>
- <property>
- <name>unit-concurrent</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
- <forkMode>once</forkMode>
- <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</argLine>
-
- <includes>
- <include>**/ConcurrentRestTestSuite.java</include>
- </includes>
- <excludes>
- <exclude>**/*IT.java</exclude>
- <exclude>**/*Test.java</exclude>
- <exclude>**/RestITSuite.java</exclude>
- <exclude>**/RestTestSuite.java</exclude>
- <exclude>**/ConcurrentRestITSuite.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>integ-concurrent</id>
- <activation>
- <property>
- <name>integ-concurrent</name>
- <value>true</value>
- </property>
- </activation>
- <build>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>usergrid-rest</artifactId>
+ <packaging>war</packaging>
+ <name>Usergrid REST</name>
+ <description>REST web services for Usergrid system.</description>
+
+ <!-- Override these properties in an active profile within your settings.xml -->
+ <properties>
+ <!-- If you got the resources, max parallelism = 6 forks -->
+ <rest.it.forkCount>1</rest.it.forkCount>
+ <core.it.suite.concurrency>1</core.it.suite.concurrency>
+ </properties>
+
+ <profiles>
+
+<!-- <profile>
+ <id>unit</id>
+ <activation>
+ <property>
+ <name>unit</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+ <forkMode>once</forkMode>
+ TODO: make this into a small configuration but based on settings.xml
+ <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</argLine>
+
+ <includes>
+ <include>**/RestTestSuite.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*IT.java</exclude>
+ <exclude>**/*ITSuite.java</exclude>
+ TODO - add these suites too
+ <exclude>**/*Test.java</exclude>
+ <exclude>**/ConcurrentRest*Suite.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>-->
+
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+
+<!-- <parallel>classes</parallel>
+ <forkCount>${rest.it.forkCount}</forkCount>
+ <reuseForks>false</reuseForks>
+ <perCoreThreadCount>false</perCoreThreadCount>
+ <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
+ </argLine>-->
+
+ <includes>
+ <include>**/RestTestSuite.java</include>
+ <include>**/RestITSuite.java</include>
+ <include>**/*IT.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*Concurrent*Suite.java</exclude>
+ <exclude>**/ActivityResourceIT.java</exclude>
+ <exclude>**/AdminEmailEncodingIT.java</exclude>
+ <exclude>**/ApplicationRequestCounterIT.java</exclude>
+ <exclude>**/AssetResourceIT.java</exclude>
+ <exclude>**/BasicIT.java</exclude>
+ <exclude>**/CollectionsResourceIT.java</exclude>
+ <exclude>**/ContentTypeResourceIT.java</exclude>
+ <exclude>**/DevicesResourceIT.java</exclude>
+ <exclude>**/EventsResourceIT.java</exclude>
+ <exclude>**/GroupResourceIT.java</exclude>
+ <exclude>**/OrganizationResourceIT.java</exclude>
+ <exclude>**/OrganizationsResourceIT.java</exclude>
+ <exclude>**/OwnershipResourceIT.java</exclude>
+ <exclude>**/PagingResourceIT.java</exclude>
+ <exclude>**/PermissionsResourceIT.java</exclude>
+ <exclude>**/UserResourceIT.java</exclude>
+ <exclude>**/UsersOrganizationsResourceIT.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+<!-- <profile>
+ <id>unit-concurrent</id>
+ <activation>
+ <property>
+ <name>unit-concurrent</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+ <forkMode>once</forkMode>
+ <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</argLine>
+
+ <includes>
+ <include>**/ConcurrentRestTestSuite.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*IT.java</exclude>
+ <exclude>**/*Test.java</exclude>
+ <exclude>**/RestITSuite.java</exclude>
+ <exclude>**/RestTestSuite.java</exclude>
+ <exclude>**/ConcurrentRestITSuite.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>-->
+
+<!-- <profile>
+ <id>integ-concurrent</id>
+ <activation>
+ <property>
+ <name>integ-concurrent</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+ <forkMode>once</forkMode>
+ <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</argLine>
+
+ <includes>
+ <include>**/ConcurrentRestITSuite.java</include>
+ <include>**/LongRunningNotInSuiteIT.java</include>
+ an example
+ </includes>
+ <excludes>
+ <exclude>**/*IT.java</exclude>
+ <exclude>**/*Test.java</exclude>
+ <exclude>**/RestITSuite.java</exclude>
+ <exclude>**/RestTestSuite.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>-->
+
+ </profiles>
+
+ <build>
+ <finalName>ROOT</finalName>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.json</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ </testResources>
+
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
- <forkMode>once</forkMode>
- <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</argLine>
-
- <includes>
- <include>**/ConcurrentRestITSuite.java</include>
- <include>**/LongRunningNotInSuiteIT.java</include>
- <!-- an example -->
- </includes>
- <excludes>
- <exclude>**/*IT.java</exclude>
- <exclude>**/*Test.java</exclude>
- <exclude>**/RestITSuite.java</exclude>
- <exclude>**/RestTestSuite.java</exclude>
- </excludes>
- </configuration>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <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</argLine>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jasig.mojo.jspc</groupId>
+ <artifactId>jspc-maven-plugin</artifactId>
+ <version>2.0.0</version>
+ <configuration>
+ <includeInProject>false</includeInProject>
+ <webFragmentFile>${project.build.directory}/web-fragment.xml.txt</webFragmentFile>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jspc</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jasig.mojo.jspc</groupId>
+ <artifactId>jspc-compiler-tomcat6</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-a-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <classifier>classes</classifier>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jsp-jar-execution</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <classifier>compiled-jsp</classifier>
+ <classesDirectory>${project.build.directory}/jsp-source</classesDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.3.1</version>
+ <executions>
+ <execution>
+ <id>install jar</id>
+ <phase>install</phase>
+ <goals>
+ <goal>install-file</goal>
+ </goals>
+ <configuration>
+ <packaging>jar</packaging>
+ <artifactId>${project.artifactId}</artifactId>
+ <groupId>${project.groupId}</groupId>
+ <version>${project.version}</version>
+ <file>
+ ${project.build.directory}/${project.artifactId}-${project.version}.jar
+ </file>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
- </build>
- </profile>
- </profiles>
-
- <build>
- <finalName>ROOT</finalName>
-
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.json</include>
- </includes>
- </resource>
- </resources>
-
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <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</argLine>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.3</version>
- </plugin>
-
- <plugin>
- <groupId>org.jasig.mojo.jspc</groupId>
- <artifactId>jspc-maven-plugin</artifactId>
- <version>2.0.0</version>
- <configuration>
- <includeInProject>false</includeInProject>
- <webFragmentFile>${project.build.directory}/web-fragment.xml.txt</webFragmentFile>
- </configuration>
- <executions>
- <execution>
- <id>jspc</id>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.jasig.mojo.jspc</groupId>
- <artifactId>jspc-compiler-tomcat6</artifactId>
- <version>2.0.0</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <finalName>${project.artifactId}-${project.version}</finalName>
- </configuration>
- <executions>
- <execution>
- <id>make-a-jar</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <classifier>classes</classifier>
- </configuration>
- </execution>
- <execution>
- <id>jsp-jar-execution</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <classifier>compiled-jsp</classifier>
- <classesDirectory>${project.build.directory}/jsp-source</classesDirectory>
- </configuration>
- </execution>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.3.1</version>
- <executions>
- <execution>
- <id>install jar</id>
- <phase>install</phase>
- <goals>
- <goal>install-file</goal>
- </goals>
- <configuration>
- <packaging>jar</packaging>
- <artifactId>${project.artifactId}</artifactId>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <file>
- ${project.build.directory}/${project.artifactId}-${project.version}.jar
- </file>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <!-- Usergrid Dependencies -->
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-config</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-core</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>commons-logging</artifactId>
- <groupId>commons-logging</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-mongo-emulator</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Apache Dependencies -->
-
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
-
- <!-- SUN, Javax Package, and Other Com Dependencies -->
-
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- </dependency>
-
-
- <dependency>
- <groupId>com.sun.jersey.contribs</groupId>
- <artifactId>jersey-multipart</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>2.3.1</version>
- </dependency>
-
- <dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-spring</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- </dependency>
-
- <dependency>
- <groupId>net.tanesha.recaptcha4j</groupId>
- <artifactId>recaptcha4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey.contribs</groupId>
- <artifactId>jersey-spring</artifactId>
- </dependency>
-
- <!-- Codehaus, Spring, and Other Org Dependencies -->
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </dependency>
-
- <dependency>
- <!-- TODO - should not scope be 'test' ? -->
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
-
- <dependency>
- <!-- TODO - should not scope be 'test' ? -->
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
-
- <!-- Testing and Logging Dependencies -->
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-config</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jvnet.mock-javamail</groupId>
- <artifactId>mock-javamail</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hectorclient</groupId>
- <artifactId>hector-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jasper-el</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jsp-api</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>juli</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- use the external test client. Just depend on the maven jetty plugin to launch jetty -->
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-external</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.sun.jersey.jersey-test-framework</groupId>
- <artifactId>jersey-test-framework-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-java-client</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-services</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- </dependencies>
+ </build>
+
+ <dependencies>
+
+ <!-- Usergrid Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-core</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-mongo-emulator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Apache Dependencies -->
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <!-- SUN, Javax Package, and Other Com Dependencies -->
+
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>net.tanesha.recaptcha4j</groupId>
+ <artifactId>recaptcha4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-spring</artifactId>
+ </dependency>
+
+ <!-- Codehaus, Spring, and Other Org Dependencies -->
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- TODO - should not scope be 'test' ? -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- TODO - should not scope be 'test' ? -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ </dependency>
+
+ <!-- Testing and Logging Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-config</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jvnet.mock-javamail</groupId>
+ <artifactId>mock-javamail</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hectorclient</groupId>
+ <artifactId>hector-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper-el</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jsp-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>juli</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- use the external test client. Just depend on the maven jetty plugin to launch jetty -->
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-external</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-java-client</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-services</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ </dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index c2df2e3..dd7db4d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -37,7 +37,6 @@ import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
-import org.apache.usergrid.cassandra.Concurrent;
import org.apache.usergrid.java.client.Client;
import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
import static org.apache.usergrid.utils.MapUtils.hashMap;
@@ -56,7 +55,7 @@ import org.slf4j.LoggerFactory;
* method(s) should following the following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
* failure condition if multiple]
*/
-@Concurrent()
+//@Concurrent()
public abstract class AbstractRestIT extends JerseyTest {
private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
private static boolean usersSetup = false;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index aa7aef8..3e997c7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -37,8 +37,6 @@ import org.apache.usergrid.services.ServiceManagerFactory;
/** A {@link org.junit.rules.TestRule} that sets up services. */
public class ITSetup extends ExternalResource {
-
-
private static final Logger LOG = LoggerFactory.getLogger( ITSetup.class );
private final CassandraResource cassandraResource;
private final TomcatResource tomcatResource;
@@ -81,12 +79,15 @@ public class ITSetup extends ExternalResource {
setupCalled = true;
}
+ emf = cassandraResource.getBean( EntityManagerFactory.class );
+ smf = cassandraResource.getBean( ServiceManagerFactory.class );
+ properties = cassandraResource.getBean( "properties", Properties.class );
+ tokenService = cassandraResource.getBean( TokenService.class );
+ providerFactory = cassandraResource.getBean( SignInProviderFactory.class );
applicationCreator = cassandraResource.getBean( ApplicationCreator.class );
- emf = cassandraResource.getBean( EntityManagerFactory.class );
- tokenService = cassandraResource.getBean( TokenService.class );
- providerFactory = cassandraResource.getBean( SignInProviderFactory.class );
- properties = cassandraResource.getBean( "properties", Properties.class );
- smf = cassandraResource.getBean( ServiceManagerFactory.class );
+
+ tomcatResource.setCassandraPort( cassandraResource.getRpcPort() );
+ tomcatResource.setElasticSearchPort( Integer.parseInt( System.getProperty("EMBEDDED_ES_PORT")) );
tomcatResource.before();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/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 a0f3f26..3f85652 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
@@ -16,70 +16,207 @@
*/
package org.apache.usergrid.rest;
-
import java.io.File;
import org.junit.rules.ExternalResource;
import org.apache.usergrid.cassandra.AvailablePortFinder;
-import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang.math.RandomUtils;
-import com.google.common.io.Files;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import java.io.BufferedReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/** @author tnine */
+/**
+ * Setup Tomcat to run Usergrid from src/main/webapps plus inherited (Maven) classpath.
+ * Caller must provide Cassandra and ElasticSearch ports.
+ * Generates Usergrid properties files.
+ */
public class TomcatResource extends ExternalResource {
-
- private static final Logger log = LoggerFactory.getLogger( TomcatResource.class );
+ private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
public static final TomcatResource instance = new TomcatResource();
- private static Object mutex = new Object();
- private static final String CONTEXT = "/";
+ private static final Object mutex = new Object();
private String webAppsPath;
private int port;
- private Tomcat tomcat;
+ private int esPort;
+ private int cassPort;
+ private boolean started = false;
- protected TomcatResource(){
- }
+ Process process = null;
+
+ protected TomcatResource() {}
+
+ @Override
+ protected void after() {
+ // TODO: need something better than this, see also TomcatMain.
+ process.destroy();
+ }
+
@Override
protected void before() throws Throwable {
- if ( tomcat != null ) {
+
+ if (started) {
return;
}
- synchronized ( mutex ) {
- //second into mutex
- if ( tomcat != null ) {
+ synchronized (mutex) {
+
+ if (started) {
return;
}
- File dataDir = Files.createTempDir();
- dataDir.deleteOnExit();
+ port = AvailablePortFinder.getNextAvailable(9998 + RandomUtils.nextInt(10));
+
+ String propDirPath = createPropDir();
+
+ createPropertyFiles( propDirPath );
+
+ process = startTomcatProcess( propDirPath );
+
+ waitForTomcat();
+
+ started = true;
+ }
+ }
+
+ private String createPropDir() {
+ String propDirName = "target" + File.separator + "tomcat_" + port;
+ File newDir = new File( propDirName );
+ newDir.mkdirs();
+ String propDirPath = newDir.getAbsolutePath();
+ return propDirPath;
+ }
+
+ private void waitForTomcat() throws RuntimeException {
+ int count = 0;
+ while (count++ < 60) {
+ try {
+ Thread.sleep(1000);
+ Client c = Client.create();
+ WebResource wr = c.resource("http://localhost:" + port + "/status");
+ wr.get(String.class);
+ log.info("Tomcat is started.");
+ break;
+
+ } catch (Exception e) {
+ log.info("Cannot connect: " + e.getMessage());
+ }
+ throw new RuntimeException("Tomcat process never started.");
+ }
+ }
+
+ private Process startTomcatProcess( String propDirPath ) throws IOException {
- port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt(10) );
+ String javaHome = (String)System.getenv("JAVA_HOME");
- tomcat = new Tomcat();
- tomcat.setBaseDir( dataDir.getAbsolutePath() );
- tomcat.setPort( port );
- tomcat.addWebapp( CONTEXT, new File( getWebAppsPath() ).getAbsolutePath() );
+ ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/java",
+ "org.apache.usergrid.TomcatMain", "src/main/webapp", port + "");
- log.info("-----------------------------------------------------------------");
- log.info("Starting Tomcat port {} dir {}", port, dataDir.getAbsolutePath());
- log.info("-----------------------------------------------------------------");
- tomcat.start();
+ // ensure Tomcat gets same classpath we have
+ String classpath = System.getProperty("java.class.path");
+ List<String> path = new ArrayList<String>();
+ String parts[] = classpath.split( File.pathSeparator );
+ for ( String part : parts ) {
+ if ( part.endsWith("test-classes") ) {
+ continue;
+ }
+ path.add(part);
}
+ // plus our special properties directory
+ path.add( propDirPath );
+ String newClasspath = StringUtils.join( path, File.pathSeparator );
+
+ Map<String, String> env = pb.environment();
+ StringBuilder sb = new StringBuilder();
+ sb.append( newClasspath );
+ env.put("CLASSPATH", sb.toString());
+
+ //pb.directory(new File("."));
+ pb.redirectErrorStream(true);
+
+ final Process p = pb.start();
+
+ log.debug("Started Tomcat process with classpath = " + newClasspath );
+
+ // use thread to log Tomcat output
+ new Thread( new Runnable() {
+ @Override
+ public void run() {
+ BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line = null;
+ try {
+ while ((line = br.readLine()) != null) {
+ log.info(line);
+ }
+ } catch (IOException ex) {
+ log.error("Error reading from Tomcat process", ex);
+ return;
+ }
+ }
+ }).start();
+
+ return p;
}
+ private void createPropertyFiles( String propDirPath ) throws IOException {
+
+ PrintWriter pw = new PrintWriter(
+ new FileWriter( propDirPath + File.separator + "usergrid-custom.properties"));
+
+ pw.println("cassandra.url=localhost:" + cassPort);
+ pw.println("usergrid.mongo.disable=true");
+ pw.println("swagger.basepath=http://sometestvalue");
+ pw.println("usergrid.counter.batch.size=1");
+ pw.println("usergrid.test=true");
+ pw.println("usergrid.sysadmin.login.name=superuser");
+ 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");
+ pw.println("cassandra.timeout=5000");
+
+ pw.println("collections.keyspace=Usergrid_Applications");
+ pw.println("collections.keyspace.strategy.options=replication_factor:1");
+ pw.println("collections.keyspace.strategy.class=org.apache.cassandra.locator.SimpleStrategy");
+ pw.println("collection.stage.transient.timeout=6");
+
+ pw.println("elasticsearch.hosts=127.0.0.1");
+ pw.println("elasticsearch.port=" + esPort);
+ pw.println("elasticsearch.cluster_name=usergrid_test");
+ pw.println("elasticsearch.index_prefix=usergrid");
+
+ pw.println("index.query.limit.default=1000");
+ pw.flush();
+ pw.close();
+ }
/**
- * Get the port tomcat runs on
- * @return
+ * Get the port Tomcat runs on.
*/
- public int getPort(){
+ public int getPort() {
return port;
}
@@ -90,4 +227,12 @@ public class TomcatResource extends ExternalResource {
public void setWebAppsPath(String webAppsPath) {
this.webAppsPath = webAppsPath;
}
+
+ void setCassandraPort(int cassPort) {
+ this.cassPort = cassPort;
+ }
+
+ void setElasticSearchPort(int esPort) {
+ this.esPort = esPort;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/stack/test-utils/pom.xml
----------------------------------------------------------------------
diff --git a/stack/test-utils/pom.xml b/stack/test-utils/pom.xml
index 18a1d9c..e3b228c 100644
--- a/stack/test-utils/pom.xml
+++ b/stack/test-utils/pom.xml
@@ -17,235 +17,247 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>usergrid-test-utils</artifactId>
- <name>Usergrid Test Utils</name>
- <description>Test Utilities for Usergrid system.</description>
- <packaging>jar</packaging>
-
- <build>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
-
- <configuration>
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target-directory>${project.build.directory}</target-directory>
- </systemPropertyVariables>
- <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</argLine>
-
- <includes>
- <include>**/CassandraResourceITSuite.java</include>
- <!-- <include>**/CassandraResourceTest.java</include>-->
- </includes>
- <excludes>
- <exclude>**/CassandraRunnerTest.java</exclude>
- <exclude>**/OtherRunnerTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid-config</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Apache Dependencies -->
-
- <dependency>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- <!-- Exclude the old and problematic Snappy -->
- <exclusions>
- <exclusion>
- <artifactId>snappy-java</artifactId>
- <groupId>org.xerial.snappy</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Include the slighly newer and less problematic snappy -->
- <dependency>
- <artifactId>snappy-java</artifactId>
- <groupId>org.xerial.snappy</groupId>
- <version>1.0.5</version>
- </dependency>
-
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr-runtime</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-thrift</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-spring</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- </dependency>
-
- <!-- Spring and Other Dependencies -->
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>commons-logging</artifactId>
- <groupId>commons-logging</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <!-- TODO - should not scope be 'test' ? -->
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
-
- <dependency>
- <!-- TODO - should not scope be 'test' ? -->
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit-dep</artifactId>
- </dependency>
-
- <!-- Test Dependencies -->
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.9</version>
- <type>jar</type>
- </dependency>
-
- </dependencies>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>usergrid-test-utils</artifactId>
+ <name>Usergrid Test Utils</name>
+ <description>Test Utilities for Usergrid system.</description>
+ <packaging>jar</packaging>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+
+ <configuration>
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target-directory>${project.build.directory}</target-directory>
+ </systemPropertyVariables>
+ <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</argLine>
+
+ <includes>
+ <include>**/CassandraResourceITSuite.java</include>
+ <!-- <include>**/CassandraResourceTest.java</include>-->
+ </includes>
+ <excludes>
+ <exclude>**/CassandraRunnerTest.java</exclude>
+ <exclude>**/OtherRunnerTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>usergrid-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Apache Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-all</artifactId>
+ <!-- Exclude the old and problematic Snappy -->
+ <exclusions>
+ <exclusion>
+ <artifactId>snappy-java</artifactId>
+ <groupId>org.xerial.snappy</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Include the slighly newer and less problematic snappy -->
+ <dependency>
+ <artifactId>snappy-java</artifactId>
+ <groupId>org.xerial.snappy</groupId>
+ <version>1.0.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-thrift</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.yammer.metrics</groupId>
+ <artifactId>metrics-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shiro</groupId>
+ <artifactId>shiro-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </dependency>
+
+ <!-- Spring and Other Dependencies -->
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- TODO - should not scope be 'test' ? -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- TODO - should not scope be 'test' ? -->
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ </dependency>
+
+ <!-- Test Dependencies -->
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.9.9</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ <version>7.0.47</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>7.0.47</version>
+ </dependency>
+
+ </dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5194e7c/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
new file mode 100644
index 0000000..4fe08e5
--- /dev/null
+++ b/stack/test-utils/src/main/java/org/apache/usergrid/TomcatMain.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.usergrid;
+
+import com.google.common.io.Files;
+import java.io.File;
+import org.apache.catalina.startup.Tomcat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Simple wrapper for starting "embedded" Tomcat as it's own process, for testing.
+ */
+public class TomcatMain {
+
+ private static final Logger log = LoggerFactory.getLogger( TomcatMain.class );
+
+ public static void main(String[] args) throws Exception {
+
+ String webappsPath = args[0];
+ int port = Integer.parseInt( args[1] );
+
+ File dataDir = Files.createTempDir();
+ dataDir.deleteOnExit();
+
+ Tomcat tomcat = new Tomcat();
+ tomcat.setBaseDir(dataDir.getAbsolutePath());
+ tomcat.setPort(port);
+ tomcat.addWebapp("/", new File(webappsPath).getAbsolutePath());
+
+ log.info("-----------------------------------------------------------------");
+ log.info("Starting Tomcat port {} dir {}", port, webappsPath);
+ log.info("-----------------------------------------------------------------");
+ tomcat.start();
+
+ // TODO: figure out how to stop of this process at end of testing.
+ while ( true ) {
+ Thread.sleep(1000);
+ }
+ }
+
+}