Skip to content

Commit

Permalink
Support "mvn test"
Browse files Browse the repository at this point in the history
- Lets maven run OpenTSDB unit tests.
Modifies pom.xml.in to configure the surefire plugin properly. Also creates
plugin_test.jar that some unit tests depend on.

- Makes it easy to use Eclipse.
The steps for OSX will be:
   0. Install OSX autoconf
     port install automake autoconf libtool
   1. Generate pom.xml and the Eclipse-friendly directory structure overlay
     ./build.sh pom.xml
   2. Build the maven project
     mvn clean compile
   3. Import the Maven project into Eclipse.
   4. Include target/generated-sources in Eclipse source path.

- Added some file extensions and working files to .gitignore.

NOTE: Submitted on behalf of third-party contributors:
 * Guenther Schmuelling <schmuell@pepperdata.com>
 * Kimoon Kim <kimoon@pepperdata.com>

Signed-off-by: Chris Larsen <clarsen@euphoriaaudio.com>
  • Loading branch information
jesse5e authored and manolama committed Apr 10, 2014
1 parent e3be594 commit c221520
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 17 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,32 @@ config.log
config.status
configure
pom.xml
*.pyc
.*.swp
*.rrd
*.class
*/target/*
*.orig
*.log

#for Intellij
\.idea
*.iml

#for guava rpm maker
guava-rpm-maker/\.project

# for mac finder
.DS_Store

# for eclipse
.pydevproject
.metadata
.project
.classpath
.settings

# maven
src-main
src-test
plugin_test.jar
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ distclean-local:
rm -rf $(srcdir)/target

pom.xml: pom.xml.in Makefile
(cd $(top_srcdir) ; ./build-aux/create-src-dir-overlay.sh)
{ \
echo '<!-- Generated by Makefile on '`date`' -->'; \
sed <$< \
Expand Down
17 changes: 17 additions & 0 deletions build-aux/create-src-dir-overlay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Creates directory structure overlay on top of original source directories so
# that the overlay matches Java package hierarchy.
#!/bin/bash

if [ ! -d src-main ]; then
mkdir src-main
mkdir src-main/net
mkdir src-main/tsd
(cd src-main/net && ln -s ../../src opentsdb)
(cd src-main/tsd && ln -s ../../src/tsd/QueryUi.gwt.xml QueryUi.gwt.xml)
(cd src-main/tsd && ln -s ../../src/tsd/client client)
fi
if [ ! -d src-test ]; then
mkdir src-test
mkdir src-test/net
(cd src-test/net && ln -s ../../test opentsdb)
fi
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ fi
TSDB_FIND_PROG([java])
TSDB_FIND_PROG([javac])
TSDB_FIND_PROG([jar])
TSDB_FIND_PROG([gnuplot])
# Mac OS does not have gnuplot. Falls back to /usr/bin/true to make gnuplot
# optional.
TSDB_FIND_PROG([gnuplot], [true])
AC_PATH_PROG([JAVADOC], [javadoc], [])
AM_MISSING_PROG([JAVADOC], [javadoc])

Expand Down
85 changes: 69 additions & 16 deletions pom.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
<packaging>jar</packaging>

<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<sourceDirectory>src-main</sourceDirectory>
<testSourceDirectory>src-test</testSourceDirectory>

<plugins>

Expand All @@ -74,12 +74,8 @@
<target>1.6</target>
<compilerArgument>-Xlint</compilerArgument>
<excludes>
<exclude>**/Test*.java</exclude>
<exclude>**/client/*.java</exclude>
</excludes>
<testIncludes>
<include>**/Test*.java</include>
</testIncludes>
</configuration>
</plugin>

Expand All @@ -89,21 +85,71 @@
<version>1.2.1</version>
<executions>
<execution>
<id>generate-build-data</id>
<configuration>
<executable>build-aux/gen_build_data.sh</executable>
<!-- optional -->
<arguments>
<argument>target/generated-sources/net/opentsdb/BuildData.java</argument>
<argument>net.opentsdb</argument>
<argument>BuildData</argument>
</arguments>
</configuration>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>create-plugin-test-jar</id>
<!-- TODO: Put the jar in the target dir and fix surefire conf. -->
<configuration>
<executable>jar</executable>
<arguments>
<argument>cvfm</argument>
<argument>plugin_test.jar</argument>
<argument>test/META-INF/MANIFEST.MF</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/plugin/DummyPluginA.class</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/plugin/DummyPluginB.class</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/search/DummySearchPlugin.class</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/tsd/DummyHttpSerializer.class</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/tsd/DummyRpcPlugin.class</argument>
<argument>-C</argument>
<argument>target/test-classes</argument>
<argument>net/opentsdb/tsd/DummyRTPublisher.class</argument>
<argument>-C</argument>
<argument>test</argument>
<argument>META-INF/services/net.opentsdb.plugin.DummyPlugin</argument>
<argument>-C</argument>
<argument>test</argument>
<argument>META-INF/services/net.opentsdb.search.SearchPlugin</argument>
<argument>-C</argument>
<argument>test</argument>
<argument>META-INF/services/net.opentsdb.tsd.HttpSerializer</argument>
<argument>-C</argument>
<argument>test</argument>
<argument>META-INF/services/net.opentsdb.tsd.RpcPlugin</argument>
<argument>-C</argument>
<argument>test</argument>
<argument>META-INF/services/net.opentsdb.tsd.RTPublisher</argument>
</arguments>
</configuration>
<phase>test-compile</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>build-aux/gen_build_data.sh</executable>
<!-- optional -->
<arguments>
<argument>target/generated-sources/net/opentsdb/BuildData.java</argument>
<argument>net.opentsdb</argument>
<argument>BuildData</argument>
</arguments>
</configuration>
</plugin>

<plugin>
Expand Down Expand Up @@ -149,7 +195,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<version>2.16</version>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<parallel>classes</parallel>
<threadCount>2</threadCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>

<plugin>
Expand Down

0 comments on commit c221520

Please sign in to comment.