Skip to content

Commit

Permalink
scripts/run_tests.sh: Add check dependencies
Browse files Browse the repository at this point in the history
Check that all the dependencies to run the test script are in place and
bail out early before spending time on needless work.

The dependencies are:
* running as root
* docker has to function
* pytest-3 needs to be installed

Signed-off-by: Leonard Foerster <[email protected]>
  • Loading branch information
foersleo committed Jun 5, 2024
1 parent 6b61a82 commit 446b5b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/lib_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ export NITRO_CLI_ARTIFACTS="$SCRIPTDIR/../build"
ARCH="$(uname -m)"
AWS_ACCOUNT_ID=667861386598

check_dependencies() {
# check we are root
if [ "${EUID}" -ne 0 ]
then
echo "The testing requires the capabilities to load and unload kernel modules. Please run as root."
exit 1
fi

# Check that docker is available
if ! type docker; then
echo "Could not find docker installed. Please ensure you have docker installed and reachable through your PATH."
exit 1
fi

# ...and usable
if ! docker ps; then
echo "Docker seems to be not functional. Please ensure docker can be used by $USER."
exit 1
fi

# The testing relies on pytest-3 for orchestration. Ensure we have that installed.
if ! type pytest-3; then
echo "Could not find pytest-3 installed. Please ensure you have pytest-3 installed and reachable through your PATH."
exit 1
fi
}

test_start() {
TEST_SUITES_TOTAL=$((TEST_SUITES_TOTAL + 1))
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ source "$SCRIPTDIR/lib_tests.sh"

trap test_failed ERR

check_dependencies

# Build and install NE CLI
build_and_install

Expand Down

0 comments on commit 446b5b7

Please sign in to comment.