ansible-role-mongodb/tests/scripts/test.sh

51 lines
3.7 KiB
Bash
Raw Normal View History

2018-02-15 08:24:38 +00:00
#!/usr/bin/env bash
# -*- mode: sh; -*-
# File: test.sh
2018-07-13 15:06:31 +00:00
# Time-stamp: <2018-07-13 11:05:31>
2018-02-15 08:24:38 +00:00
# Copyright (C) 2018 Sergei Antipov
# Description:
# set -o xtrace
set -o nounset
set -o errexit
2018-07-13 15:06:31 +00:00
package=${MONGODB_PACKAGE:-mongodb-org}
2018-02-15 08:24:38 +00:00
# Test 1
2018-07-13 15:06:31 +00:00
echo "ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION}"
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION}
2018-02-15 08:24:38 +00:00
# Idempotence test
2018-07-13 15:06:31 +00:00
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e image_name=${DISTRIBUTION}:${DIST_VERSION} | \
2018-02-26 09:07:56 +00:00
grep -q 'changed=0.*failed=0' && \
(echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
2018-02-15 08:24:38 +00:00
# Delete all containers
docker kill mongo{1,2,3} && docker rm mongo{1,2,3}
# Test 2
2018-07-13 15:06:31 +00:00
echo "ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled'"
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled'
2018-02-15 08:24:38 +00:00
# Idempotence test
2018-07-13 15:06:31 +00:00
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' \
2018-02-26 09:07:56 +00:00
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
2018-02-15 08:24:38 +00:00
# Delete all containers
docker kill mongo{1,2,3} && docker rm mongo{1,2,3}
# Test 3
2018-07-13 15:06:31 +00:00
echo "ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'"
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
2018-02-15 08:24:38 +00:00
# Idempotence test
2018-07-13 15:06:31 +00:00
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' \
2018-02-26 09:07:56 +00:00
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
2018-02-15 08:24:38 +00:00
# Delete all containers
docker kill mongo{1,2,3} && docker rm mongo{1,2,3}
# Test 4
2018-07-13 15:06:31 +00:00
echo "ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled'"
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled'
2018-02-15 08:24:38 +00:00
# Idempotence test
2018-07-13 15:06:31 +00:00
ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_package=${package} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' \
2018-02-26 09:07:56 +00:00
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)