From c0ba5dac60889bb42a782d8b7cd518db9415df7f Mon Sep 17 00:00:00 2001 From: Sergei Antipov Date: Thu, 15 Feb 2018 15:24:38 +0700 Subject: [PATCH] Moved test script into bash file --- .travis.yml | 57 +------------------------------------------ tests/scripts/test.sh | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 56 deletions(-) create mode 100644 tests/scripts/test.sh diff --git a/.travis.yml b/.travis.yml index 768dcdd..c59ce5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,59 +66,4 @@ install: - bash tests/scripts/before_install.sh script: - # Test 1 - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} - # Idempotence test - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Delete all containers - - sudo docker kill mongo{1,2,3} && docker rm mongo{1,2,3} - - # Test 2 - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' - # Idempotence test - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Delete all containers - - sudo docker kill mongo{1,2,3} && docker rm mongo{1,2,3} - - # Test 3 - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' - # Idempotence test - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Delete all containers - - sudo docker kill mongo{1,2,3} && docker rm mongo{1,2,3} - - # Test 4 - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' - -e mongodb_security_authorization='enabled' - # Idempotence test - - > - ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} - -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' - -e mongodb_security_authorization='enabled' - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) + - bash tests/scripts/test.sh diff --git a/tests/scripts/test.sh b/tests/scripts/test.sh new file mode 100644 index 0000000..fe6c2a8 --- /dev/null +++ b/tests/scripts/test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# -*- mode: sh; -*- + +# File: test.sh +# Time-stamp: <2018-02-15 15:24:30> +# Copyright (C) 2018 Sergei Antipov +# Description: + +# set -o xtrace +set -o nounset +set -o errexit +set -o pipefail + +# Test 1 +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} +# Idempotence test +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} | \ + grep -q 'changed=0.*failed=0' && \ + (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) +# Delete all containers +docker kill mongo{1,2,3} && docker rm mongo{1,2,3} + +# Test 2 +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' +# Idempotence test +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' \ + | grep -q 'changed=0.*failed=0' \ + && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) +# Delete all containers +docker kill mongo{1,2,3} && docker rm mongo{1,2,3} + +# Test 3 +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' +# Idempotence test +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' \ + | grep -q 'changed=0.*failed=0' \ + && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) +# Delete all containers +docker kill mongo{1,2,3} && docker rm mongo{1,2,3} + +# Test 4 +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' +# Idempotence test +ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' \ + | grep -q 'changed=0.*failed=0' \ + && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)