Skip to content

Commit

Permalink
tests: replace use of test-snapd-curl with simpleget where possible
Browse files Browse the repository at this point in the history
Replace uses of test-snapd-curl with simpleget in an attempt to reduce
the number of external dependencies installed by the tests.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
  • Loading branch information
bboozzoo committed Dec 19, 2024
1 parent 3edac9b commit eea4557
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
8 changes: 3 additions & 5 deletions tests/core/snapd-refresh-vs-services-reboots/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ environment:
SNAPD_2_49_2_ARMHF: https://storage.googleapis.com/snapd-spread-tests/snaps/snapd_2.49.2_11586.snap

prepare: |
snap install test-snapd-curl --edge --devmode # devmode so it can save to any dir
# save the version of snapd from the PR to refresh to later
INITIAL_REV=$(snap list snapd | tail -n +2 | awk '{print $3}')
cp "/var/lib/snapd/snaps/snapd_$INITIAL_REV.snap" snapd-pr.snap
# download and install snapd 2.49.2
if os.query is-pc-amd64; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_X86"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_X86"
elif os.query is-arm64; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARM64"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARM64"
elif os.query is-armhf; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARMHF"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARMHF"
else
echo "architecture not supported for this variant"
exit 0
Expand Down
14 changes: 6 additions & 8 deletions tests/core/snapd-refresh-vs-services/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ environment:
SNAPD_2_49_2_ARMHF: https://storage.googleapis.com/snapd-spread-tests/snaps/snapd_2.49.2_11586.snap

prepare: |
# install http snap to download files
snap install test-snapd-curl --edge --devmode # devmode so it can save to any dir
# save the current version of snapd for later
INITIAL_REV=$(snap list snapd | tail -n +2 | awk '{print $3}')
cp "/var/lib/snapd/snaps/snapd_$INITIAL_REV.snap" snapd-pr.snap
Expand Down Expand Up @@ -81,11 +79,11 @@ execute: |
# introduced so we can install a snap service that will not have Requires= in
# it
if os.query is-pc-amd64; then
test-snapd-curl.curl -s -o snapd_2.49.1.snap "$SNAPD_2_49_1_X86"
"$TESTSTOOLS/simpleget" -o snapd_2.49.1.snap "$SNAPD_2_49_1_X86"
elif os.query is-arm64; then
test-snapd-curl.curl -s -o snapd_2.49.1.snap "$SNAPD_2_49_1_ARM64"
"$TESTSTOOLS/simpleget" -o snapd_2.49.1.snap "$SNAPD_2_49_1_ARM64"
elif os.query is-armhf; then
test-snapd-curl.curl -s -o snapd_2.49.1.snap "$SNAPD_2_49_1_ARMHF"
"$TESTSTOOLS/simpleget" -o snapd_2.49.1.snap "$SNAPD_2_49_1_ARMHF"
fi
snap install --dangerous snapd_2.49.1.snap
Expand All @@ -112,11 +110,11 @@ execute: |
elif [ "${SNAPD_VERSION_UNDER_TEST}" = "2.49.2" ]; then
# download and install snapd 2.49.2
if os.query is-pc-amd64; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_X86"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_X86"
elif os.query is-arm64; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARM64"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARM64"
elif os.query is-armhf; then
test-snapd-curl.curl -s -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARMHF"
"$TESTSTOOLS/simpleget" -o snapd_2.49.2.snap "$SNAPD_2_49_2_ARMHF"
fi
echo "Refreshing snapd to 2.49.2"
Expand Down
6 changes: 1 addition & 5 deletions tests/main/default-tracks/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ environment:
A_SNAP: test-snapd-default-track
A_TRACK: default

prepare: |
snap install test-snapd-curl --edge
execute: |
# first, precondition check that the snap has a default track
snap run test-snapd-curl.curl -H "Snap-Device-Series: 16" "https://api.snapcraft.io/v2/snaps/info/$A_SNAP" > info
"$TESTSTOOLS/simpleget" -H "Snap-Device-Series: 16" "https://api.snapcraft.io/v2/snaps/info/$A_SNAP" > info
test "$( gojq -r '."default-track"' < info )" == "$A_TRACK"
# TODO: check the output of 'snap info' for the default-track-having snap
Expand All @@ -33,7 +30,6 @@ execute: |
"$TESTSTOOLS"/snapd-state check-state ".data.snaps.\"$A_SNAP\".channel" = "$A_TRACK/candidate"
snap remove --purge "$A_SNAP"
snap remove --purge test-snapd-curl
# now try a multi-install
snap install "$A_SNAP" "test-snapd-tools"
Expand Down
6 changes: 2 additions & 4 deletions tests/nested/manual/cloud-init-never-used-not-vuln/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ prepare: |
# thus this test would no longer be testing that old vulnerable devices
# become safe after refreshing to the fix
if [ "$NESTED_BUILD_SNAPD_FROM_CURRENT" = "false" ]; then
snap install test-snapd-curl --edge --devmode # devmode so it can save to any dir
if os.query is-xenial; then
# uc16 uses core snap
test-snapd-curl.curl -s -o core_2.45.snap "$SNAPD_2_45_CORE_SNAP"
"$TESTSTOOLS/simpleget" -o core_2.45.snap "$SNAPD_2_45_CORE_SNAP"
# The core snap is unpacked and repacked to prevent it is auto-refreshed when
# it is installed with --dangerous as it has a different hash
unsquashfs -d core-snap core_2.45.snap
snap pack core-snap/ "$(tests.nested get extra-snaps-path)"
else
# uc18 uses snapd snap
test-snapd-curl.curl -s -o snapd_2.45.snap "$SNAPD_2_45_SNAPD_SNAP"
"$TESTSTOOLS/simpleget" -o snapd_2.45.snap "$SNAPD_2_45_SNAPD_SNAP"
# The snapd snap is unpacked and repacked to prevent it from being
# auto-refreshed when it is installed
unsquashfs -d snapd-snap snapd_2.45.snap
Expand Down
6 changes: 2 additions & 4 deletions tests/nested/manual/cloud-init-nocloud-not-vuln/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ prepare: |
# thus this test would no longer be testing that old vulnerable devices
# become safe after refreshing to the fix
if [ "$NESTED_BUILD_SNAPD_FROM_CURRENT" = "false" ]; then
snap install test-snapd-curl --edge --devmode # devmode so it can save to any dir
if os.query is-xenial; then
# uc16 uses core snap
test-snapd-curl.curl -s -o core_2.45.snap "$SNAPD_2_45_CORE_SNAP"
"$TESTSTOOLS/simpleget" -o core_2.45.snap "$SNAPD_2_45_CORE_SNAP"
# The core snap is unpacked and repacked to prevent it is auto-refreshed when
# it is installed with --dangerous as it has a different hash
unsquashfs -d core-snap core_2.45.snap
snap pack core-snap/ "$(tests.nested get extra-snaps-path)"
else
# uc18 uses snapd snap
test-snapd-curl.curl -s -o snapd_2.45.snap "$SNAPD_2_45_SNAPD_SNAP"
"$TESTSTOOLS/simpleget" -o snapd_2.45.snap "$SNAPD_2_45_SNAPD_SNAP"
# repack to prevent automatic refresh
unsquashfs -d snapd-snap snapd_2.45.snap
snap pack snapd-snap/ "$(tests.nested get extra-snaps-path)"
Expand Down

0 comments on commit eea4557

Please sign in to comment.