Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Fix tests that needed to be updated after snapd snap is build from
current
  • Loading branch information
sergiocazzolato committed Oct 7, 2024
1 parent f21aa90 commit bc42534
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 41 deletions.
40 changes: 8 additions & 32 deletions tests/main/snap-run-devmode-classic/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ systems:
# when the host has cgroupsv2 in it
- ubuntu-16.04-*

# Start early as it takes a long time.
priority: 100
kill-timeout: 60m

environment:
# ensure that re-exec is on by default like it should be
SNAP_REEXEC: "1"
Expand All @@ -39,28 +35,12 @@ environment:
BASE_NON_CORE_STRICT_SNAP: test-snapd-sh-core18

prepare: |
# much of what follows is copied from tests/main/snapd-snap
apt-get autoremove -y lxd lxd-client
# load the fuse kernel module before installing lxd
modprobe fuse
"$TESTSTOOLS"/lxd-state prepare-snap
# install snapcraft snap
snap install snapcraft --channel="${SNAPCRAFT_SNAP_CHANNEL}" --classic
tests.cleanup defer snap remove --purge snapcraft
# shellcheck disable=SC2164
pushd "${PROJECT_PATH}"
echo "Build the snap"
snap run snapcraft --verbosity debug --output snapd-from-branch.snap
# Save some disk
snap run snapcraft clean
popd
# Core snap is not modified for classic re-exec any more in this scenario
if tests.info is-snapd-pkg-repo; then
tests.exec skip-test "Core snap is not modified for classic re-exec any more in this scenario" && exit 0
fi
mv "$PROJECT_PATH/snapd-from-branch.snap" "$PWD/snapd-from-branch.snap"
cp "$SNAPD_WORK_DIR"/snapd_snap/snapd_*.snap "$PWD/snapd-from-branch.snap"
# now repack the core snap with this snapd snap
snap download core --edge --basename=core-from-edge
Expand All @@ -87,11 +67,11 @@ prepare: |
rm -r "$coredir"
rm -r "$snapddir"
restore: |
"$TESTSTOOLS"/lxd-state undo-mount-changes || true
execute: |
tests.exec is-skipped && exit 0
if [ "$SNAP_TO_USE_FIRST" = "core" ]; then
# first install our core snap because we don't have the snapd snap on
# the system yet, so we don't need to do any shenanigans
snap install --dangerous core-from-branch.snap
Expand Down Expand Up @@ -141,7 +121,6 @@ execute: |
# we already had the core snap installed, so we need to purge things
# and then install only the snapd snap to test this scenario
snap remove go snapcraft
snap remove core18
apt remove --purge -y snapd
apt install snapd -y
Expand Down Expand Up @@ -187,7 +166,4 @@ execute: |
# undo the purging
apt install -y "$GOHOME"/snapd_*.deb
else
echo "unknown variant $SNAP_TO_USE_FIRST"
exit 1
fi
12 changes: 3 additions & 9 deletions tests/main/snapd-update-services/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ prepare: |
# Download current snapd edge
snap download --edge snapd --basename=snapd_edge
# Repack it with currently built snapd
unpackdir=/tmp/snapd-update-services
unsquashfs -no-progress -d "${unpackdir}" snapd_edge.snap
dpkg-deb -x "${GOHOME}"/snapd_*.deb "${unpackdir}"
snap pack "${unpackdir}" --filename snapd_modified.snap
rm -rf "${unpackdir}"
# Get the snapd package built from the current branch
cp "$SNAPD_WORK_DIR"/snapd_snap/snapd_*.snap "$PWD/snapd_current.snap"
restore: |
rm -rf /tmp/snapd-update-services
rm -f snapd_edge.snap
rm -f snapd_modified.snap
execute: |
snap install --dangerous snapd_edge.snap
Expand Down Expand Up @@ -69,7 +63,7 @@ execute: |
done
# Snapd update
snap install --dangerous snapd_modified.snap
snap install --dangerous snapd_current.snap
# Check the service file has been updated
systemctl is-active snap.test-snapd-service.test-snapd-service.service
Expand Down

0 comments on commit bc42534

Please sign in to comment.