From eea4557d1aa6d7e3c5dd896674d020dec5eac5a7 Mon Sep 17 00:00:00 2001 From: Maciej Borzecki Date: Thu, 19 Dec 2024 07:40:31 +0100 Subject: [PATCH] tests: replace use of test-snapd-curl with simpleget where possible 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 --- .../snapd-refresh-vs-services-reboots/task.yaml | 8 +++----- tests/core/snapd-refresh-vs-services/task.yaml | 14 ++++++-------- tests/main/default-tracks/task.yaml | 6 +----- .../cloud-init-never-used-not-vuln/task.yaml | 6 ++---- .../manual/cloud-init-nocloud-not-vuln/task.yaml | 6 ++---- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/tests/core/snapd-refresh-vs-services-reboots/task.yaml b/tests/core/snapd-refresh-vs-services-reboots/task.yaml index 7e4f0af8940..85e4d5e2c5d 100644 --- a/tests/core/snapd-refresh-vs-services-reboots/task.yaml +++ b/tests/core/snapd-refresh-vs-services-reboots/task.yaml @@ -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 diff --git a/tests/core/snapd-refresh-vs-services/task.yaml b/tests/core/snapd-refresh-vs-services/task.yaml index a1b16a8a613..65ca1396eb6 100644 --- a/tests/core/snapd-refresh-vs-services/task.yaml +++ b/tests/core/snapd-refresh-vs-services/task.yaml @@ -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 @@ -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 @@ -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" diff --git a/tests/main/default-tracks/task.yaml b/tests/main/default-tracks/task.yaml index f0221afa56f..b08b87b6ad1 100644 --- a/tests/main/default-tracks/task.yaml +++ b/tests/main/default-tracks/task.yaml @@ -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 @@ -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" diff --git a/tests/nested/manual/cloud-init-never-used-not-vuln/task.yaml b/tests/nested/manual/cloud-init-never-used-not-vuln/task.yaml index 3474dce6544..c897687ab64 100644 --- a/tests/nested/manual/cloud-init-never-used-not-vuln/task.yaml +++ b/tests/nested/manual/cloud-init-never-used-not-vuln/task.yaml @@ -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 diff --git a/tests/nested/manual/cloud-init-nocloud-not-vuln/task.yaml b/tests/nested/manual/cloud-init-nocloud-not-vuln/task.yaml index 5e7faf1cdc7..df3d2f66943 100644 --- a/tests/nested/manual/cloud-init-nocloud-not-vuln/task.yaml +++ b/tests/nested/manual/cloud-init-nocloud-not-vuln/task.yaml @@ -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)"