Skip to content
Permalink
Browse files

Merge 135b339 into 5461777

  • Loading branch information...
megies committed Aug 1, 2016
2 parents 5461777 + 135b339 commit 224e9fe0acf1ccdd058833922e4940180e9037bd
@@ -22,6 +22,16 @@ Running it without any commands will execute the test suite on all available ima
$ ./run_obspy_tests.sh
```

Additionally arguments can be passed to `obspy-runtests` in the Docker images
with the `-e` argument. To for example only the MiniSEED test suite on CentOS
7, do

```bash
$ ./run_obspy_tests.sh -eio.mseed centos_7
```

Make sure to use the `-e` argument before the list of images to run on.

If the image is not yet available it will be created automatically. The
`base_images` directory contains all available images receipts.

@@ -7,6 +7,7 @@ RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.
RUN yum -y upgrade || true
RUN yum install -y gcc numpy scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-basemap python-basemap-data python-pip python-requests python-decorator
RUN easy_install -U setuptools pip
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
# Force agg.
RUN mkdir -p /root/.matplotlib && echo "backend: agg" > /root/.matplotlib/matplotlibrc
@@ -5,5 +5,6 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip ttf-bitstream-vera python-decorator python-requests
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
RUN echo "backend: agg" > /etc/matplotlibrc
@@ -5,5 +5,6 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip ttf-bitstream-vera python-decorator python-requests
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
RUN echo "backend: agg" > /etc/matplotlibrc
@@ -5,4 +5,5 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip python-tornado ttf-bitstream-vera python-decorator python-requests
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -5,4 +5,5 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN yum -y upgrade || true
RUN yum install -y gcc numpy scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-basemap python-basemap-data python-tornado python-pip python-decorator python-requests
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -4,4 +4,5 @@ MAINTAINER Lion Krischer

# Can fail on occasion.
RUN dnf -y upgrade || true
RUN dnf install -y gcc redhat-rpm-config numpy scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-basemap python-basemap-data python-tornado python-pip python-decorator python-requests python-flake8 python-future
RUN dnf install -y gcc redhat-rpm-config numpy scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-basemap python-basemap-data python-tornado python-pip python-decorator python-requests python-future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -5,5 +5,6 @@ MAINTAINER Lion Krischer
RUN zypper --non-interactive addrepo http://download.opensuse.org/repositories/Application:/Geo/openSUSE_13.2/Application:Geo.repo
RUN zypper --non-interactive --no-gpg-checks refresh
RUN zypper --non-interactive update
RUN zypper --non-interactive install gcc python-devel python-numpy python-scipy python-matplotlib python-SQLAlchemy python-lxml python-mock python-pip python-tornado python-requests python-decorator python-flake8 python-basemap python-basemap-data python-nose ca-certificates-mozilla
RUN zypper --non-interactive install gcc python-devel python-numpy python-scipy python-matplotlib python-SQLAlchemy python-lxml python-mock python-pip python-tornado python-requests python-decorator python-basemap python-basemap-data python-nose ca-certificates-mozilla
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -5,6 +5,7 @@ MAINTAINER Lion Krischer
RUN zypper --non-interactive addrepo http://download.opensuse.org/repositories/Application:/Geo/openSUSE_Leap_42.1/Application:Geo.repo
RUN zypper --non-interactive --no-gpg-checks refresh
RUN zypper --non-interactive update
RUN zypper --non-interactive install gcc python-devel python-numpy python-scipy python-matplotlib python-SQLAlchemy python-lxml python-mock python-pip python-tornado python-requests python-decorator python-flake8 python-basemap python-basemap-data python-nose
RUN zypper --non-interactive install gcc python-devel python-numpy python-scipy python-matplotlib python-SQLAlchemy python-lxml python-mock python-pip python-tornado python-requests python-decorator python-basemap python-basemap-data python-nose
RUN pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
RUN zypper --non-interactive install ca-certificates-mozilla
@@ -5,5 +5,6 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip python-tornado ttf-bitstream-vera python-decorator python-requests
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
RUN echo "backend: agg" > /etc/matplotlibrc
@@ -5,4 +5,5 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip python-tornado ttf-bitstream-vera python-requests python-decorator
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -5,4 +5,5 @@ MAINTAINER Lion Krischer
# Can fail on occasion.
RUN apt-get update && apt-get upgrade || true
RUN apt-get -y install python-numpy python-scipy python-matplotlib python-sqlalchemy python-lxml python-mock python-mpltoolkits.basemap python-mpltoolkits.basemap-data python-pip python-tornado ttf-bitstream-vera
RUN pip install flake8 future
RUN pip install future
RUN pip install https://github.com/Damgaard/PyImgur/archive/9ebd8bed9b3d0ae2797950876f5c1e64a560f7d8.zip
@@ -1,4 +1,26 @@
#!/bin/bash

DATETIME=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
LOG_DIR_BASE=logs/$DATETIME
mkdir -p $LOG_DIR_BASE

# Parse the additional args later passed to `obspy-runtests` in
# the docker images.
extra_args=""
while getopts "e:" opt; do
case "$opt" in
e) extra_args=', "'$OPTARG'"'
;;
esac
done

# This bracket is closed at the very end and causes a redirection of everything
# to the logfile as well as stdout.
{
# Delete all but the last 15 log directories. The `+16` is intentional. Fully
# POSIX compliant version adapted from http://stackoverflow.com/a/34862475/1657047
ls -tp logs | tail -n +16 | xargs -I % rm -rf -- logs/%

OBSPY_PATH=$(dirname $(dirname $(pwd)))

# Remove all test images stored locally. Otherwise they'll end up on the
@@ -10,7 +32,6 @@ rm -rf $OBSPY_PATH/obspy/station/tests/images/testrun
DOCKERFILE_FOLDER=base_images
TEMP_PATH=temp
NEW_OBSPY_PATH=$TEMP_PATH/obspy
DATETIME=$(date -u +"%Y-%m-%dT%H-%M-%SZ")

# Determine the docker binary name. The official debian packages use docker.io
# for the binary's name due to some legacy docker package.
@@ -20,7 +41,6 @@ DOCKER=`which docker.io || which docker`
# file.
python -c "import obspy"


# Create temporary folder.
rm -rf $TEMP_PATH
mkdir -p $TEMP_PATH
@@ -50,6 +70,8 @@ else
echo "Bad value for OBSPY_DOCKER_TEST_SOURCE_TREE: $OBSPY_DOCKER_TEST_SOURCE_TREE"
exit 1
fi
FULL_VERSION=`cat $NEW_OBSPY_PATH/obspy/RELEASE-VERSION`
COMMIT=`cd $OBSPY_PATH && git log -1 --pretty=format:%H`


# Copy the install script.
@@ -72,7 +94,7 @@ create_image () {
if [ "$has_image" ]; then
printf "\e[101m\e[30m >>> Image '$image_name' already exists.\e[0m\n"
else
printf "\e[101m\e[30m Image '$image_name'will be created.\e[0m\n"
printf "\e[101m\e[30m Image '$image_name' will be created.\e[0m\n"
$DOCKER build -t obspy:$image_name $image_path
fi
}
@@ -83,10 +105,10 @@ run_tests_on_image () {
image_name=$1;
printf "\n\e[101m\e[30m >>> Running tests for image '"$image_name"'...\e[0m\n"
# Copy dockerfile and render template.
sed 's/{{IMAGE_NAME}}/'$image_name'/g' scripts/Dockerfile_run_tests.tmpl > $TEMP_PATH/Dockerfile
sed "s/{{IMAGE_NAME}}/$image_name/g; s/{{EXTRA_ARGS}}/$extra_args/g" scripts/Dockerfile_run_tests.tmpl > $TEMP_PATH/Dockerfile

# Where to save the logs, and a random ID for the containers.
LOG_DIR=logs/$DATETIME/$image_name
LOG_DIR=${LOG_DIR_BASE}/$image_name
mkdir -p $LOG_DIR
ID=$RANDOM-$RANDOM-$RANDOM

@@ -96,6 +118,8 @@ run_tests_on_image () {

$DOCKER cp $ID:/INSTALL_LOG.txt $LOG_DIR
$DOCKER cp $ID:/TEST_LOG.txt $LOG_DIR
$DOCKER cp $ID:/failure $LOG_DIR
$DOCKER cp $ID:/success $LOG_DIR

$DOCKER cp $ID:/obspy/obspy/imaging/tests/images/testrun $LOG_DIR/imaging_testrun
$DOCKER cp $ID:/obspy/obspy/core/tests/images/testrun $LOG_DIR/core_testrun
@@ -143,4 +167,30 @@ for image_name in $($DOCKER images | grep obspy | awk '{print $2}'); do
run_tests_on_image $image_name;
done

# set commit status
# helper function to determine overall success/failure across all images
# env variable OBSPY_COMMIT_STATUS_TOKEN has to be set for authorization
overall_status() {
ls ${LOG_DIR_BASE}/*/failure 2>&1 > /dev/null && return 1
ls ${LOG_DIR_BASE}/*/success 2>&1 > /dev/null && return 0
return 1
}
# encode parameter part of the URL, using requests as it is installed anyway..
# (since we use python to import obspy to generate RELEASE-VERSION above)
# it's just looking up the correct quoting function from urllib depending on
# py2/3 and works with requests >= 1.0 (which is from 2012)
FULL_VERSION_URLENCODED=`python -c "from requests.compat import quote; print(quote(\"${FULL_VERSION}\"))"`
COMMIT_STATUS_TARGET_URL="http://tests.obspy.org/?version=${FULL_VERSION_URLENCODED}"
if overall_status ;
then
COMMIT_STATUS=success
COMMIT_STATUS_DESCRIPTION="Docker tests succeeded:"
else
COMMIT_STATUS=failed
COMMIT_STATUS_DESCRIPTION="Docker tests failed:"
fi
curl -H "Content-Type: application/json" -H "Authorization: token ${OBSPY_COMMIT_STATUS_TOKEN}" --request POST --data "{\"state\": \"${COMMIT_STATUS}\", \"context\": \"docker-testbot\", \"description\": \"${COMMIT_STATUS_DESCRIPTION}\", \"target_url\": \"${COMMIT_STATUS_TARGET_URL}\"}" https://api.github.com/repos/obspy/obspy/statuses/${COMMIT}

rm -rf $TEMP_PATH

} 2>&1 | tee -a $LOG_DIR_BASE/docker.log
@@ -5,4 +5,4 @@ MAINTAINER Lion Krischer
ADD install_and_run_tests_on_image.sh install_and_run_tests_on_image.sh
ADD obspy /obspy
RUN echo {{IMAGE_NAME}} > container_name.txt
CMD ["/bin/bash", "install_and_run_tests_on_image.sh"]
CMD ["/bin/bash", "install_and_run_tests_on_image.sh"{{EXTRA_ARGS}}]
@@ -6,7 +6,7 @@ no_color='\e[0m'
# Install ObsPy and run the tests.
cd /obspy

pip install -v -e . > /INSTALL_LOG.txt 2>&1
pip install -v -e . 2>&1 | tee /INSTALL_LOG.txt

if [ $? != 0 ]; then
echo -e "${red}Installation failed!${no_color}"
@@ -16,13 +16,15 @@ fi

cd

obspy-runtests -r --keep-images --node=docker-$(cat /container_name.txt) > /TEST_LOG.txt 2>&1
obspy-runtests -r --keep-images --no-flake8 --node=docker-$(cat /container_name.txt) $1 2>&1 | tee /TEST_LOG.txt


if [ $? != 0 ]; then
echo -e "${red}Tests failed!${no_color}"
touch /failure
else
echo -e "${green}Tests successful!${no_color}"
touch /success
fi

echo "Done with everything!"

0 comments on commit 224e9fe

Please sign in to comment.
You can’t perform that action at this time.