Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Kafka under third party tests #469

Merged
merged 4 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions thirdparty_containers/kafka/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<project name="kafka-test" default="build" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<description>
Build kafka-test Docker image
</description>

<!-- set properties for this build -->
<property name="DEST" value="${BUILD_ROOT}/thirdparty_containers/kafka-test" />
<property name="src" location="." />
<property name="jvm_version" location="${JVM_VERSION}" />

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

<target name="clean_image" depends="init" description="clean kafka test docker image if there is one">
<exec executable="docker">
<arg line="rmi -f adoptopenjdk-kafka-test" />
</exec>
</target>

<target name="build_image" depends="clean_image" description="build kafka test docker image">
<exec executable="docker" failonerror="true">
<arg line="build -t adoptopenjdk-kafka-test -f dockerfile/Dockerfile --pull . --build-arg SDK=${JVM_VERSION}" />
</exec>
</target>

<target name="dist" depends="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>
71 changes: 71 additions & 0 deletions thirdparty_containers/kafka/dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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.

# This Dockerfile in thirdparty_containers/kafka/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-kafka-test .`
#
# 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-kafka-test .`

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

FROM $IMAGE_NAME:$IMAGE_VERSION

# Install test dependent executable files
RUN apt-get update \
&& apt-get -y install \
ant \
apt-transport-https \
ca-certificates \
dirmngr \
curl \
git \
make \
unzip \
vim \
wget

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

#Install Gradle
RUN mkdir -p /usr/share/gradle \
&& cd /usr/share/gradle \
&& wget -q https://services.gradle.org/distributions/gradle-4.5-bin.zip \
&& unzip -qq gradle-4.5-bin.zip \
&& rm -rf gradle-4.5-bin.zip \
&& ln -s /usr/share/gradle/gradle-4.5/bin/gradle /usr/bin/gradle \
&& cd /

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

RUN cd .

VOLUME ["/java"]
ENV JAVA_HOME=/java \
PATH=/java/bin:$PATH \
JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"

# This is the main script to run kafka tests.
COPY ./dockerfile/kafka-test.sh /kafka-test.sh

# Clone the repo where kafka tests reside.
WORKDIR /
RUN pwd

RUN git clone https://github.com/apache/kafka.git

ENTRYPOINT ["/bin/bash", "/kafka-test.sh"]
CMD ["--version"]
61 changes: 61 additions & 0 deletions thirdparty_containers/kafka/dockerfile/kafka-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#/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
#
# 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.
#

#Set up Java to be used by the kafka-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
java -version
elif [ -d /java/bin ]; then
echo "Using mounted Java9"
export JAVA_BIN=/java/bin
export JAVA_HOME=/java
export PATH=$JAVA_BIN:$PATH
java -version
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"
$JAVA_BIN/java -version
fi

TEST_SUITE=$1

echo "PATH is : $PATH"
echo "JAVA_HOME is : $JAVA_HOME"
echo "type -p java is :"
type -p java
echo "java -version is: \n"
java -version

# Initial command to trigger the execution of kafka test
cd /kafka
ls .
pwd

echo "Building kafka using gradle" && \
gradle -q
./gradlew jar

echo "Kafka Build - Completed"

echo "Running (ALL) Kafka tests :"

./gradlew testAll
31 changes: 31 additions & 0 deletions thirdparty_containers/kafka/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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
#
# 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.
-->
<playlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../TestConfig/playlist.xsd">
<test>
<testCaseName>kafka_test</testCaseName>
<command>docker run --rm -v $(JDK_HOME):/java adoptopenjdk-kafka-test:latest ; \
$(TEST_STATUS)</command>
<subsets>
<subset>SE80</subset>
<subset>SE90</subset>
</subsets>
<levels>
<level>extended</level>
</levels>
<groups>
<group>external</group>
</groups>
</test>
</playlist>