From 484e5c3c711b4dbb1bf06d8904ff1bf367594679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samu=CC=81el=20Jo=CC=81n=20Gunnarsson?= Date: Wed, 27 Sep 2017 11:24:48 +0200 Subject: [PATCH] Started testing docker executions --- tests/setup_tests.sh | 25 ++++++++++++++++++++++++- tests/test_inside_docker.sh | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 tests/test_inside_docker.sh diff --git a/tests/setup_tests.sh b/tests/setup_tests.sh index 641f6d4..f151ba2 100755 --- a/tests/setup_tests.sh +++ b/tests/setup_tests.sh @@ -1 +1,24 @@ -echo "Keyrsla fyrir $1" +#!/bin/sh -xe + +# This script starts docker and systemd (if el7) + +# Version of CentOS/RHEL +el_version=$1 + + # Run tests in Container +if [ "$el_version" = "6" ]; then + +sudo docker run --rm=true -v `pwd`:/nagios-plugins:rw centos:centos${OS_VERSION} /bin/bash -c "bash -xe /nagios-plugins/tests/test_inside_docker.sh ${OS_VERSION}" + +elif [ "$el_version" = "7" ]; then + +docker run --privileged -d -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup -v `pwd`:/nagios-plugins:rw centos:centos${OS_VERSION} /usr/sbin/init +DOCKER_CONTAINER_ID=$(docker ps | grep centos | awk '{print $1}') +docker logs $DOCKER_CONTAINER_ID +docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "bash -xe /nagios-plugins/tests/test_inside_docker.sh ${OS_VERSION}; + echo -ne \"------\nEND NAGIOS-PLUGINS TESTS\n\";" +docker ps -a +docker stop $DOCKER_CONTAINER_ID +docker rm -v $DOCKER_CONTAINER_ID + +fi diff --git a/tests/test_inside_docker.sh b/tests/test_inside_docker.sh new file mode 100755 index 0000000..09d9cff --- /dev/null +++ b/tests/test_inside_docker.sh @@ -0,0 +1,2 @@ +echo "Keyrsla fyrir CentOS $1" +ls -l /