From de9757bd6b5a8629dcfa51886a247d17bd7fd3d2 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Fri, 16 Jun 2017 13:35:07 -0700 Subject: [PATCH] Add testing infrastructure Signed-off-by: Eli Uriegas --- Jenkinsfile | 42 ++++++++++++++++++++++++++++++++++++++++++ Makefile | 29 +++++++++++++++++++++++++++++ verify-docker-install | 29 +++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 Jenkinsfile create mode 100644 Makefile create mode 100644 verify-docker-install diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a38a51e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,42 @@ +#!groovy +properties( + [ + buildDiscarder(logRotator(numToKeepStr: '20')), + parameters([ + string(defaultValue: '', description: 'Expected docker version output of --version flag.', name: 'EXPECTED_VERSION'), + string(defaultValue: '', description: 'Expected docker gitcommit output of --version flag.', name: 'EXPECTED_GITCOMMIT'), + ]) + ] +) + +def verifyTargets = [ + 'verify-install-centos-7', + 'verify-install-fedora-24', + 'verify-install-fedora-25', + 'verify-install-debian-wheezy', + 'verify-install-debian-jessie', + 'verify-install-debian-stretch', + 'verify-install-ubuntu-trusty', + 'verify-install-ubuntu-xenial', + 'verify-install-ubuntu-yakkety', + 'verify-install-ubuntu-zesty', +] + +def genVerifyJob(String t) { + return [ "${t}" : { -> + stage("${t}") { + wrappedNode(label: 'aufs', cleanWorkspace: true) { + checkout scm + sh("make clean ${t}.log") + archiveArtifacts '*.log' + } + } + } ] +} + +def verifyJobs = [:] +for (t in verifyTargets) { + verifyJobs << genVerifyJob(t) +} + +parallel(verifyJobs) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..785e8d5 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +SHELL:=/bin/bash +VERIFY_INSTALL_DISTROS:=$(addprefix verify-install-,centos-7 fedora-24 fedora-25 debian-wheezy debian-jessie debian-stretch ubuntu-trusty ubuntu-xenial ubuntu-yakkety ubuntu-zesty) +EXPECTED_VERSION?= +EXPECTED_GITCOMMIT?= + +needs_version: +ifndef EXPECTED_VERSION + $(error EXPECTED_VERSION is undefined) +endif + +needs_gitcommit: +ifndef EXPECTED_GITCOMMIT + $(error EXPECTED_GITCOMMIT is undefined) +endif + +check: $(VERIFY_INSTALL_DISTROS) + +clean: + $(RM) *.log + +verify-install-%.log: needs_version needs_gitcommit + set -o pipefail && docker run \ + --rm \ + -v $(CURDIR):/v \ + -w /v \ + $(subst -,:,$*) \ + bash verify-docker-install "$(EXPECTED_VERSION)" "$(EXPECTED_GITCOMMIT)" | tee $@ + +# TODO: Add a target for uploading final script to s3 diff --git a/verify-docker-install b/verify-docker-install new file mode 100644 index 0000000..41f9ae6 --- /dev/null +++ b/verify-docker-install @@ -0,0 +1,29 @@ +#!/bin/bash -e +expected_version=$1 +expected_gitcommit=$2 +( + echo "Executing installation script!" + sh install.sh +) +docker_version=$(docker --version) +if [ $? -ne 0 ]; then + echo "ERROR: Did Docker get installed?" + exit 3 +fi +installed_version=$(echo $docker_version | awk '{print$3}') +installed_gitcommit=$(echo $docker_version | awk '{print$5}') +echo $docker_version +echo -n "Checking if installed version '$installed_version' matches '$expected_version'... " +if [[ "$installed_version" =~ "$expected_version" ]]; then + echo "PASSED!" +else + echo "FAILED!" + exit 1 +fi +echo -n "Checking if installed gitcommit '$installed_gitcommit' matches '$expected_gitcommit'... " +if [[ "$installed_gitcommit" =~ "$expected_gitcommit" ]]; then + echo "PASSED!" +else + echo "FAILED!" + exit 2 +fi