Skip to content

Commit

Permalink
Make tests more reliable
Browse files Browse the repository at this point in the history
* ensure config and creds are ready before attempting auth
* warn instead of error on DUT shutdown failures

change-type: patch
  • Loading branch information
ab77 committed Jul 4, 2024
1 parent 3ffd7d8 commit a094005
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/balena-tests/balena.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# shellcheck disable=SC2154,SC2034,SC1090
set -ae
set -aeu

curl_opts="--retry 3 --fail"
if [[ $VERBOSE =~ on|On|Yes|yes|true|True ]]; then
Expand Down Expand Up @@ -41,7 +41,9 @@ function shutdown_dut() {

if [[ -n $balena_device_uuid ]]; then
with_backoff balena device "${balena_device_uuid}"
with_backoff balena device shutdown -f "${balena_device_uuid}"
if ! with_backoff balena device shutdown -f "${balena_device_uuid}"; then
echo 'DUT failed to shutdown properly'
fi
fi
}

Expand Down Expand Up @@ -303,7 +305,17 @@ GUEST_IMAGE=${GUEST_IMAGE:-/balena/balena.img}
OS_VERSION="$(get_os_version)"
TEST_FLEET=${TEST_FLEET:-test-fleet}

[[ -f "$CONF" ]] && source "${CONF}"
# wait here until global config is ready
until [[ -s "$CONF" ]]; do
sleep "$(( (RANDOM % 5) + 5 ))s"
done
source "${CONF}"

# wait her until we have valid login credentials
until [[ -n "$SUPERUSER_EMAIL" ]] && [[ -n "$SUPERUSER_PASSWORD" ]]; do
sleep "$(( (RANDOM % 5) + 5 ))s"
source "${CONF}"
done

update_ca_certificates # ensure self-signed root CA certificate(s) trust

Expand Down

0 comments on commit a094005

Please sign in to comment.