mirror of https://github.com/grpc/grpc.git
Merge pull request #3605 from jtattermusch/interop_improvements
Build and run per-language containers for interop testspull/3614/head
commit
f8460df564
17 changed files with 1123 additions and 247 deletions
@ -1,111 +0,0 @@ |
||||
#!/bin/bash |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# This script is invoked by run_interop_tests.py to accommodate |
||||
# "interop tests under docker" scenario. You should never need to call this |
||||
# script on your own. |
||||
|
||||
set -ex |
||||
|
||||
cd `dirname $0`/../.. |
||||
git_root=`pwd` |
||||
cd - |
||||
|
||||
mkdir -p /tmp/ccache |
||||
|
||||
# Use image name based on Dockerfile checksum |
||||
DOCKER_IMAGE_NAME=grpc_jenkins_slave${docker_suffix}_`sha1sum tools/jenkins/grpc_jenkins_slave/Dockerfile | cut -f1 -d\ ` |
||||
|
||||
# Make sure docker image has been built. Should be instantaneous if so. |
||||
docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_jenkins_slave$docker_suffix |
||||
|
||||
# Create a local branch so the child Docker script won't complain |
||||
git branch -f jenkins-docker |
||||
|
||||
# Make sure the CID files are gone. |
||||
rm -f prepare.cid server.cid client.cid |
||||
|
||||
# Prepare image for interop tests |
||||
docker run \ |
||||
-e CCACHE_DIR=/tmp/ccache \ |
||||
-i $TTY_FLAG \ |
||||
-v "$git_root:/var/local/jenkins/grpc" \ |
||||
-v /tmp/ccache:/tmp/ccache \ |
||||
--cidfile=prepare.cid \ |
||||
$DOCKER_IMAGE_NAME \ |
||||
bash -l /var/local/jenkins/grpc/tools/jenkins/docker_prepare_interop_tests.sh || DOCKER_FAILED="true" |
||||
|
||||
PREPARE_CID=`cat prepare.cid` |
||||
|
||||
# Create image from the container, we will spawn one docker for clients |
||||
# and one for servers. |
||||
INTEROP_IMAGE=interop_`uuidgen` |
||||
docker commit $PREPARE_CID $INTEROP_IMAGE |
||||
# remove container, possibly killing it first |
||||
docker rm -f $PREPARE_CID || true |
||||
echo "Successfully built image $INTEROP_IMAGE" |
||||
|
||||
# run interop servers under docker in the background |
||||
docker run \ |
||||
-d -i \ |
||||
$SERVERS_DOCKER_EXTRA_ARGS \ |
||||
--cidfile=server.cid \ |
||||
$INTEROP_IMAGE bash -l /var/local/git/grpc/tools/jenkins/docker_run_interop_servers.sh |
||||
|
||||
SERVER_CID=`cat server.cid` |
||||
|
||||
SERVER_PORTS="" |
||||
for tuple in $SERVER_PORT_TUPLES |
||||
do |
||||
# lookup under which port docker exposes given internal port |
||||
exposed_port=`docker port $SERVER_CID ${tuple#*:} | awk -F ":" '{print $NF}'` |
||||
|
||||
# override the port for corresponding cloud_to_cloud server |
||||
SERVER_PORTS+=" --override_server ${tuple%:*}=localhost:$exposed_port" |
||||
echo "${tuple%:*} server is exposed under port $exposed_port" |
||||
done |
||||
|
||||
# run interop clients |
||||
docker run \ |
||||
-e "RUN_TESTS_COMMAND=$RUN_TESTS_COMMAND $SERVER_PORTS" \ |
||||
-w /var/local/git/grpc \ |
||||
-i $TTY_FLAG \ |
||||
--net=host \ |
||||
--cidfile=client.cid \ |
||||
$INTEROP_IMAGE bash -l /var/local/git/grpc/tools/jenkins/docker_run_interop_tests.sh || DOCKER_FAILED="true" |
||||
|
||||
CLIENT_CID=`cat client.cid` |
||||
|
||||
echo "killing and removing server container $SERVER_CID" |
||||
docker rm -f $SERVER_CID || true |
||||
|
||||
docker cp $CLIENT_CID:/var/local/git/grpc/report.xml $git_root |
||||
docker rm -f $CLIENT_CID || true |
||||
docker rmi -f $DOCKER_IMAGE_NAME || true |
@ -0,0 +1,93 @@ |
||||
#!/bin/bash |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# This script is invoked by run_interop_tests.py to build the docker image |
||||
# for interop testing. You should never need to call this script on your own. |
||||
|
||||
set -x |
||||
|
||||
cd `dirname $0`/../.. |
||||
GRPC_ROOT=`pwd` |
||||
MOUNT_ARGS="-v $GRPC_ROOT:/var/local/jenkins/grpc" |
||||
|
||||
GRPC_JAVA_ROOT=`cd ../grpc-java && pwd` |
||||
if [ "$GRPC_JAVA_ROOT" != "" ] |
||||
then |
||||
MOUNT_ARGS+=" -v $GRPC_JAVA_ROOT:/var/local/jenkins/grpc-java" |
||||
else |
||||
echo "WARNING: grpc-java not found, it won't be mounted to the docker container." |
||||
fi |
||||
|
||||
GRPC_GO_ROOT=`cd ../grpc-go && pwd` |
||||
if [ "$GRPC_GO_ROOT" != "" ] |
||||
then |
||||
MOUNT_ARGS+=" -v $GRPC_GO_ROOT:/var/local/jenkins/grpc-go" |
||||
else |
||||
echo "WARNING: grpc-go not found, it won't be mounted to the docker container." |
||||
fi |
||||
|
||||
mkdir -p /tmp/ccache |
||||
|
||||
# Params: |
||||
# INTEROP_IMAGE - name of tag of the final interop image |
||||
# BASE_NAME - base name used to locate the base Dockerfile and build script |
||||
# TTY_FLAG - optional -t flag to make docker allocate tty. |
||||
|
||||
# Use image name based on Dockerfile checksum |
||||
BASE_IMAGE=${BASE_NAME}_base:`sha1sum tools/jenkins/$BASE_NAME/Dockerfile | cut -f1 -d\ ` |
||||
|
||||
# Make sure base docker image has been built. Should be instantaneous if so. |
||||
docker build -t $BASE_IMAGE --force-rm=true tools/jenkins/$BASE_NAME || exit $? |
||||
|
||||
# Create a local branch so the child Docker script won't complain |
||||
git branch -f jenkins-docker |
||||
|
||||
CIDFILE=`mktemp -u --suffix=.cid` |
||||
|
||||
# Prepare image for interop tests, commit it on success. |
||||
(docker run \ |
||||
-e CCACHE_DIR=/tmp/ccache \ |
||||
-i $TTY_FLAG \ |
||||
$MOUNT_ARGS \ |
||||
-v /tmp/ccache:/tmp/ccache \ |
||||
--cidfile=$CIDFILE \ |
||||
$BASE_IMAGE \ |
||||
bash -l /var/local/jenkins/grpc/tools/jenkins/$BASE_NAME/build_interop.sh \ |
||||
&& docker commit `cat $CIDFILE` $INTEROP_IMAGE \ |
||||
&& echo "Successfully built image $INTEROP_IMAGE") |
||||
EXITCODE=$? |
||||
|
||||
# remove intermediate container, possibly killing it first |
||||
docker rm -f `cat $CIDFILE` |
||||
|
||||
# remove the cidfile |
||||
rm -rf `cat $CIDFILE` |
||||
|
||||
exit $EXITCODE |
@ -0,0 +1,92 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
# A work-in-progress Dockerfile that allows running gRPC test suites |
||||
# inside a docker container. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install Git. |
||||
RUN apt-get update && apt-get install -y \ |
||||
autoconf \ |
||||
autotools-dev \ |
||||
build-essential \ |
||||
bzip2 \ |
||||
ccache \ |
||||
curl \ |
||||
gcc \ |
||||
gcc-multilib \ |
||||
git \ |
||||
gyp \ |
||||
libc6 \ |
||||
libc6-dbg \ |
||||
libc6-dev \ |
||||
libgtest-dev \ |
||||
libtool \ |
||||
make \ |
||||
strace \ |
||||
python-dev \ |
||||
python-setuptools \ |
||||
python-yaml \ |
||||
telnet \ |
||||
unzip \ |
||||
wget \ |
||||
zip && apt-get clean |
||||
|
||||
# Prepare ccache |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/g++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/cc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/c++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ |
||||
|
||||
################# |
||||
# C# dependencies |
||||
|
||||
# Update to a newer version of mono |
||||
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
||||
RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list |
||||
RUN echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list |
||||
RUN echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list |
||||
RUN echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list |
||||
|
||||
# Install dependencies |
||||
RUN apt-get update && apt-get -y dist-upgrade && apt-get install -y \ |
||||
mono-devel \ |
||||
nunit \ |
||||
nunit-console \ |
||||
monodevelop |
||||
|
||||
# Download NuGet |
||||
RUN cd /var/local && wget www.nuget.org/NuGet.exe |
||||
ENV NUGET mono /var/local/NuGet.exe |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,44 @@ |
||||
#!/bin/bash |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# Builds C# interop server and client in a base image. |
||||
set -e |
||||
|
||||
mkdir -p /var/local/git |
||||
git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc |
||||
|
||||
cd /var/local/git/grpc |
||||
|
||||
make install-certs |
||||
|
||||
# build C# interop client & server |
||||
make install_grpc_csharp_ext |
||||
(cd src/csharp && mono /var/local/NuGet.exe restore Grpc.sln) |
||||
(cd src/csharp && xbuild Grpc.sln) |
@ -0,0 +1,75 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
# A work-in-progress Dockerfile that allows running gRPC test suites |
||||
# inside a docker container. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install Git. |
||||
RUN apt-get update && apt-get install -y \ |
||||
autoconf \ |
||||
autotools-dev \ |
||||
build-essential \ |
||||
bzip2 \ |
||||
ccache \ |
||||
curl \ |
||||
gcc \ |
||||
gcc-multilib \ |
||||
git \ |
||||
gyp \ |
||||
libc6 \ |
||||
libc6-dbg \ |
||||
libc6-dev \ |
||||
libgtest-dev \ |
||||
libtool \ |
||||
make \ |
||||
strace \ |
||||
python-dev \ |
||||
python-setuptools \ |
||||
python-yaml \ |
||||
telnet \ |
||||
unzip \ |
||||
wget \ |
||||
zip && apt-get clean |
||||
|
||||
# Prepare ccache |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/g++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/cc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/c++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ |
||||
|
||||
################## |
||||
# C++ dependencies |
||||
RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,42 @@ |
||||
#!/bin/bash |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# Builds C++ interop server and client in a base image. |
||||
set -e |
||||
|
||||
mkdir -p /var/local/git |
||||
git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc |
||||
|
||||
cd /var/local/git/grpc |
||||
|
||||
make install-certs |
||||
|
||||
# build C++ interop client & server |
||||
make interop_client interop_server |
@ -0,0 +1,58 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install JDK 8 and Git |
||||
# |
||||
# TODO(temiola): simplify this if/when a simpler process is available. |
||||
# |
||||
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ |
||||
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \ |
||||
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \ |
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \ |
||||
apt-get update && \ |
||||
apt-get -y install \ |
||||
git \ |
||||
libapr1 \ |
||||
oracle-java8-installer \ |
||||
&& \ |
||||
apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ |
||||
|
||||
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle |
||||
ENV PATH $PATH:$JAVA_HOME/bin |
||||
|
||||
# Trigger download of as many Gradle artifacts as possible. |
||||
RUN git clone --recursive --depth 1 https://github.com/grpc/grpc-java.git && \ |
||||
cd grpc-java && \ |
||||
./gradlew build -PskipCodegen=true && \ |
||||
rm -r "$(pwd)" |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,79 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
# A work-in-progress Dockerfile that allows running gRPC test suites |
||||
# inside a docker container. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install Git. |
||||
RUN apt-get update && apt-get install -y \ |
||||
autoconf \ |
||||
autotools-dev \ |
||||
build-essential \ |
||||
bzip2 \ |
||||
ccache \ |
||||
curl \ |
||||
gcc \ |
||||
gcc-multilib \ |
||||
git \ |
||||
gyp \ |
||||
libc6 \ |
||||
libc6-dbg \ |
||||
libc6-dev \ |
||||
libgtest-dev \ |
||||
libtool \ |
||||
make \ |
||||
strace \ |
||||
python-dev \ |
||||
python-setuptools \ |
||||
python-yaml \ |
||||
telnet \ |
||||
unzip \ |
||||
wget \ |
||||
zip && apt-get clean |
||||
|
||||
# Prepare ccache |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/g++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/cc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/c++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ |
||||
|
||||
################## |
||||
# Node dependencies |
||||
|
||||
# Install nvm |
||||
RUN touch .profile |
||||
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash |
||||
RUN /bin/bash -l -c "nvm install 0.12" |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,112 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
# A work-in-progress Dockerfile that allows running gRPC test suites |
||||
# inside a docker container. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install Git. |
||||
RUN apt-get update && apt-get install -y \ |
||||
autoconf \ |
||||
autotools-dev \ |
||||
build-essential \ |
||||
bzip2 \ |
||||
ccache \ |
||||
curl \ |
||||
gcc \ |
||||
gcc-multilib \ |
||||
git \ |
||||
gyp \ |
||||
libc6 \ |
||||
libc6-dbg \ |
||||
libc6-dev \ |
||||
libgtest-dev \ |
||||
libtool \ |
||||
make \ |
||||
strace \ |
||||
python-dev \ |
||||
python-setuptools \ |
||||
python-yaml \ |
||||
telnet \ |
||||
unzip \ |
||||
wget \ |
||||
zip && apt-get clean |
||||
|
||||
# Prepare ccache |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/g++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/cc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/c++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ |
||||
|
||||
################## |
||||
# Ruby dependencies |
||||
|
||||
# Install rvm |
||||
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 |
||||
RUN \curl -sSL https://get.rvm.io | bash -s stable |
||||
|
||||
# Install Ruby 2.1 |
||||
RUN /bin/bash -l -c "rvm install ruby-2.1" |
||||
RUN /bin/bash -l -c "rvm use --default ruby-2.1" |
||||
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" |
||||
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" |
||||
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc" |
||||
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc" |
||||
|
||||
################## |
||||
# PHP dependencies |
||||
|
||||
# Install dependencies |
||||
|
||||
RUN /bin/bash -l -c "echo 'deb http://packages.dotdeb.org wheezy-php55 all' \ |
||||
>> /etc/apt/sources.list.d/dotdeb.list" |
||||
RUN /bin/bash -l -c "echo 'deb-src http://packages.dotdeb.org wheezy-php55 all' \ |
||||
>> /etc/apt/sources.list.d/dotdeb.list" |
||||
RUN wget http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add - |
||||
|
||||
RUN apt-get update && apt-get install -y \ |
||||
git php5 php5-dev phpunit unzip |
||||
|
||||
# ronn: a ruby tool used to convert markdown to man pages, used during the |
||||
# install of Protobuf extensions |
||||
# |
||||
# rake: a ruby version of make used to build the PHP Protobuf extension |
||||
RUN /bin/bash -l -c "rvm all do gem install ronn rake" |
||||
|
||||
ENV DEBIAN_FRONTEND noniteractive |
||||
|
||||
# Install composer |
||||
RUN curl -sS https://getcomposer.org/installer | php |
||||
RUN mv composer.phar /usr/local/bin/composer |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,87 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
# A work-in-progress Dockerfile that allows running gRPC test suites |
||||
# inside a docker container. |
||||
|
||||
FROM debian:jessie |
||||
|
||||
# Install Git. |
||||
RUN apt-get update && apt-get install -y \ |
||||
autoconf \ |
||||
autotools-dev \ |
||||
build-essential \ |
||||
bzip2 \ |
||||
ccache \ |
||||
curl \ |
||||
gcc \ |
||||
gcc-multilib \ |
||||
git \ |
||||
gyp \ |
||||
libc6 \ |
||||
libc6-dbg \ |
||||
libc6-dev \ |
||||
libgtest-dev \ |
||||
libtool \ |
||||
make \ |
||||
strace \ |
||||
python-dev \ |
||||
python-setuptools \ |
||||
python-yaml \ |
||||
telnet \ |
||||
unzip \ |
||||
wget \ |
||||
zip && apt-get clean |
||||
|
||||
# Prepare ccache |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/gcc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/g++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/cc |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/c++ |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang |
||||
RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ |
||||
|
||||
|
||||
################## |
||||
# Ruby dependencies |
||||
|
||||
# Install rvm |
||||
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 |
||||
RUN \curl -sSL https://get.rvm.io | bash -s stable |
||||
|
||||
# Install Ruby 2.1 |
||||
RUN /bin/bash -l -c "rvm install ruby-2.1" |
||||
RUN /bin/bash -l -c "rvm use --default ruby-2.1" |
||||
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" |
||||
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc" |
||||
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc" |
||||
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc" |
||||
|
||||
# Define the default command. |
||||
CMD ["bash"] |
@ -0,0 +1,43 @@ |
||||
#!/bin/bash |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# Builds Ruby interop server and client in a base image. |
||||
set -e |
||||
|
||||
mkdir -p /var/local/git |
||||
git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc |
||||
|
||||
cd /var/local/git/grpc |
||||
rvm --default use ruby-2.1 |
||||
|
||||
make install-certs |
||||
|
||||
# build Ruby interop client and server |
||||
(cd src/ruby && gem update bundler && bundle && rake compile:grpc) |
@ -0,0 +1,115 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
"""Helpers to run docker instances as jobs.""" |
||||
|
||||
import jobset |
||||
import tempfile |
||||
import time |
||||
import uuid |
||||
import os |
||||
import subprocess |
||||
|
||||
_DEVNULL = open(os.devnull, 'w') |
||||
|
||||
def wait_for_file(filepath, timeout_seconds=15): |
||||
"""Wait until given file exists and returns its content.""" |
||||
started = time.time() |
||||
while time.time() - started < timeout_seconds: |
||||
if os.path.isfile(filepath): |
||||
with open(filepath, 'r') as f: |
||||
content = f.read() |
||||
# make sure we don't return empty content |
||||
if content: |
||||
return content |
||||
time.sleep(1) |
||||
raise Exception('Failed to read file %s.' % filepath) |
||||
|
||||
|
||||
def docker_mapped_port(cid, port): |
||||
"""Get port mapped to internal given internal port for given container.""" |
||||
output = subprocess.check_output('docker port %s %s' % (cid, port), shell=True) |
||||
return int(output.split(':', 2)[1]) |
||||
|
||||
|
||||
def finish_jobs(jobs): |
||||
"""Kills given docker containers and waits for corresponding jobs to finish""" |
||||
for job in jobs: |
||||
job.kill(suppress_failure=True) |
||||
|
||||
while any(job.is_running() for job in jobs): |
||||
time.sleep(1) |
||||
|
||||
|
||||
def image_exists(image): |
||||
"""Returns True if given docker image exists.""" |
||||
return subprocess.call(['docker','inspect', image], |
||||
stdout=_DEVNULL, |
||||
stderr=_DEVNULL) == 0 |
||||
|
||||
|
||||
def remove_image(image, skip_nonexistent=False, max_retries=10): |
||||
"""Attempts to remove docker image with retries.""" |
||||
if skip_nonexistent and not image_exists(image): |
||||
return True |
||||
for attempt in range(0, max_retries): |
||||
if subprocess.call(['docker','rmi', '-f', image]) == 0: |
||||
return True |
||||
time.sleep(2) |
||||
print 'Failed to remove docker image %s' % image |
||||
return False |
||||
|
||||
|
||||
class DockerJob: |
||||
"""Encapsulates a job""" |
||||
|
||||
def __init__(self, spec): |
||||
self._spec = spec |
||||
self._job = jobset.Job(spec, bin_hash=None, newline_on_success=True, travis=True, add_env={}, xml_report=None) |
||||
self._cidfile = spec.cidfile |
||||
self._cid = None |
||||
|
||||
def cid(self): |
||||
"""Gets cid of this container""" |
||||
if not self._cid: |
||||
self._cid = wait_for_file(self._cidfile) |
||||
return self._cid |
||||
|
||||
def mapped_port(self, port): |
||||
return docker_mapped_port(self.cid(), port) |
||||
|
||||
def kill(self, suppress_failure=False): |
||||
"""Sends kill signal to the container.""" |
||||
if suppress_failure: |
||||
self._job.suppress_failure_message() |
||||
return subprocess.call(['docker','kill', self.cid()]) == 0 |
||||
|
||||
def is_running(self): |
||||
"""Polls a job and returns True if given job is still running.""" |
||||
return self._job.state(jobset.NoCache()) == jobset._RUNNING |
Loading…
Reference in new issue