Skip to content

Commit

Permalink
fixup! utils: Rewrite run-tests.sh to use functions and extenal scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeffman committed Jul 15, 2024
1 parent 8f3899c commit c3a15b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions utils/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ positional arguments:
optional arguments:
-h display this message and exit
-a Do not install Ansible, use host's provided one.
-A ANSIBLE Ansible version to use, e.g. "ansible-core==2.16.0"
-a ANSIBLE Ansible version to use, e.g. "ansible-core==2.16.0"
(default: latest ansible-core for the python version)
-A Do not install Ansible, use host's provided one.
-c CONTAINER use container CONTAINER to run tests
-K keep container, even if tests succeed
-l list available images
Expand Down Expand Up @@ -73,15 +73,15 @@ unset ANSIBLE_VERSION

# Process command options

while getopts ":haa:Ac:ei:Klm:p:s:S:vx" option
while getopts ":ha:Ac:ei:Klm:p:s:S:vx" option
do
case "$option" in
h) help && exit 0 ;;
A)
A)
[ -n "${ANSIBLE_VERSION:-""}" ] && die "Can't use -A with '-a'"
SKIP_ANSIBLE="YES"
;;
a)
a)
[ "${SKIP_ANSIBLE:-"no"}" == "YES" ] && die "Can't use -A with '-a'"
ANSIBLE_VERSION="${OPTARG}"
;;
Expand All @@ -91,7 +91,7 @@ do
K) STOP_CONTAINER="N" ;;
l) "${SCRIPTDIR}"/setup_test_container.sh -l && exit 0 || exit 1 ;;
m) MEMORY="${OPTARG}" ;;
p) ansible_interpreter="${OPTARG}" ;;
p) ansible_interpreter="${OPTARG}" ;;
s)
[ ${SPLITS} -ne 0 ] && die -u "Can't use '-S' with '-s'"
if [ -d "${TOPDIR}/tests/${OPTARG}" ]
Expand Down
12 changes: 7 additions & 5 deletions utils/setup_test_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,21 @@ log info "Testing kinit with admin."
# shellcheck disable=SC2154
log info "Creating inventory."
make_inventory "${scenario}" "${engine}" "${ansible_interpreter:-"/usr/bin/python3"}"
if [ -z "${inventory}" ]
if [ -z "${inventory:-''}" ]
then
log error "Could not create inventory file."
else
# shellcheck disable=SC2154
log info "Inventory path: [${inventory}]"
# shellcheck disable=SC2154
log debug "$(cat "${inventory}")"
if [ "${ansible_test}" == "yes" ]
then
log info "Testing Asnible connection."
run_if_exists ansible_ping "${inventory}"
log info "Querying installed software"
run_if_exists query_container_installed_software
log info "Testing Ansible connection."
# shellcheck disable=SC2154
run_if_exists ansible_ping "${inventory}"
log info "Querying installed software"
run_if_exists query_container_installed_software
fi
fi

0 comments on commit c3a15b3

Please sign in to comment.