Skip to content

Commit

Permalink
automated: linux: add ota-apps test
Browse files Browse the repository at this point in the history
Signed-off-by: Milosz Wasilewski <[email protected]>
  • Loading branch information
mwasilew committed Nov 17, 2023
1 parent 2ff7a1f commit 4323efe
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
28 changes: 28 additions & 0 deletions automated/linux/ota-apps/ota-apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2023 Foundries.io
metadata:
format: Lava-Test Test Definition 1.0
name: ota-apps
description: "Download OTA apps update. Use eiter proper or corrupt app"

maintainer:
- [email protected]
os:
- openembedded
scope:
- functional

devices:
- imx8mm
- imx6ull

params:
TYPE: "regular"
APPNAME: "shellhttpd"
VERSION: ""
DEBUG: "false"
run:
steps:
- cd ./automated/linux/ota-apps
- ./update-apps.sh -t "${TYPE}" -a "${APPNAME}" -v "${VERSION}" -d "${DEBUG}"
- ../../utils/send-to-lava.sh ./output/result.txt
92 changes: 92 additions & 0 deletions automated/linux/ota-apps/update-apps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2023 Foundries.io Ltd.

# shellcheck disable=SC1091
. ../../lib/sh-test-lib
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/result.txt"
export RESULT_FILE
TYPE="regular"
APPNAME=""
VERSION=""
DEBUG="false"

usage() {
echo "\
Usage: $0 [-t <regular|corrupt>] [-a <app name>] [-d <true|false> ] [-v <expected target version>]
-t <regular|corrupt>
This determines type of upgrade test performed:
regular: register with proper app. OTA should be successful
corrupt: register with corrupt app. OTA should result in rollback
-a <app name>
Name of the docker app that should be running after registration
and update
-v <target version>
Version of the target expected after reboot.
Defaults to 1. Should be set to avoid bad results
-d <true|false> Enables more debug messages. Default: false
"
}

while getopts "t:a:v:d:h" opts; do
case "$opts" in
t) TYPE="${OPTARG}";;
a) APPNAME="${OPTARG}";;
v) VERSION="${OPTARG}";;
d) DEBUG="${OPTARG}";;
h|*) usage ; exit 1 ;;
esac
done

# the script works only on builds with aktualizr-lite
# and lmp-device-auto-register

! check_root && error_msg "You need to be root to run this script."
create_out_dir "${OUTPUT}"

# configure aklite callback
cp aklite-callback.sh /var/sota/
chmod 755 /var/sota/aklite-callback.sh
cp z-99-aklite-callback.toml /etc/sota/conf.d/

report_pass "${TYPE}-create-aklite-callback"

# create signal files
touch /var/sota/ota.signal
touch /var/sota/ota.result
report_pass "${TYPE}-create-signal-files"

# enabling lmp-device-auto-register variant
if [ "${TYPE}" = "regular" ]; then
systemctl enable --now lmp-device-auto-register || error_fatal "Unable to register device"
elif [ "${TYPE}" = "corrupt" ]; then
systemctl enable --now lmp-device-auto-register-corrupt || error_fatal "Unable to register device"
fi

while ! systemctl is-active aktualizr-lite; do
echo "Waiting for aktualizr-lite to start"
sleep 1
done

# wait for 'install-post' signal
SIGNAL=$(</var/sota/ota.signal)
while [ ! "${SIGNAL}" = "install-post" ]
do
echo "Sleeping 1s"
sleep 1
cat /var/sota/ota.signal
SIGNAL=$(</var/sota/ota.signal)
echo "SIGNAL: ${SIGNAL}."
done
report_pass "${TYPE}-install-post-received"
journalctl --no-pager -u aktualizr-lite | grep "No reboot"
check_return "aklite-no-reboot"

. /var/sota/current-version
compare_test_value "targer_after_upgrade" "${VERSION}" "${CUSTOM_VERSION}"

if [ "${DEBUG}" = "true" ]; then
journalctl --no-pager -u aktualizr-lite
fi

0 comments on commit 4323efe

Please sign in to comment.