Skip to content

Commit

Permalink
Add Jacoco tests into external group
Browse files Browse the repository at this point in the history
- Add Jacoco tests into external group

Issue: adoptium#1697
signed-off-by: Nikola Milijevic <nmilijev@uwaterloo.ca>
  • Loading branch information
nikolamilijevic1 committed Jul 29, 2020
1 parent e3cbf52 commit 51a13f3
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 1 deletion.
17 changes: 16 additions & 1 deletion external/common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ supported_builds="slim full"

# Supported tests
# Test Not Included: elasticsearch
supported_tests="camel derby jenkins functional-test kafka lucene-solr openliberty-mp-tck payara-mp-tck quarkus quarkus_quickstarts scala system-test thorntail-mp-tck tomcat tomee wildfly wycheproof"
supported_tests="camel derby jacoco jenkins functional-test kafka lucene-solr openliberty-mp-tck payara-mp-tck quarkus quarkus_quickstarts scala system-test thorntail-mp-tck tomcat tomee wildfly wycheproof"

function check_version() {
version=$1
Expand Down Expand Up @@ -224,6 +224,21 @@ function set_test_info() {
ubi_packages="git wget make gcc unzip"
ubi_minimal_packages="${ubi_packages}"
;;
jacoco)
github_url="https://github.com/jacoco/jacoco.git"
script="jacoco-test.sh"
home_path=""
test_results="testResults"
tag_version="master"
debian_packages="git maven"
debianslim_packages="${debian_packages}"
ubuntu_packages="${debian_packages}"
alpine_packages="git maven"
centos_packages="git maven"
clefos_packages="${centos_packages}"
ubi_packages="git maven"
ubi_minimal_packages="${ubi_packages}"
;;
jenkins)
github_url="https://github.com/jenkinsci/jenkins.git"
script="jenkins-test.sh"
Expand Down
27 changes: 27 additions & 0 deletions external/jacoco/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<project name="Jacoco-Test" default="build" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<description>
Build jacoco-test Docker image
</description>
<import file="${TEST_ROOT}/external/build.xml"/>

<!-- set properties for this build -->
<property name="TEST" value="jacoco" />
<property name="DEST" value="${BUILD_ROOT}/external/${TEST}" />
<property name="src" location="." />

<target name="init">
<mkdir dir="${DEST}"/>
</target>

<target name="dist" depends="move_scripts,clean_image,build_image" description="generate the distribution">
<copy todir="${DEST}">
<fileset dir="${src}" includes="*.xml, *.mk"/>
</copy>
</target>

<target name="build">
<antcall target="dist" inheritall="true" />
</target>
</project>
49 changes: 49 additions & 0 deletions external/jacoco/dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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
#
# https://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.

# This Dockerfile in external/jacoco/dockerfile dir is used to create an image with
# AdoptOpenJDK jdk binary installed. Basic test dependent executions
# are installed during the building process.
#
# Build example: `docker build -t adoptopenjdk-jacoco-test -f Dockerfile ../.`
#
# This Dockerfile builds image based on adoptopenjdk/openjdk8:latest.
# If you want to build image based on other images, please use
# `--build-arg list` to specify your base image
#
# Build example: `docker build --build-arg IMAGE_NAME=<image_name> --build-arg IMAGE_VERSION=<image_version >-t adoptopenjdk-jacoco-test .`


ARG SDK=openjdk8
ARG IMAGE_NAME=adoptopenjdk/$SDK
ARG IMAGE_VERSION=nightly

FROM $IMAGE_NAME:$IMAGE_VERSION

# Install test dependent executable files
RUN apt-get update \
&& apt-get -y install \
maven \
git \
wget

ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
ENV MODE="java"

COPY ./dockerfile/jacoco-test.sh /jacoco-test.sh
RUN mkdir testResults
WORKDIR /
RUN pwd
RUN git clone https://github.com/jacoco/jacoco.git

ENTRYPOINT ["/bin/bash", "/jacoco-test.sh"]
CMD ["$MODE"]
51 changes: 51 additions & 0 deletions external/jacoco/dockerfile/jacoco-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#/bin/bash
# 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
#
# https://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.

source $(dirname "$0")/test_base_functions.sh

# Set up Java to be used by the the jacoco-test

if [ -d /java/jre/bin ];then
echo "Using mounted Java8"
export JAVA_BIN=/java/jre/bin
export JAVA_HOME=/java
export PATH=$JAVA_BIN:$PATH
elif [ -d /java/bin ]; then
echo "Using mounted Java"
export JAVA_BIN=/java/bin
export JAVA_HOME=/java
export PATH=$JAVA_BIN:$PATH
else
echo "Using docker image default Java"
java_path=$(type -p java)
suffix="/java"
java_root=${java_path%$suffix}
export JAVA_BIN="$java_root"
echo "JAVA_BIN is: $JAVA_BIN"
export JAVA_HOME="${java_root%/bin}"
fi

echo_setup

#begin jacoco test
cd /jacoco
echo "Compile and run jacoco tests"
mvn clean verify

test_exit_code=$?
echo "Build jacoco completed"

find ./ -type d -name 'surefire-reports' -exec cp -r "{}" /testResults \;
echo "Test results copied"

exit $test_exit_code
42 changes: 42 additions & 0 deletions external/jacoco/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
# 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
#
# https://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.
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../TestConfig/playlist.xsd">
<test>
<testCaseName>MachineInfo</testCaseName>
<command>$(JAVA_COMMAND) -cp $(JVM_TEST_ROOT)$(D)TKG$(D)bin$(D)TestKitGen.jar org.openj9.envInfo.EnvDetector MachineInfo; \
$(TEST_STATUS)</command>
<levels>
<level>sanity</level>
<level>extended</level>
<level>special</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
<test>
<testCaseName>jacoco_test</testCaseName>
<command> $(TEST_ROOT)$(D)external$(D)external.sh --run --tag ${DOCKERIMAGE_TAG} --version ${JDK_VERSION} --impl ${JDK_IMPL} --dir jacoco --reportdst $(REPORTDIR) --docker_args "$(EXTRA_DOCKER_ARGS)"; \
$(TEST_STATUS); \
$(TEST_ROOT)$(D)external$(D)external.sh --clean --tag ${DOCKERIMAGE_TAG} --version ${JDK_VERSION} --impl ${JDK_IMPL} --dir jacoco
</command>
<levels>
<level>extended</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
</playlist>

0 comments on commit 51a13f3

Please sign in to comment.