Files
snapd/tests/core/basic20/task.yaml
Sergio Cazzolato ddfc54bd59 tests: use new snaps.name and snaps.cleanup tools (#11599)
* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 872b64e05b..1a986df8d5

1a986df8d5 Merge pull request #17 from snapcore/new-snaps-cleanup-tool
29600af53a Fixing os.paths test for arch linux
e5cdb06053 Minor fixes based on comment reviews
89a0073b88 Run cleanup tests just on systems with snapd pre-installed
19d216a1b9 New tools to get os paths, snap names and cleanup the snaps
a36ee8451a Merge pull request #16 from snapcore/add-codespell
f837691b62 Adding codespell tool to github workflow
58418c3f7e Merge pull request #15 from snapcore/testing-jammy
f015a34899 Fix issue about how info is saved for Debug output
1ee4240e79 Adding jammy to the test systems in spread.yaml
61a4c3142d Merge pull request #14 from snapcore/include-support-s390x
3a1a65f6e1 Update the comments about shellchek
5ddfb7e1db New support for s390x arch in os.query tool
575f5d2016 Merge pull request #13 from snapcore/new-utils-section
4701612434 avoid installing and removing snapd in ubuntu focal
4d0317633d shellcheck in xenial is not needed
d95cb2e627 Moving some tools to the new utils section
839a0ce808 Merge pull request #10 from snapcore/new-spread-shellcheck-tool
5d5efd6fbe Merge pull request #12 from snapcore/run-shellchek-in-old-version
497b7d691f Force testing shellchek with versions 0.8 and 0.7
b3cb5a5a0a Update the copyright
5cfa7cb84d New shellcheck for spread tasks

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 1a986df8d5e66459ec9aa2498a1e9c7d7e419284

* Using new snaps.name and snaps.cleanup tools

These tools are imported from snapd-testing-tools

* cleanup tool will not be in bin

* Fix shellcheck

* Update missing tests

* Fix shellcheck

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 1a986df8d5..53ca1b3b70

53ca1b3b70 Merge pull request #21 from snapcore/fix-some-shellcheks
d380a8065e Fix shellchecks
ad410d44cd Merge pull request #20 from snapcore/fixes-on-remote-tools
80bfd6d85b Updates based on review comments in snapd project
5c77d93bd6 Merge pull request #18 from snapcore/tests-new-remote-tools
3cef4b69b4 Updating timeouts
2c6bf4bd48 Using local vars and removing wait-for tool
8642893803 Test fixes
a14ec4ea88 New remote tools
4545a5e5be Merge branch 'main' into tests-new-remote-tools
a791ae89cb New remote tools

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 53ca1b3b709e685b7910e4b559f182dd78039029

* Make snaps.name executable
2022-05-13 15:11:54 -03:00

116 lines
4.2 KiB
YAML

summary: Check basic core20 system functionality
systems:
- ubuntu-core-20-*
# TODO:
# depends on https://github.com/snapcore/core-base/issues/37
# - ubuntu-core-22-*
execute: |
case "$SPREAD_SYSTEM" in
ubuntu-core-22-*)
base_snap=core22
;;
ubuntu-core-20-*)
base_snap=core20
;;
esac
echo "Check that the system snaps are there"
snap list "${base_snap}"
snap list snapd
if snap list core; then
echo "The old core snap is installed but should not"
exit 1
fi
echo "Ensure that the system is fully seeded"
snap changes | MATCH "Done.*Initialize system state"
echo "Check that a simple shell snap"
if os.query is-core22; then
snap install --edge "test-snapd-sh-${base_snap}"
else
snap install "test-snapd-sh-${base_snap}"
fi
"test-snapd-sh-${base_snap}.sh" -c 'echo hello' | MATCH hello
if python3 -m json.tool < /var/lib/snapd/system-key | grep '"build-id": ""'; then
echo "The build-id of snapd must not be empty."
exit 1
fi
echo "Ensure passwd/group is available for snaps"
"test-snapd-sh-${base_snap}.sh" -c 'cat /var/lib/extrausers/passwd' | MATCH test
case "$SPREAD_SYSTEM" in
ubuntu-core-20-64|ubuntu-core-22-64)
echo "Ensure extracted kernel.efi exists"
kernel_name="$(snaps.name kernel)"
test -e /boot/grub/"$kernel_name"*/kernel.efi
echo "Ensure kernel.efi is a symlink"
test -L /boot/grub/kernel.efi
echo "Ensure we are using managed boot assets"
MATCH '# Snapd-Boot-Config-Edition: [0-9]+' < /boot/grub/grub.cfg
MATCH '# Snapd-Boot-Config-Edition: [0-9]+' < /run/mnt/ubuntu-seed/EFI/ubuntu/grub.cfg
;;
*)
echo "Ensure extracted {kernel,initrd}.img exists"
test -e /run/mnt/ubuntu-seed/systems/*/kernel/kernel.img
test -e /run/mnt/ubuntu-seed/systems/*/kernel/initrd.img
;;
esac
echo "Ensure that model was written to ubuntu-boot"
test -e /run/mnt/ubuntu-boot/device/model
# ensure that our the-tool (and thus our snap-bootstrap ran)
# for external backend the initramfs is not rebuilt
echo "Check that we booted with the rebuilt initramfs in the kernel snap"
if [ "$SPREAD_BACKEND" != "external" ]; then
test -e /writable/system-data/the-tool-ran
fi
# ensure we handled cloud-init, either we have:
# a) cloud init is disabled
# b) there was a cloud.cfg.d override (e.g. MAAS), then we must have more
# files in writable than in the core20 snap. The core20 content and the
# extra config will be merged
test -e /writable/system-data/etc/cloud/cloud-init.disabled || [ "$(find /writable/system-data/etc/cloud/cloud.cfg.d/ | wc -l)" -gt "$(find /snap/${base_snap}/current/etc/cloud/cloud.cfg.d/ | wc -l)" ]
# ensure that we have no symlinks from /var/lib/snapd/snaps to
# /var/lib/snapd/seed
for sn in /var/lib/snapd/snaps/*.snap ; do
if [[ -L $sn ]]; then
echo "snap $sn is a symlink but should not be"
exit 1
fi
done
# ensure that disk-mapping.json is created - we check the format of this
# file in unit tests and in uc20-create-partitions so we don't check
# anything here, just that the file exists
test -e /var/lib/snapd/device/disk-mapping.json
# ubuntu-save has it too
test -e /run/mnt/ubuntu-save/device/disk-mapping.json
# ensure the "snap recovery" command works
MODEL="$(snap model --verbose | grep '^model' | awk '{ print $2 }')"
BRAND_ID="$(snap model --verbose | grep '^brand-id:' | awk '{print $2}')"
if [ "$(snap known account "username=$BRAND_ID" | grep '^validation:' | awk '{print $2}')" != "unproven" ]; then
BRAND_ID="$BRAND_ID\*\*"
fi
snap recovery --unicode=never | MATCH "[0-9]+ +$BRAND_ID +$MODEL +current"
# check that we have a boot-flags file
test -f /run/snapd/boot-flags
# make sure that loop devices created by snap-bootstrap initramfs-mounts for snaps are readonly
for mount in /run/mnt/base /run/mnt/kernel; do
mountpoint "${mount}"
loop="$(findmnt -o source "${mount}" -n)"
echo "${loop}" | MATCH "/dev/loop[0-9]+"
losetup -O ro -n --raw "${loop}" | MATCH "1"
done