changeset 228:fb4b4501e0d4

Bug 3358: [TEST]Add Dockerfile and README for testing on container Reviewed-by: yasuenag https://github.com/HeapStats/heapstats/pull/93
author KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
date Wed, 12 Apr 2017 16:02:25 +0900
parents f421a4c6e7ea
children ac5cfda97b59
files ChangeLog agent/test/Dockerfile agent/test/Dockerfile.el7 agent/test/README.md
diffstat 4 files changed, 168 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 11 18:05:01 2017 +0900
+++ b/ChangeLog	Wed Apr 12 16:02:25 2017 +0900
@@ -5,6 +5,7 @@
 	* Bug 3355: [TEST]Add unit test cases
 	* Bug 3356: [TEST]Add a race-condition test framework
 	* Bug 3357: [TEST][RaceCondition]Add some events with ClassPrepare
+	* Bug 3358: [TEST]Add Dockerfile and README for testing on container
 
 2017-03-25 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent/test/Dockerfile	Wed Apr 12 16:02:25 2017 +0900
@@ -0,0 +1,53 @@
+FROM fedora:latest
+
+MAINTAINER KUBOTA Yuji <kubota.yuji@gmail.com>
+
+ENV HEAPSTATS_PATH /heapstats
+ARG _JAVA_OPTIONS=""
+
+# Update without using cache
+## https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run
+RUN dnf update -y \
+ && dnf install -y \
+    git
+
+# Install dependencies for HeapStats
+RUN dnf install -y \
+    ant \
+    binutils-devel \
+    gcc-c++ \
+# If you want to test with old jdk, use below
+#    java-1.6.0-openjdk-devel java-1.7.0-openjdk-devel \
+    java-1.8.0-openjdk-devel \
+    maven \
+    net-snmp-devel net-snmp-libs \
+    pcre-devel \
+ && dnf install -y \
+    --enablerepo="*debug*" --disablerepo="*test*" \
+# If you want to test with old jdk, use below
+#    java-1.6.0-openjdk-debuginfo java-1.7.0-openjdk-debuginfo \
+    java-1.8.0-openjdk-debuginfo
+
+ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk
+ENV PATH ${PATH}:${JAVA_HOME}/lib/
+
+# Build HeapStats
+RUN git clone https://github.com/HeapStats/heapstats.git ${HEAPSTATS_PATH}
+
+WORKDIR ${HEAPSTATS_PATH}
+RUN bash configure --with-jdk=${JAVA_HOME} \
+ && make agent mbean
+
+ENV HEAPSTATS_LIB ${HEAPSTATS_PATH}/agent/src/libheapstats-2.0.so.3
+
+# Prepare to test HeapStats
+WORKDIR ${HEAPSTATS_PATH}/agent/test/gtest
+RUN dnf install -y \
+    gtest-devel \
+    gdb \
+ && make
+
+WORKDIR ${HEAPSTATS_PATH}/agent/test
+RUN useradd testuser \
+ && chown -R testuser.testuser ./*
+USER testuser
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent/test/Dockerfile.el7	Wed Apr 12 16:02:25 2017 +0900
@@ -0,0 +1,62 @@
+FROM registry.access.redhat.com/rhel7:latest
+
+MAINTAINER KUBOTA Yuji <kubota.yuji@gmail.com>
+
+ENV HEAPSTATS_PATH /heapstats
+ARG _JAVA_OPTIONS=""
+
+# Install common requirements
+RUN yum update -y \
+ && yum install -y \
+    git \
+    wget
+
+# Install dependencies for HeapStats
+RUN yum install -y \
+    ant \
+    binutils-devel \
+    gcc-c++ \
+# If you want to test with old jdk, use below
+#    java-1.6.0-openjdk-devel java-1.7.0-openjdk-devel \
+    java-1.8.0-openjdk-devel \
+    make \
+    net-snmp-devel net-snmp-libs \
+    pcre-devel \
+# When RHEL provides maven 3.3 or later, use below.
+# && yum install -y --enablerepo="rhel-7-server-optional-rpms" \
+#    maven \
+ && yum install -y --enablerepo="rhel-server-rhscl-7-beta-rpms" \
+    rh-maven33 \
+ && yum install -y --enablerepo="*debug*" --disablerepo="*beta*,*test*" \
+# If you want to test with old jdk, use below.
+#    java-1.6.0-openjdk-debuginfo java-1.7.0-openjdk-debuginfo \
+    java-1.8.0-openjdk-debuginfo
+
+ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk
+ENV PATH "/opt/rh/rh-maven33/root/usr/bin:${PATH:-/bin:/usr/bin}"
+
+# Build  HeapStats
+RUN git clone https://github.com/HeapStats/heapstats.git ${HEAPSTATS_PATH}
+
+WORKDIR ${HEAPSTATS_PATH}
+RUN bash configure --with-jdk=${JAVA_HOME} \
+ && make agent mbean
+
+ENV HEAPSTATS_LIB ${HEAPSTATS_PATH}/agent/src/libheapstats-2.0.so.3
+
+# Prepare to test HeapStats
+WORKDIR ${HEAPSTATS_PATH}/agent/test
+RUN yum install -y \
+    python-devel \
+    texinfo \
+ && wget -q http://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz \
+ && tar zxf gdb-7.12.tar.gz \
+ && cd gdb-7.12 \
+ && bash configure --prefix=/opt/gdb --with-python \
+ && make \
+ && make install \
+ && cd ../ \
+ && rm -rf gdb-7.12*
+
+ENV GDB_PATH /opt/gdb
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent/test/README.md	Wed Apr 12 16:02:25 2017 +0900
@@ -0,0 +1,52 @@
+# Test for HeapStats
+
+Test cases for HeapStats. These test cases could run on containers.
+
+## Usage
+
+### on container
+
+```
+docker build --pull -t heapstatas/test -f ./Dockerfile .
+```
+If run under proxy, run with `--build-arg http_proxy=<proxy> --build-arg https_proxy=<proxy> --build-arg _JAVA_OPTIONS="-Dhttps.proxyHost=<proxy host> -Dhttps.proxyPort=<proxy port>"`
+
+Once you have the image, you can easily run tests as below.
+
+```
+docker run --rm  -t heapstats/test ./<dirctory>/testcase.sh
+
+# You need security option when you run race-condition/testcase.sh
+docker run --rm --security-opt seccomp=unconfined -t heapstats/test ./race-condition/testcase.sh
+```
+
+These commands are just example, you can use container as you like.
+
+#### Container for RHEL 7
+
+You can create an image of RHEL 7 by using Dockerfile.el7. This requires Red Hat subscription(s), read [Red Hat's documentations](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/7.0_Release_Notes/sect-Red_Hat_Enterprise_Linux-7.0_Release_Notes-Linux_Containers_with_Docker_Format-Using_Docker.html) for details.
+
+Also, you need to get and build gtest when you test by ./gtest .
+
+### on local machine
+
+```
+bash <directory>/testcase.sh
+
+# You can delete result files
+bash <directory>/testcase.sh --clean
+```
+
+## Requirements
+
+There are some requirements for running test cases on your own machine.
+
+* Libraries
+  * gdb (>= 7.12)
+  * gtest
+  * maven (>= 3.3)
+  * python (>= 2.7)
+* Environment varibles
+  * JAVA_HOME: Path to JDK installed (default: /usr/lib/jvm/java-openjdk)
+  * HEAPSTATS_LIB: Path to libheapstats.so (default: /usr/lib64/heapstats/libheapstats.so)
+