Skip to content

Commit

Permalink
Add cross version test for ml.dmlc.xgboost4j
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Apr 24, 2019
1 parent 66c76ee commit 0d7e3b6
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 8 deletions.
22 changes: 16 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pipeline {
'build-gpu-cuda8.0': { BuildCUDA(cuda_version: '8.0') },
'build-gpu-cuda9.2': { BuildCUDA(cuda_version: '9.2') },
'build-gpu-cuda10.0': { BuildCUDA(cuda_version: '10.0') },
'build-jvm-spark2.4.1': { BuildJVMSpark(spark_version: '2.4.1') },
'build-jvm-packages': { BuildJVMPackages(spark_version: '2.4.1') },
'build-jvm-doc': { BuildJVMDoc() }
])
}
Expand All @@ -76,7 +76,8 @@ pipeline {
'test-python-gpu-cuda10.0': { TestPythonGPU(cuda_version: '10.0') },
'test-cpp-gpu': { TestCppGPU(cuda_version: '10.0') },
'test-cpp-mgpu': { TestCppGPU(cuda_version: '10.0', multi_gpu: true) },
'test-jvm-test': { TestJVM() },
'test-jvm-jdk8': { CrossTestJVMwithJDK(jdk_version: '8') },
'test-jvm-jdk11': { CrossTestJVMwithJDK(jdk_version: '11') },
'test-r-3.4.4': { TestR(r_version: '3.4.4') },
'test-r-3.5.3': { TestR(r_version: '3.5.3') }
])
Expand Down Expand Up @@ -164,14 +165,16 @@ def BuildCUDA(args) {
}
}

def BuildJVMSpark(args) {
def BuildJVMPackages(args) {
node('linux && cpu') {
echo "Build XGBoost4J-Spark with Spark ${args.spark_version}"
container_type = "jvm"
docker_binary = "docker"
sh """
${dockerRun} ${container_type} ${docker_binary} tests/ci_build/build_jvm_packages.sh
"""
echo 'Stashing XGBoost4J JAR...'
stash name: 'xgboost4j_jar', includes: 'jvm-packages/xgboost4j/target/*.jar'
}
}

Expand All @@ -185,7 +188,7 @@ def BuildJVMDoc() {
${dockerRun} ${container_type} ${docker_binary} tests/ci_build/build_jvm_doc.sh ${BRANCH_NAME}
"""
archiveArtifacts artifacts: "jvm-packages/${BRANCH_NAME}.tar.bz2", allowEmptyArchive: true
echo 'Deploying doc...'
echo 'Uploading doc...'
s3Upload file: "jvm-packages/${BRANCH_NAME}.tar.bz2", bucket: 'xgboost-docs', acl: 'PublicRead', path: "${BRANCH_NAME}.tar.bz2"
}
}
Expand All @@ -211,9 +214,16 @@ def TestCppGPU(args) {
}
}

def TestJVM() {
def CrossTestJVMwithJDK(args) {
node('linux && cpu') {
echo "Test JVM packages"
unstash name: 'xgboost4j_jar'
echo "Test XGBoost4J on a machine with JDK ${args.jdk_version}"
container_type = "jvm_cross"
docker_binary = "docker"
docker_args = "--build-arg JDK_VERSION=${args.jdk_version}"
sh """
${dockerRun} ${container_type} ${docker_binary} ${docker_args} tests/ci_build/test_jvm_cross.sh
"""
}
}

Expand Down
150 changes: 150 additions & 0 deletions jvm-packages/xgboost4j-tester/generate_pom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import sys

pom_template = """
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ml.dmlc</groupId>
<artifactId>xgboost4j-tester</artifactId>
<version>1.0-SNAPSHOT</version>
<name>xgboost4j-tester</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>{maven_compiler_source}</maven.compiler.source>
<maven.compiler.target>{maven_compiler_target}</maven.compiler.target>
<scala.version>{scala_version}</scala.version>
<scala.binary.version>{scala_binary_version}</scala.binary.version>
</properties>
<dependencies>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${{scala.version}}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${{scala.version}}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${{scala.version}}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_${{scala.binary.version}}</artifactId>
<version>2.3.11</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_${{scala.binary.version}}</artifactId>
<version>2.3.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${{scala.binary.version}}</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ml.dmlc</groupId>
<artifactId>xgboost4j</artifactId>
<version>{xgboost4j_version}</version>
</dependency>
<dependency>
<groupId>ml.dmlc</groupId>
<artifactId>xgboost4j</artifactId>
<version>{xgboost4j_version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<dependenciesToScan>
<dependency>ml.dmlc:xgboost4j</dependency>
</dependenciesToScan>
</configuration>
</plugin>
</plugins>
</build>
</project>
"""

if __name__ == '__main__':
if len(sys.argv) != 6:
print('Usage: {} [xgboost4j version] [maven compiler source level] [maven compiler target level] [scala version] [scala binary version]'.format(sys.argv[0]))
sys.exit(1)
with open('pom.xml', 'w') as f:
print(pom_template.format(xgboost4j_version=sys.argv[1],
maven_compiler_source=sys.argv[2],
maven_compiler_target=sys.argv[3],
scala_version=sys.argv[4],
scala_binary_version=sys.argv[5]), file=f)
13 changes: 13 additions & 0 deletions jvm-packages/xgboost4j-tester/src/main/java/ml/dmlc/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ml.dmlc;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
20 changes: 20 additions & 0 deletions jvm-packages/xgboost4j-tester/src/test/java/ml/dmlc/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ml.dmlc;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
25 changes: 25 additions & 0 deletions tests/ci_build/Dockerfile.jvm_cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG JDK_VERSION
FROM ubuntu:18.04

# Environment
ENV DEBIAN_FRONTEND noninteractive

# Install all basic requirements
RUN \
apt-get update && \
apt-get install -y tar unzip wget openjdk-${JDK_VERSION}-jdk

ENV GOSU_VERSION 1.10

# Install lightweight sudo (not bound to TTY)
RUN set -ex; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

# Default entry-point to use if running locally
# It will preserve attributes of created files
COPY entrypoint.sh /scripts/

WORKDIR /workspace
ENTRYPOINT ["/scripts/entrypoint.sh"]
2 changes: 1 addition & 1 deletion tests/ci_build/build_jvm_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -e
set -x

# Initialize Maven cache
# Initialize local Maven repository
./tests/ci_build/initialize_maven.sh

rm -rf build/
Expand Down
2 changes: 1 addition & 1 deletion tests/ci_build/build_jvm_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
set -x

# Initialize Maven cache
# Initialize local Maven repository
./tests/ci_build/initialize_maven.sh

rm -rf build/
Expand Down
28 changes: 28 additions & 0 deletions tests/ci_build/test_jvm_cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e
set -x

# Initialize local Maven repository
./tests/ci_build/initialize_maven.sh

# Get version number of XGBoost4J and other auxiliary information
cd jvm-packages
xgboost4j_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
maven_compiler_source=$(mvn help:evaluate -Dexpression=maven.compiler.source -q -DforceStdout)
maven_compiler_target=$(mvn help:evaluate -Dexpression=maven.compiler.target -q -DforceStdout)
scala_version=$(mvn help:evaluate -Dexpression=scala.version -q -DforceStdout)
scala_binary_version=$(mvn help:evaluate -Dexpression=scala.binary.version -q -DforceStdout)

# Install XGBoost4J JAR into local Maven repository
mvn install:install-file -Dfile=./jvm-packages/xgboost4j/target/xgboost4j-${xgboost4j_version}.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j -Dversion=${xgboost4j_version} -Dpackaging=jar
mvn install:install-file -Dfile=./jvm-packages/xgboost4j/target/xgboost4j-${xgboost4j_version}-tests.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j -Dversion=${xgboost4j_version} -Dpackaging=test-jar -Dclassifier=tests

cd xgboost4j-tester
# Generate pom.xml for XGBoost4J-tester, a dummy project to run XGBoost4J tests
python3 ./generate_pom.py ${xgboost4j_version} ${maven_compiler_source} ${maven_compiler_target} ${scala_version} ${scala_binary_version}
# Run tests
mvn test

set +x
set +e

0 comments on commit 0d7e3b6

Please sign in to comment.