Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
add profile to functional-test to run against wildfly 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Sep 15, 2014
1 parent 2ef538c commit e83adb0
Show file tree
Hide file tree
Showing 4 changed files with 661 additions and 65 deletions.
199 changes: 135 additions & 64 deletions functional-test/pom.xml
Expand Up @@ -64,6 +64,10 @@
<hibernate.search.default.indexBase>${project.build.directory}/zanataindex</hibernate.search.default.indexBase>
<javamelody.storage-directory>${project.build.directory}/zanatastats</javamelody.storage-directory>
<smtp.port>2552</smtp.port>
<jndi-remote-client.groupId>org.jboss.as</jndi-remote-client.groupId>
<jndi-remote-client.artifactId>jboss-as-ejb-client-bom</jndi-remote-client.artifactId>
<jndi-remote-client.version>7.1.1.Final</jndi-remote-client.version>
<standalone.xml.file>standalone.xml</standalone.xml.file>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -268,9 +272,9 @@

<!-- For remote JNDI lookup -->
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<version>7.1.1.Final</version>
<groupId>${jndi-remote-client.groupId}</groupId>
<artifactId>${jndi-remote-client.artifactId}</artifactId>
<version>${jndi-remote-client.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
Expand All @@ -291,9 +295,68 @@
<artifactId>joda-time</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>

<profiles>
<profile>
<id>wildfly</id>
<activation>
<property>
<name>wildfly</name>
</property>
</activation>
<properties>
<wildfly.version>8.1.0.Final</wildfly.version>
<cargo.container>wildfly8x</cargo.container>
<cargo.installation>http://download.jboss.org/wildfly/${wildfly.version}/wildfly-${wildfly.version}.zip</cargo.installation>
<standalone.xml.file>standalone_wildfly.xml</standalone.xml.file>
<jndi-remote-client.groupId>org.wildfly</jndi-remote-client.groupId>
<jndi-remote-client.artifactId>wildfly-ejb-client-bom</jndi-remote-client.artifactId>
<jndi-remote-client.version>${wildfly.version}</jndi-remote-client.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration combine.self="append">
</configuration>
<executions>
<execution>
<id>cargo-install</id>
<phase>prepare-package</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>unpack-wildfly-modules</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${pom.basedir}/src/etc/wildflyModules.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-functional-test</id>
<activation>
Expand Down Expand Up @@ -403,86 +466,27 @@
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<configuration>
<configuration combine.self="append">
<container>
<containerId>${cargo.container}</containerId>
<type>installed</type>

<!--if install from url-->
<zipUrlInstaller>
<url>${cargo.installation}</url>
<downloadDir>${user.home}/Downloads</downloadDir>
<extractDir>${cargo.extract.dir}</extractDir>
</zipUrlInstaller>

<output>${project.build.directory}/container.log</output>
<append>false</append>
<log>${project.build.directory}/cargo.log</log>

<systemProperties>
<ehcache.disk.store.dir>${project.build.directory}/ehcache</ehcache.disk.store.dir>
<jboss.server.log.threshold>WARN</jboss.server.log.threshold>
<hibernate.search.default.indexBase>${hibernate.search.default.indexBase}</hibernate.search.default.indexBase>
<javamelody.storage-directory>${javamelody.storage-directory}</javamelody.storage-directory>
<jboss.socket.binding.port-offset>${cargo.port.offset}</jboss.socket.binding.port-offset>
</systemProperties>

<timeout>0</timeout>
</container>

<deployables>
<deployable>
<type>war</type>
<location>${project.basedir}/../zanata-test-war/target/${zanata.test.war.name}.war</location>
<pingURL>http://${cargo.host}:${cargo.servlet.port}/${context.path}/</pingURL>
<pingTimeout>180000</pingTimeout>
<pingTimeout>300000</pingTimeout>
<properties>
<context>${context.path}</context>
</properties>
</deployable>

</deployables>

<configuration>
<type>standalone</type>
<home>${cargo.container.home}</home>

<configfiles>
<configfile>
<file>${project.build.testOutputDirectory}/datasource/zanata-ds.xml</file>
<todir>deployments</todir>
</configfile>
<!-- see above zipUrlInstaller/extractDir-->
<!-- cargo will force todir and tofile to be relative to container home directory -->

<!-- security and jndi for properties -->
<configfile>
<file>${project.build.testOutputDirectory}/conf/standalone.xml</file>
<todir>configuration</todir>
</configfile>

</configfiles>

<files>
<file>
<file>${settings.localRepository}/${jdbc.groupId}/${jdbc.artifactId}/${jdbc.version}/${jdbc.artifactId}-${jdbc.version}.jar</file>
<tofile>deployments/${jdbc.artifactId}.jar</tofile>
</file>
</files>

<properties>
<cargo.jboss.configuration>standalone</cargo.jboss.configuration>
<cargo.jvmargs>
<!-- NB: JDom parser doesn't like comments starting with '-' -->
-XX:PermSize=512m -XX:MaxPermSize=1024
-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
${cargo.debug.jvm.args}
</cargo.jvmargs>
<cargo.port.offset>${cargo.port.offset}</cargo.port.offset>
<cargo.jboss.ajp.port>8109</cargo.jboss.ajp.port>
</properties>
</configuration>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -660,6 +664,73 @@
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<!-- this plugin configuration is shared by two profiles: functional-test and wildfly -->
<configuration>
<container>
<containerId>${cargo.container}</containerId>
<type>installed</type>

<output>${project.build.directory}/container.log</output>
<append>false</append>
<log>${project.build.directory}/cargo.log</log>

<systemProperties>
<ehcache.disk.store.dir>${project.build.directory}/ehcache</ehcache.disk.store.dir>
<jboss.server.log.threshold>WARN</jboss.server.log.threshold>
<hibernate.search.default.indexBase>${hibernate.search.default.indexBase}</hibernate.search.default.indexBase>
<javamelody.storage-directory>${javamelody.storage-directory}</javamelody.storage-directory>
<jboss.socket.binding.port-offset>${cargo.port.offset}</jboss.socket.binding.port-offset>
</systemProperties>

<timeout>0</timeout>
</container>

<configuration>
<type>standalone</type>
<home>${cargo.container.home}</home>

<configfiles>
<configfile>
<file>${project.build.testOutputDirectory}/datasource/zanata-ds.xml</file>
<todir>deployments</todir>
</configfile>
<!-- see above zipUrlInstaller/extractDir-->
<!-- cargo will force todir and tofile to be relative to container home directory -->

<!-- security and jndi for properties -->
<configfile>
<file>${project.build.testOutputDirectory}/conf/${standalone.xml.file}</file>
<tofile>configuration/standalone.xml</tofile>
</configfile>

</configfiles>

<files>
<file>
<file>${settings.localRepository}/${jdbc.groupId}/${jdbc.artifactId}/${jdbc.version}/${jdbc.artifactId}-${jdbc.version}.jar</file>
<tofile>deployments/${jdbc.artifactId}.jar</tofile>
</file>
</files>

<properties>
<cargo.jboss.configuration>standalone</cargo.jboss.configuration>
<cargo.jvmargs>
<!-- NB: JDom parser doesn't like comments starting with '-' -->
-XX:PermSize=512m -XX:MaxPermSize=1024
-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
${cargo.debug.jvm.args}
</cargo.jvmargs>
<cargo.port.offset>${cargo.port.offset}</cargo.port.offset>
<cargo.jboss.ajp.port>8109</cargo.jboss.ajp.port>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
51 changes: 51 additions & 0 deletions functional-test/src/etc/wildflyModules.groovy
@@ -0,0 +1,51 @@

def download(String address, File destFile) {
def file = new FileOutputStream(destFile)
def out = new BufferedOutputStream(file)
out << new URL(address).openStream()
out.close()
}

def mojarraUrl = "http://sourceforge.net/projects/zanata/files/wildfly/wildfly-8.1.0.Final-module-mojarra-2.1.28.zip/download"
def hibernateUrl = "http://sourceforge.net/projects/zanata/files/wildfly/wildfly-8.1.0.Final-module-hibernate-main-4.2.15.Final.zip/download"

File mojarraZip = new File(project.build.directory, "mojarra.zip")
File hibernateZip = new File(project.build.directory, "hibernate.zip")

download(mojarraUrl, mojarraZip)
download(hibernateUrl, hibernateZip)


def ant = new AntBuilder()

def mojarraModuleDest = project.build.directory + "/mojarra"
ant.unzip(src: mojarraZip.absolutePath, dest: mojarraModuleDest, overwrite: "true" )
def hibernateModuleDest = project.build.directory + "/hibernate"
ant.unzip(src: hibernateZip.absolutePath, dest: hibernateModuleDest, overwrite: "true" )

File wildFlyInstallRoot = new File(project.properties['cargo.extract.dir'])
def dirFilter = {
it.isDirectory();
} as FileFilter

def listSubDirs = { File it ->
it.listFiles(dirFilter)
}

def subDirs = listSubDirs(wildFlyInstallRoot)
File wildFlyRoot;
while (subDirs.size() == 1) {
wildFlyRoot = subDirs[0]
subDirs = listSubDirs(wildFlyRoot)
}

assert wildFlyRoot != null
println "Wild Fly root is at $wildFlyRoot"

ant.copy(todir: wildFlyRoot, overwrite: true) {
fileset(dir: mojarraModuleDest)
}

ant.copy(todir: wildFlyRoot, overwrite: true) {
fileset(dir: hibernateModuleDest)
}
Expand Up @@ -10,6 +10,7 @@
import javax.naming.NamingException;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;

/**
Expand Down Expand Up @@ -39,6 +40,7 @@ public static void resetFileData() {
public static String getDocumentStoragePath() {
if (storagePath == null) {
final Properties env = new Properties();
// env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.put(Context.INITIAL_CONTEXT_FACTORY,
org.jboss.naming.remote.client.InitialContextFactory.class
.getName());
Expand All @@ -54,7 +56,25 @@ public static String getDocumentStoragePath() {
.lookup("zanata/files/document-storage-directory");
}
catch (NamingException e) {
throw Throwables.propagate(e);
try {
// wildfly uses 'http-remoting:' not 'remote:'
rmiPort = 8080+portOffset;
env.put(Context.PROVIDER_URL, "http-remoting://localhost:" + rmiPort);
remoteContext = new InitialContext(env);
storagePath =
(String) remoteContext
.lookup("zanata/files/document-storage-directory");
} catch (NamingException e1) {
// fall back option:
URL testClassRoot =
Thread.currentThread().getContextClassLoader()
.getResource("setup.properties");
File targetDir =
new File(testClassRoot.getPath()).getParentFile();
storagePath =
new File(targetDir, "zanata-documents")
.getAbsolutePath();
}
}
}
return storagePath;
Expand Down

0 comments on commit e83adb0

Please sign in to comment.