Skip to content

Commit

Permalink
fixup! Create test scenarios with ipalab-config
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeffman committed Feb 9, 2025
1 parent 7c829e3 commit a892d37
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions infra/scenarios/run_test_scenario.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

BASEDIR="$(dirname $(readlink -f "$0"))"
BASEDIR="$(dirname "$(readlink -f "$0")")"
TOPDIR="$(dirname "$(dirname "${BASEDIR}")")"
TESTDIR="${TOPDIR}/tests"

Expand Down Expand Up @@ -45,7 +45,7 @@ do
h) usage && exit 1 ;;
a) RUN_ALL="Y" ; export SKIP_GIT_TEST="True" ;;
k) SHUTDOWN="YES" ;;
m) MODULES+="${OPTARG}" ;;
m) MODULES+=("${OPTARG}") ;;
*) die "Invalid option: ${option}" ;;
esac
done
Expand Down Expand Up @@ -81,6 +81,7 @@ declare -a IGNORE
for module in $(split <<< "${IPA_DISABLED_MODULES[@]}")
do
grep -qe "^None" <<< "${module}" && continue
# shellcheck disable=SC2207
IGNORE+=($(find "${TESTDIR}/${module}" -name "test_*.yml" ))
done

Expand All @@ -94,14 +95,15 @@ done
echo "${IGNORE[@]}" | tr " " "\n" > /tmp/ignored_tests

# remove duplicates
read -r -a IGNORE <<< "$(echo ${IGNORE[@]} | tr " " "\n" | sort | uniq | tr "\n" " ")"
read -r -a IGNORE <<< "$(echo "${IGNORE[@]}" | tr " " "\n" | sort | uniq | tr "\n" " ")"

if [ -n "${IPA_ENABLED_MODULES:-}" ] || [ -n "${IPA_ENABLED_TESTS:-}" ]
then
# Get list of enabled modules
for module in $(split <<< "${IPA_ENABLED_MODULES[@]}")
do
grep -qe "^None" <<< "${module}" && continue
# shellcheck disable=SC2207
PLAYBOOKS+=($(find "${TESTDIR}/${module}" -name "test_*.yml" ))
done

Expand All @@ -112,14 +114,17 @@ then
PLAYBOOKS+=("$(find "${TESTDIR}" -name "${module}.yml" )")
done
# remove duplicates
read -r -a PLAYBOOKS <<< "$(echo ${PLAYBOOKS[@]} | tr " " "\n" | sort | uniq | tr "\n" " ")"
read -r -a PLAYBOOKS <<< "$(echo "${PLAYBOOKS[@]}" | tr " " "\n" | sort | uniq | tr "\n" " ")"

else
echo "INFO: Running all tests."
# shellcheck disable=SC2207
PLAYBOOKS=($(find "${TESTDIR}" -name "test_*.yml" | tr "\n" " "))
fi

test_playbooks="$(grep -Fxvf /tmp/ignored_tests <(echo "${PLAYBOOKS[@]}" | tr " " "\n"))"
ansible-playbook -i ${INVENTORY} $test_playbooks

[ "${SHUTDOWN:-"NO"}" == "YES" ] && infra/scenarios/stop-scenario


0 comments on commit a892d37

Please sign in to comment.