From 687a45c564d9d4e35d8d0c351eb92d6ffca30fce Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 13 Sep 2019 11:40:39 +0200 Subject: [PATCH] Added docker to run tests on various mono versions --- docker/tests/mono/complete/Dockerfile | 22 ++++++ docker/tests/mono/sonarr/Dockerfile | 28 +++++++ docker/tests/mono/startup.sh | 15 ++++ docker/tests/run-all.sh | 108 ++++++++++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 docker/tests/mono/complete/Dockerfile create mode 100644 docker/tests/mono/sonarr/Dockerfile create mode 100644 docker/tests/mono/startup.sh create mode 100644 docker/tests/run-all.sh diff --git a/docker/tests/mono/complete/Dockerfile b/docker/tests/mono/complete/Dockerfile new file mode 100644 index 000000000..5f4e68de9 --- /dev/null +++ b/docker/tests/mono/complete/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:xenial + +ENV DEBIAN_FRONTEND noninteractive +ARG MONO_VERSION=5.20 +ARG MONO_URL=stable-xenial/snapshots/$MONO_VERSION + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ + echo "deb http://download.mono-project.com/repo/debian $MONO_URL main" > /etc/apt/sources.list.d/mono-official-stable.list && \ + apt-get update && apt-get install -y \ + tofrodos tzdata \ + mono-complete \ + sqlite3 mediainfo \ + && rm -rf /var/lib/apt/lists/* + +COPY startup.sh /startup.sh +RUN fromdos /startup.sh + +WORKDIR /data/ +VOLUME ["/data/_tests_linux", "/data/_output_linux", "/data/_tests_results"] + +CMD bash /startup.sh + diff --git a/docker/tests/mono/sonarr/Dockerfile b/docker/tests/mono/sonarr/Dockerfile new file mode 100644 index 000000000..f43478af9 --- /dev/null +++ b/docker/tests/mono/sonarr/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:xenial + +ENV DEBIAN_FRONTEND noninteractive +ARG MONO_VERSION=5.20 +ARG MONO_URL=stable-xenial/snapshots/$MONO_VERSION + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ + echo "deb http://download.mono-project.com/repo/debian $MONO_URL main" > /etc/apt/sources.list.d/mono-official-stable.list && \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 2009837CBFFD68F45BC180471F4F90DE2A9B4BF8 && \ + echo "deb http://apt.sonarr.tv/ubuntu xenial main" > /etc/apt/sources.list.d/sonarr.list && \ + apt-get update && apt-get install -y \ + tofrodos tzdata \ + sonarr \ + sqlite3 mediainfo \ + && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && apt-get install -y \ + libmono-system-runtime4.0-cil \ + && rm -rf /var/lib/apt/lists/* + +COPY startup.sh /startup.sh +RUN fromdos /startup.sh + +WORKDIR /data/ +VOLUME ["/data/_tests_linux", "/data/_output_linux", "/data/_tests_results"] + +CMD bash /startup.sh + diff --git a/docker/tests/mono/startup.sh b/docker/tests/mono/startup.sh new file mode 100644 index 000000000..30b5c43f1 --- /dev/null +++ b/docker/tests/mono/startup.sh @@ -0,0 +1,15 @@ +echo "Preparing Test..." +mkdir -p /data/test +cp -r /data/_tests_linux/* /data/test/ +cp -r /data/_output_linux /data/test/bin + +cd /data/test + +runTest() +{ + bash test.sh Linux $1 + cp TestResult.xml /data/_tests_results/TestResult_$1.xml +} + +runTest Integration +runTest Unit \ No newline at end of file diff --git a/docker/tests/run-all.sh b/docker/tests/run-all.sh new file mode 100644 index 000000000..70c079e34 --- /dev/null +++ b/docker/tests/run-all.sh @@ -0,0 +1,108 @@ + +opt_parallel= +opt_version= +opt_mode=both +while getopts 'pv:m:?h' c +do + case $c in + p) opt_parallel=1 ;; + v) opt_version=$OPTARG ;; + m) opt_mode=$OPTARG ;; + ?|h) printf "Usage: %s [-p] [-v mono-ver] [-m sonarr|complete]\n" $0 + printf " -p run parallel\n" + printf " -v run specified mono version\n" + printf " -m run only mono-'complete' or 'sonarr' package variants\n" + exit 2 + esac +done +# NOTE: +# each container has a 1gb tmpfs mounted since it greatly speeds up the normally intensive db operations +# make sure that the docker host has enough memory to handle about ~300 MB per container, so 2-3 GB total +# excess goes to the swap and will slow down the entire system + +# Preferred versions +MONO_VERSIONS="6.0 5.20 5.18" + +# Future versions +MONO_VERSIONS="$MONO_VERSIONS 6.4=preview-xenial" + +# Supported versions +MONO_VERSIONS="$MONO_VERSIONS 5.16 5.14 5.12 5.10 5.8 5.4" + +# Legacy unsupported versions +MONO_VERSIONS="$MONO_VERSIONS 5.0" +#MONO_VERSIONS="$MONO_VERSIONS 4.8=stable-wheezy/snapshots/4.8" + +if [ "$opt_version" != "" ]; then + MONO_VERSIONS="$opt_version" +fi + +mkdir -p ${PWD}/../../_tests_results + +prepOne() { + local MONO_VERSION_PAIR=$1 + + MONO_VERSION_SPLIT=(${MONO_VERSION_PAIR//=/ }) + MONO_VERSION=${MONO_VERSION_SPLIT[0]} + MONO_URL=${MONO_VERSION_SPLIT[1]:-"stable-xenial/snapshots/$MONO_VERSION"} + + echo "Building Test Docker for mono $MONO_VERSION" + + if [ "$opt_mode" != "sonarr" ]; then + docker build -t sonarr-test-$MONO_VERSION --build-arg MONO_VERSION=$MONO_VERSION --build-arg MONO_URL=$MONO_URL --file mono/complete/Dockerfile mono + fi + + if [ "$opt_mode" != "complete" ] && [ "$MONO_VERSION" != "5.0" ]; then + docker build -t sonarr-test-$MONO_VERSION-sonarr --build-arg MONO_VERSION=$MONO_VERSION --build-arg MONO_URL=$MONO_URL --file mono/sonarr/Dockerfile mono + fi +} + +runOne() { + local MONO_VERSION_PAIR=$1 + + MONO_VERSION_SPLIT=(${MONO_VERSION_PAIR//=/ }) + MONO_VERSION=${MONO_VERSION_SPLIT[0]} + + echo "Running Test Docker for mono $MONO_VERSION" + + if [ "$opt_mode" != "sonarr" ]; then + dockerArgs="--rm" + dockerArgs="$dockerArgs -v /${PWD}/../../_tests_linux:/data/_tests_linux:ro" + dockerArgs="$dockerArgs -v /${PWD}/../../_output_linux:/data/_output_linux:ro" + dockerArgs="$dockerArgs -v /${PWD}/../../_tests_results/mono-$MONO_VERSION:/data/_tests_results" + dockerArgs="$dockerArgs --mount type=tmpfs,destination=//data/test,tmpfs-size=1g" + docker run $dockerArgs sonarr-test-$MONO_VERSION + fi + + if [ "$opt_mode" != "complete" ] && [ "$MONO_VERSION" != "5.0" ]; then + dockerArgs="--rm" + dockerArgs="$dockerArgs -v /${PWD}/../../_tests_linux:/data/_tests_linux:ro" + dockerArgs="$dockerArgs -v /${PWD}/../../_output_linux:/data/_output_linux:ro" + dockerArgs="$dockerArgs -v /${PWD}/../../_tests_results/mono-$MONO_VERSION-sonarr:/data/_tests_results" + dockerArgs="$dockerArgs --mount type=tmpfs,destination=//data/test,tmpfs-size=1g" + docker run $dockerArgs sonarr-test-$MONO_VERSION-sonarr + fi + + echo "Finished Test Docker for mono $MONO_VERSION" +} + +if [ "$opt_parallel" == "1" ]; then + for MONO_VERSION_PAIR in $MONO_VERSIONS; do + prepOne "$MONO_VERSION_PAIR" + done +fi + +for MONO_VERSION_PAIR in $MONO_VERSIONS; do + if [ "$opt_parallel" == "1" ]; then + runOne "$MONO_VERSION_PAIR" & + else + prepOne "$MONO_VERSION_PAIR" + runOne "$MONO_VERSION_PAIR" + fi +done + +if [ "$opt_parallel" == "1" ]; then + echo "Waiting for all runs to finish" + wait + echo "Finished all runs" +fi \ No newline at end of file