Skip to content

Commit

Permalink
test: improve integration tests
Browse files Browse the repository at this point in the history
* Don't hide the output of the setup commands, it's useful to both see
  that the output is visually correct and allow to debug any error in
  setting up the integration tests.
* Allow to pass arguments to the integrations tests so that the deletion
  of the test instances and temporarily generated files can be accessed
  for debugging.

Change-Id: Ie104d51cd548b6dd41296ffc4e3126182f3f455a
  • Loading branch information
volans- committed May 18, 2020
1 parent 337709d commit 53482a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion cumin/tests/integration/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if [[ -z "${1}" ]]; then
exit 1
fi
ENV_NAME="${1}"
SKIP_DELETION=0
if [[ -n "${2}" && "${2}" -eq "1" ]]; then
SKIP_DELETION=1
fi

ENV_FILE="$(dirname "${0}")/${ENV_NAME}.sh"
if [[ ! -f "${ENV_FILE}" ]]; then
Expand All @@ -29,6 +33,11 @@ source "${ENV_FILE}"
# The sourced ENV_FILE must register any docker instance in this variable for cleanup
DOCKER_INSTANCES=""
function exit_trap() {
if [[ "${SKIP_DELETION}" -eq "1" ]]; then
_log "Skip deletion set: docker instances and temporary directory were not removed"
return
fi

_log "Removing docker instances"
docker rm -f ${DOCKER_INSTANCES} > /dev/null

Expand All @@ -49,6 +58,6 @@ _log "Unique identifier is ${CUMIN_IDENTIFIER}"
trap 'exit_trap' EXIT

setup
sleep 1
sleep 3
run_tests
exit "${?}"
4 changes: 2 additions & 2 deletions cumin/tests/integration/transports/clustershell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ EOF
}

function run_tests() {
USER=root SUDO_USER=user cumin --force -c "${CUMIN_TMPDIR}/config.yaml" "${CUMIN_IDENTIFIER}-[1-2,5]" "touch /tmp/maybe" > /dev/null 2>&1
USER=root SUDO_USER=user cumin --force -c "${CUMIN_TMPDIR}/config.yaml" "${CUMIN_IDENTIFIER}-[1-5]" 'echo -e "First\nSecond\nThird" > /tmp/out' > /dev/null 2>&1
USER=root SUDO_USER=user cumin --force -c "${CUMIN_TMPDIR}/config.yaml" "${CUMIN_IDENTIFIER}-[1-2,5]" "touch /tmp/maybe"
USER=root SUDO_USER=user cumin --force -c "${CUMIN_TMPDIR}/config.yaml" "${CUMIN_IDENTIFIER}-[1-5]" 'echo -e "First\nSecond\nThird" > /tmp/out'
py.test -n auto --strict --cov-report term-missing --cov=cumin cumin/tests/integration
}
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ commands =
sphinx: python setup.py build_sphinx -b man
# Fix missing space after bold blocks in man page: https://github.com/ribozz/sphinx-argparse/issues/80
sphinx: sed -i='' -e 's/^\.B/.B /' '{toxinidir}/doc/build/man/cumin.1'
integration: "{toxinidir}/cumin/tests/integration/docker.sh" "transports/clustershell"
integration: "{toxinidir}/cumin/tests/integration/docker.sh" "transports/clustershell" {posargs}
deps =
# Use install_requires and the additional extras_require[NAME] from setup.py
unitbase: .[tests-base]
Expand Down

0 comments on commit 53482a5

Please sign in to comment.