Skip to content
Snippets Groups Projects
Commit 81fde04c authored by Denis Pynkin's avatar Denis Pynkin
Browse files

refactor: rework rollback/blacklist tests


Fix the check of the uboot boot counter and the test logic.
Added some useful debug output.

Signed-off-by: default avatarDenis Pynkin <denis.pynkin@collabora.com>
parent 6b2286ac
No related branches found
No related tags found
3 merge requests!24Apply all changes from v2021pre,!23Backport refactoring ostree upgrade tests 2022dev1 -> v2021pre,!22Refactoring ostree upgrade tests
......@@ -12,12 +12,6 @@ phase_boot()
ostree admin status
# Set the couner to rollback situation
# Use old format to be compatible with the first implementation of the counter
# echo "bc 00" | xxd -r -p /boot/uboot.cnt
# New format (depending on U-Boot installed):
echo "bd 01 00 01" | xxd -r -p /boot/uboot.cnt
# Create a new commit based on current deployment, but older and without files from a skip list
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
CURREV=$(ostree rev-parse origin:$BRANCHNAME)
......@@ -25,36 +19,54 @@ phase_boot()
OLDREV=$(ostree rev-parse $BRANCHNAME)
ostree admin upgrade --allow-downgrade --deploy-only --override-commit=$OLDREV
# Emulate the ugrade state -- set the upgrade flag and bootcounter to 0
# Use old format to be compatible with the first implementation of the counter
# echo "bc 00" | xxd -r -p /boot/uboot.cnt
# New format (depending on U-Boot installed):
echo "bd 01 00 01" | xxd -r -p > /boot/uboot.cnt
# Store the commit with prepared revision for use in tests later
echo $OLDREV > $(get_phase_data_path)
sync
}
phase_check_update()
{
ostree admin status
# Enable debug for AUM to check how it deal with upgrade&rollback
enable_aum_debug
journalctl --no-pager -u apertis-update-manager
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
local COMMIT_EXPECTED=$(cat $PHASE_DATA)
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# Ensure to have \xbc\x0[12345] in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" != "$COMMIT_AFTER" ] ; then
if [ "$COMMIT_EXPECTED" != "$COMMIT_AFTER" ] ; then
echo "The update did not apply, the current commit is the same as the initial commit"
exit 1
fi
# Wait long enough so that we are sure the bootcount has not been reset
sleep 30
}
# Check the bootcounter state
# It may have different boot count on different boards due LAVA
check_bootcounter bd 01 "" 01
# Emulate the ugrade state -- set the upgrade flag and bootcounter to any value above the limit
# This should to trigger the U-Boot to boot previous version after reboot
# New format (depending on U-Boot installed):
echo "bd 01 05 01" | xxd -r -p > /boot/uboot.cnt
sync
}
phase_check_rollback()
{
# Wait long enough so that AUM have a chance to finish undeploy
sleep 30
ostree admin status
journalctl --no-pager -u apertis-update-manager
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
......@@ -62,20 +74,23 @@ phase_check_rollback()
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have \xbc\x00 in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" = "$COMMIT_AFTER" ] ; then
echo "The update did not rollback, the current commit is the same"
exit 1
fi
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have non-upgrade state
check_bootcounter bd 01 00 00
# Must exists and contain "failed" upgrade
cat /var/aum_blacklist.conf
prepare_outdated_commit
# Prepare outdated commit from the booted one
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
ostree commit -b $BRANCHNAME --tree=ref=$COMMIT_AFTER --timestamp="1 year ago"
OLDREV=$(ostree rev-parse $BRANCHNAME)
ostree admin upgrade --os=apertis --allow-downgrade --deploy-only --override-commit=$OLDREV
}
phase_clean_previous_install()
......@@ -84,6 +99,7 @@ phase_clean_previous_install()
# Add the newest commit on server side into blacklist to prevent upgrading
# Usually it should be the same as installed
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
ostree pull --commit-metadata-only --depth=1 origin "$BRANCHNAME"
BLACKLISTREV=$(ostree rev-parse origin:$BRANCHNAME)
echo "$BLACKLISTREV=true" >> /var/aum_blacklist.conf
......
......@@ -17,33 +17,48 @@ phase_boot()
echo $CURREV > $(get_phase_data_path)
ostree admin status
# Ensure to have upgrade state
check_bootcounter bd 01 00 01
}
phase_check_update()
{
ostree admin status
# Enable debug for AUM to check how it deal with upgrade&rollback
enable_aum_debug
journalctl --no-pager -u apertis-update-manager
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# Ensure to have \xbc\x0[12345] in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" = "$COMMIT_AFTER" ] ; then
echo "The update did not apply, the current commit is the same as the initial commit"
exit 1
fi
# Wait long enough so that we are sure the bootcount has not been reset
sleep 30
# Check the bootcounter state
# It may have different boot count on different boards due LAVA
check_bootcounter bd 01 "" 01
# Emulate the ugrade state -- set the upgrade flag and bootcounter to any value above the limit
# This should to trigger the U-Boot to boot previous version after reboot
# New format (depending on U-Boot installed):
echo "bd 01 05 01" | xxd -r -p > /boot/uboot.cnt
sync
}
phase_check_rollback()
{
# Wait long enough so that AUM have a chance to finish undeploy
sleep 30
ostree admin status
journalctl --no-pager -u apertis-update-manager
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
......@@ -51,17 +66,14 @@ phase_check_rollback()
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have \xbc\x00 in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" != "$COMMIT_AFTER" ] ; then
echo "The update did not rollback, the current commit is the same"
exit 1
fi
# Wait long enough so that we are sure the bootcount has not been reset
sleep 30
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have non-upgrade state
check_bootcounter bd 01 00 00
cat /var/aum_blacklist.conf
}
......@@ -72,7 +84,6 @@ phase_check_update_is_blacklisted()
cat /var/aum_blacklist.conf
local DELTAFILE=$(get_static_delta "_rollback" tests)
# Ensure the update cannot apply again
if apply_update_sync -d $DELTAFILE ; then
echo "Blacklisted update applied"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment