nils has proposed merging lp:~dernils/duplicity/DockerfileConvenience into lp:duplicity.
Requested reviews: duplicity-team (duplicity-team) For more details, see: https://code.launchpad.net/~dernils/duplicity/DockerfileConvenience/+merge/323713 -- Your team duplicity-team is requested to review the proposed merge of lp:~dernils/duplicity/DockerfileConvenience into lp:duplicity.
=== added directory 'testing/testinfrastructure' === added file 'testing/testinfrastructure/check_docker_container.sh' --- testing/testinfrastructure/check_docker_container.sh 1970-01-01 00:00:00 +0000 +++ testing/testinfrastructure/check_docker_container.sh 2017-05-06 16:14:31 +0000 @@ -0,0 +1,64 @@ +#!/bin/bash + +# Author: Erik Kristensen +# Email: [email protected] +# License: MIT +# Nagios Usage: check_nrpe!check_docker_container!_container_id_ +# Usage: ./check_docker_container.sh _container_id_ +# +# Depending on your docker configuration, root might be required. If your nrpe user has rights +# to talk to the docker daemon, then root is not required. This is why root privileges are not +# checked. +# +# The script checks if a container is running. +# OK - running +# WARNING - restarting +# CRITICAL - stopped +# UNKNOWN - does not exist +# +# CHANGELOG - March 20, 2017 +# - Removes Ghost State Check, Checks for Restarting State, Properly finds the Networking IP addresses +# - Returns unknown (exit code 3) if docker binary is missing, unable to talk to the daemon, or if container id is missing + +CONTAINER=$1 + +if [ "x${CONTAINER}" == "x" ]; then + echo "UNKNOWN - Container ID or Friendly Name Required" + exit 3 +fi + +if [ "x$(which docker)" == "x" ]; then + echo "UNKNOWN - Missing docker binary" + exit 3 +fi + +docker info > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "UNKNOWN - Unable to talk to the docker daemon" + exit 3 +fi + +RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2> /dev/null) + +if [ $? -eq 1 ]; then + echo "UNKNOWN - $CONTAINER does not exist." + exit 2 +fi + +if [ "$RUNNING" == "false" ]; then + echo "CRITICAL - $CONTAINER is not running." + exit 1 +fi + +RESTARTING=$(docker inspect --format="{{.State.Restarting}}" $CONTAINER) + +if [ "$RESTARTING" == "true" ]; then + echo "WARNING - $CONTAINER state is restarting." + exit 3 +fi + +STARTED=$(docker inspect --format="{{.State.StartedAt}}" $CONTAINER) +NETWORK=$(docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $CONTAINER) + +echo "OK - $CONTAINER is running. IP: $NETWORK, StartedAt: $STARTED" +exit 0 \ No newline at end of file === added directory 'testing/testinfrastructure/ftp_server' === added file 'testing/testinfrastructure/ftp_server/Dockerfile' --- testing/testinfrastructure/ftp_server/Dockerfile 1970-01-01 00:00:00 +0000 +++ testing/testinfrastructure/ftp_server/Dockerfile 2017-05-06 16:14:31 +0000 @@ -0,0 +1,32 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright 2017 Nils Tekampe <[email protected]> +# +# This file is part of duplicity. +# It is the Dockerfile of a simple ftp server that is used for backend testing +# +# Duplicity is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# Duplicity is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with duplicity; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +FROM stilliard/pure-ftpd + +# Install some tools for convenience +RUN apt-get update \ + && apt-get install -y \ + nano \ + mc \ + && rm -rf /var/lib/apt/lists/* + +# Creating a ftp user account for testing testuser:testuser +COPY pureftpd.passwd /etc/pure-ftpd/passwd/pureftpd.passwd === added file 'testing/testinfrastructure/ftp_server/pureftpd.passwd' --- testing/testinfrastructure/ftp_server/pureftpd.passwd 1970-01-01 00:00:00 +0000 +++ testing/testinfrastructure/ftp_server/pureftpd.passwd 2017-05-06 16:14:31 +0000 @@ -0,0 +1,1 @@ +testuser:$1$36McU8X0$bjd0mfn7qCisOoqrSLFl01:1000:1000::/home/ftpusers/testuser/./:::::::::::: \ No newline at end of file === added file 'testing/testinfrastructure/setup.sh' --- testing/testinfrastructure/setup.sh 1970-01-01 00:00:00 +0000 +++ testing/testinfrastructure/setup.sh 2017-05-06 16:14:31 +0000 @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Copyright 2017 Nils Tekampe <[email protected]> +# +# This file is part of duplicity. +# This script sets up a test network for the tests of dupclicity +# This script takes the assumption that the containers for the testinfrastructure do deither run +# or they are removed. It is not intended to have stopped containers. +# +# Duplicity is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# Duplicity is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with duplicity; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +# Check whether a specific docker network for testing is already exisitng. If not, create it. +docker network inspect testnetwork &> /dev/null + +if [ $? -ne 0 ]; then + echo "docker testnetwork not found. Creating network." + docker network create --subnet=10.10.10.0/24 testnetwork + +fi + + +# Remove all runnging instances of the test system and als remove the containers. This ensure +# that the test infrastructure is frehshly started. +docker rm $(docker stop $(docker ps -a -q --filter name=ftpd_server --format="{{.ID}}")) +docker rm $(docker stop $(docker ps -a -q --filter name=duplicity_test --format="{{.ID}}")) + + +# Start the containers. Docker run will automatically download the image if necessary +docker run -d --net testnetwork --ip 10.10.10.3 --name ftpd_server -p 21:21 -p 30000-30009:30000-30009 -e "PUBLICHOST=localhost" dernils/duplicity_testinfrastructure_ftp +docker run --name duplicity_test --net testnetwork --ip 10.10.10.2 -it dernils/duplicitytest:latest
_______________________________________________ Mailing list: https://launchpad.net/~duplicity-team Post to : [email protected] Unsubscribe : https://launchpad.net/~duplicity-team More help : https://help.launchpad.net/ListHelp

