tests: initial changes to run core suite in uc24 (#13712)

* tests: initial changes to run core suite in uc24

Changes needed to run core test suite in uc24

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 1c8efb77e1..1db5214d5f

1db5214d5f Improve the remote docs (#36)
2e4a3153a2 1 more comment
3a0fc57e1e add explanation about why we check for ( Do | Doing )
4cf8e635bf fix os.query test after merge
b89b4f8647 fix artifacts name
d30cee6da0 Merge remote-tracking branch 'upstream/main'
5ef5dcbe8f Tests use artifacts in spread tests (#51)
555c43d2ab Support auto-refresh with Do instead of Doing
96c2b0c19c remove tests support for ubuntu 23.04 (EoL)
74082c0c34 Tests improve remote wait (#49)
5121bfb659 remove support for opensuse leap 15.4 (#48)
30df700d08 Add new systems support (#47)
1f08938925 Support check amazon linux version (#46)
43533bdd97 Change the exit value checking for test formats (#45)
3c88244c04 Update check-test-format to support a dir and a list of files (#44)
510d95f429 add extra check for error in auto-refresh detection function
3289d4031b Try open the log with latin-1 encoding when utf-8 is not working
9db785499f improved how the tools are waiting for system reboot
2a5c4414a3 fix shellcheck errors
5e7b63883d Fixes for osquery and tests pkgs (#43)
4c9145e2ac support reboot waiting for auto-refresh
45768f5188 show changes in unknown status after refresh
8013c30c2a Remove support for ubuntu 22.10
b32b80bf54 Fix remote.rait-for test in bionic
5675c625e9 Enable fedora 38
55f4471957 Support for new oss
f2e88b357c New tool used to query spread json reports
cacd35ede0 utils/spread-shellcheck: explain disabled warnings (#42)
c82afb2dee Support --no-install-recommends parameter when installing dependencies with tests.pkgs
b84eea92e2 spread-shellcheck: fix quotes in environment variables (#41)
ab1e51c29f New comparison in os-query for core systems (#40)
e5ae22a5d4 systemd units can be overwritten
63540b845a Fix error messages in remote pull and push
75e8a426a5 make sure the unit is removed in tests.systemd test
9089ff5c02 Update tests to use the new tests.systemd stop-unit
44ecd5e56a Move tests.systemd stop-units to stop-unit
01a2a83b4b Update tests.systemd to have stop units as systemd.sh
162e93bd35 update tests.systemd CLI options to be the same than retry command
14aa43a405 new feature to re-run failed spread tests (#39)
604cb782db Fix shellcheck in systemd tool
bfc71082c8 Update the tests.systemd to allow parameters waiting for service status
8a2d0a99df Adding quiet tool and removing set +-x from tests.pkgs
d90935d2a4 A comment explaining about the default values for wait-for
3232c5dba7 Add support for ubuntu 23.04
a7164fba07 remove fedora 35 support, add fedora 37 support
89b9eb5301 Update systems supported
92bb6a0664 Include snap-sufix in the snaps.name tool

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

* fix core version under test

* adding missing model

* add missing function in nested.sh

* fix keys used for uc24

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 1db5214d5f..dacfd81de9

dacfd81de9 fix is_core functions

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

* use pc-kernel from beta channel

* removing file created for workflow tests

* remove more dirs created during automatic merge

* restore perimssions for files in test snap-repair

* restore tools permissions merged incorrectly

* fix wording in test

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from dacfd81de9..b89ec98b23

b89ec98b23 use local variables in os.query tool

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

* fix remove test details
This commit is contained in:
Sergio Cazzolato
2024-03-18 16:00:53 -03:00
committed by GitHub
parent 08db32cdad
commit 2b482743b6
20 changed files with 304 additions and 37 deletions

View File

@@ -465,6 +465,9 @@ jobs:
- group: ubuntu-core-22
backend: google
systems: 'ubuntu-core-22-64'
- group: ubuntu-core-24
backend: google
systems: 'ubuntu-core-24-64'
- group: ubuntu-arm
backend: google-arm
systems: 'ubuntu-20.04-arm-64 ubuntu-core-22-arm-64'
@@ -784,4 +787,4 @@ jobs:
uses: actions/cache/save@v3
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ github.run_attempt }}"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ github.run_attempt }}"

View File

@@ -140,6 +140,10 @@ backends:
image: ubuntu-22.04-64
workers: 8
storage: 20G
- ubuntu-core-24-64:
image: ubuntu-24.04-64
workers: 8
storage: 20G
- ubuntu-secboot-20.04-64:
image: ubuntu-20.04-64
workers: 1

View File

@@ -1,5 +1,10 @@
summary: Exercise a gadget update on a PC
details: |
This test validates the system works properly after the pc gadget
snap is installed. Also it is validated the new gadgets are installed
correctly.
environment:
BLOB_DIR: $(pwd)/fake-store-blobdir
# snap-id of 'pc' gadget snap
@@ -55,7 +60,7 @@ prepare: |
system_seed=""
system_bios="--system-bios"
if os.query is-core20 || os.query is-core22 ; then
if os.query is-core-ge 20 ; then
system_seed="--system-seed"
fi
if os.query is-arm; then
@@ -67,7 +72,7 @@ prepare: |
echo 'this is foo-x2' > foo-x2.img
cp foo-x2.img pc-snap/foo.img
echo 'this is foo.cfg' > pc-snap/foo.cfg
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
echo 'this is foo-seed.cfg' > pc-snap/foo-seed.cfg
fi
sed -i -e 's/^version: \(.*\)-1/version: \1-2/' pc-snap/meta/snap.yaml
@@ -83,7 +88,7 @@ prepare: |
echo 'this is updated foo-x3' > foo-x3.img
cp foo-x3.img pc-snap/foo.img
echo 'this is updated foo.cfg' > pc-snap/foo.cfg
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
echo 'this is updated foo-seed.cfg' > pc-snap/foo-seed.cfg
fi
echo 'this is bar.cfg' > pc-snap/bar.cfg
@@ -93,7 +98,7 @@ prepare: |
{"snap-id": "$PC_SNAP_ID", "snap-revision": "$((START_REVISION+2))"}
EOF
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
# on uc20, the pc snap we booted with is unasserted for extra debugging
snap install pc_x1.snap --dangerous
else
@@ -140,7 +145,7 @@ execute: |
# - 'EFI System' is mounted at /boot/efi
bootdir=/boot/efi
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
# /boot/efi is not mounted on UC20, so use the /run/mnt hierarchy
bootdir=/run/mnt/ubuntu-boot
fi
@@ -152,7 +157,7 @@ execute: |
cp -av pc_x2.snap "$BLOB_DIR/"
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
# on uc20, the pc snap we booted with is unasserted for extra debugging
snap install pc_x2.snap --dangerous
else
@@ -195,7 +200,7 @@ execute: |
snap ack "$p"
cp -av pc_x3.snap "$BLOB_DIR/"
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
# on uc20, the pc snap we booted with is unasserted for extra debugging
snap install pc_x3.snap --dangerous
else
@@ -227,7 +232,7 @@ execute: |
test "$(cat foo-updated-written.img)" = 'this is updated foo-x3'
fi
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
# a filesystem structure entry was copied to the right place
test "$(cat /run/mnt/ubuntu-seed/foo-seed.cfg)" = 'this is updated foo-seed.cfg'

View File

@@ -1,5 +1,9 @@
summary: Ensure that we have the right kernel
details: |
Check the kernel version is the expected for the current
ubuntu core system
# TODO: enable for arm?
systems: [ubuntu-core-*-64]
@@ -13,5 +17,7 @@ execute: |
VER="^5.4"
elif os.query is-core22; then
VER="^5.15"
elif os.query is-core24; then
VER="^6.8"
fi
uname -r | MATCH "$VER"

View File

@@ -1,5 +1,9 @@
summary: check that os-release is correct
details: |
Check the os-release file contains correct information
for the current ubuntu core system.
debug: |
cat /etc/lsb-release || true
@@ -13,6 +17,8 @@ execute: |
MATCH "DISTRIB_RELEASE=20" < /etc/lsb-release
elif os.query is-core22; then
MATCH "DISTRIB_RELEASE=22" < /etc/lsb-release
elif os.query is-core24; then
MATCH "DISTRIB_RELEASE=24" < /etc/lsb-release
else
echo "Unknown Ubuntu Core system!"
exit 1

View File

@@ -1,5 +1,10 @@
summary: Check that removal of essential snaps does not work
details: |
This test validates snapd and base snaps cannot be
removed. Also checks that a core base snap cannot be
removed when other installed snap is based on that one.
# UC16 does not seed the snapd snap (yet)
systems: [-ubuntu-core-16-*]
@@ -16,6 +21,8 @@ execute: |
base=core20
elif os.query is-core22; then
base=core22
elif os.query is-core24; then
base=core24
fi
echo "Ensure $base cannot be removed"
if snap remove --purge "$base"; then

View File

@@ -1,11 +1,13 @@
summary: Check that the seed symlinks work
details: |
This test checks that the snap is a symlink into the seed
# We explicitly don't want symlinks from /var/lib/snapd/snaps to
# /var/lib/snapd/seed in UC20 run mode because /var/lib/snapd/seed snaps are
# essentially untrusted
systems:
- -ubuntu-core-20-*
- -ubuntu-core-22-*
- -ubuntu-core-2*
execute: |
# shellcheck source=tests/lib/systems.sh

View File

@@ -1,5 +1,9 @@
summary: Ensure `snap debug bootvars` command works
details: |
This test checks the command `snap debug bootvars` displays
correct boot variables information.
debug: |
cat default.out || true
cat uc20.out || true
@@ -10,7 +14,7 @@ execute: |
# does not outright fail
snap debug boot-vars > default.out
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
echo "Check the boot-vars default output looks sane"
# boot-vars default output is for the run mode bootloader, make sure its
# output looks sane (though we don't expect any of the variables to be

View File

@@ -1,5 +1,9 @@
summary: Ensure that snap-repair works on Ubuntu Core
details: |
Checks the `snap repair` command is able repair the
system and the repairs are listed properly.
environment:
BLOB_DIR: $(pwd)/fake-store-blobdir
STORE_ADDR: localhost:11028
@@ -53,6 +57,9 @@ execute: |
elif os.query is-core22; then
REPAIR_SCRIPT=uc22-run.sh
REPAIR_JSON=uc22-run.json
elif os.query is-core24; then
REPAIR_SCRIPT=uc24-run.sh
REPAIR_JSON=uc24-run.json
fi
fakestore new-repair --dir "$BLOB_DIR" "$REPAIR_SCRIPT" --repair-json="$PWD/$REPAIR_JSON"
@@ -75,7 +82,7 @@ execute: |
test "$(snapd.tool exec snap-repair list | tail -n +2 | wc -l)" = 1
echo "And the SNAP_SYSTEM_MODE env var is set appropriately"
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
snapd.tool exec snap-repair show testrootorg-1 | MATCH "echo run"
else
snapd.tool exec snap-repair show testrootorg-1 | MATCH "echo ''"
@@ -129,6 +136,8 @@ execute: |
fakestore new-repair --dir "$BLOB_DIR" uc20-recover.sh --repair-json="$PWD/uc20-recover.json"
elif os.query is-core22; then
fakestore new-repair --dir "$BLOB_DIR" uc22-recover.sh --repair-json="$PWD/uc22-recover.json"
elif os.query is-core24; then
fakestore new-repair --dir "$BLOB_DIR" uc24-recover.sh --repair-json="$PWD/uc24-recover.json"
fi
"$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"

View File

@@ -0,0 +1,10 @@
{
"revision": "0",
"summary": "recovery mode repair assertion",
"bases": [
"core24"
],
"modes": [
"recover"
]
}

View File

@@ -0,0 +1,11 @@
#!/bin/bash -ex
# show what mode we are in
echo "$SNAP_SYSTEM_MODE"
# touch a file in /host to show that we did something from recover mode that
# persists to run mode
touch /host/ubuntu-data/system-data/var/lib/snapd/FIXED
# mark us as done using the snap-repair command
/usr/lib/snapd/snap-repair "done"

View File

@@ -0,0 +1,9 @@
{
"revision": "0",
"bases": [
"core24"
],
"modes": [
"run"
]
}

View File

@@ -0,0 +1,7 @@
#!/bin/bash -ex
# show what mode we are in
echo "$SNAP_SYSTEM_MODE"
# mark us as done using the env var
echo "done" >&"$SNAP_REPAIR_STATUS_FD"

View File

@@ -0,0 +1,42 @@
type: model
authority-id: pxF0fchmU682PEmmay31jjyCHgvscRcj
series: 16
brand-id: pxF0fchmU682PEmmay31jjyCHgvscRcj
model: ubuntu-core-24-amd64-dangerous
architecture: amd64
base: core24
grade: dangerous
snaps:
-
default-channel: 24/edge
id: UqFziVZDHLSyO3TqSWgNBoAdHbLI4dAH
name: pc
type: gadget
-
default-channel: 24/edge
id: pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza
name: pc-kernel
type: kernel
-
default-channel: latest/edge
id: dwTAh7MZZ01zyriOZErqd1JynQLiOGvM
name: core24
type: base
-
default-channel: latest/edge
id: PMrrV4ml8uWuEUDBT8dSGnKUYbevVhc4
name: snapd
type: snapd
timestamp: 2023-11-09T12:57:29+00:00
sign-key-sha3-384: Z79zvem9vfFnGDf5ujLe9x4Ztdf1mwOOoxSkY1WWv3cSDh_cyFrRkmFGVaqs8rWc
AcLBcwQAAQoAHRYhBMnGmNEOGnW9TKVit38uBaVTGCUfBQJlTOv0AAoJEH8uBaVTGCUf5AkQAKkW
O5fUF1F/XPRfE+t8FoIIq3eeOolwCxt5XD2LjJ7oLNYh3YfqXIvitA1lSo3KxT0zIJB9cgUx5ITN
RMVvRP9jkcFC0K2sUcoEbJAkdXlWpvdWWjaQbmZ+9cVEUQF9QZmF4MMOxPpFs8lDrcc7QfGw+g/7
xeomXygiC3yAmBrDzfqojJnIPb80u/1qWrSa8DCr09xELK7m30kVwlk9o865nyDQsCh/5RT63/Ja
7hJEKgihf4VAzOgfEM8tYQ5jFmhvwC3/uaSonoge6/fJBQI+pKKswjxfmQH73xxX9vifkbbX/atj
e359+YPAzntFuMvoNBA3y3JXaWpOzwZzKsr2csnQzFlcpbwjzrLPAGpkuWbFXlMbX8VyUHZHfMuj
p/Ro1A7S3OQmdm0dL8L8yzQhrgvA2bPnPUSvgyK4lnzBFwkCzbw93AG9JMtIx0nLiNRgdBeavxaL
EH42gqVLt22F5oFCfvcv1IMJ92mjJ9Txs4ubFtk9NYoW7hBqxnZoBEZTEAg+DRSF9RAg1c+nhwhi
hDMuRfjkgvciJYOx6hhYWenHZYqeyHcIDcSWAtKZWS2W81kyIYBo4yT5PaA0+7T727WX6N0zjYFM
/k8a4NipctTZb9UDIqL9U0zYZmGnhmsixclqm0EwFqgO7l2+6jwcsT8EgFGVJ672DirmyKZs

View File

@@ -2,8 +2,8 @@
show_help() {
echo "usage: remote.refresh snap [--channel CHANNEL] <SNAPNAME>"
echo "usage: remote.refresh full [--channel CHANNEL]"
echo "usage: remote.refresh disable-refreshes"
echo " remote.refresh full [--channel CHANNEL]"
echo " remote.refresh disable-refreshes"
echo ""
echo "SNAPNAME: allowed options are: kernel, core, base, gadget, snapd or the snap name"
echo ""

View File

@@ -4,7 +4,7 @@ CFG_FILE="${REMOTE_CFG_FILE:-$(pwd)/remote.setup.cfg}"
show_help() {
echo "usage: remote.setup config --host <host> --port <port> --user <USER> [--pass <PASS>] [--cert <CERT>]"
echo "usage: remote.setup get-config-path"
echo " remote.setup get-config-path"
echo ""
echo "Available options:"
echo " -h --help show this help message."

View File

@@ -64,7 +64,7 @@ restore: |
suites:
tests/:
summary: Main test suite for snapd-testing-tools
summary: Main test suite for snapd-testing-tools project
prepare: |
echo "Preparing snapd-testing-tools main suite"
# Create users for the tests

View File

@@ -4,7 +4,7 @@ show_help() {
echo "usage: os.query is-core, is-classic"
echo " os.query is-core16, is-core18, is-core20, is-core22, is-core24"
echo " os.query is-core-gt, is-core-ge, is-core-lt, is-core-le"
echo " os.query is-trusty, is-xenial, is-bionic, is-focal, is-jammy"
echo " os.query is-trusty, is-xenial, is-bionic, is-focal, is-jammy, is-noble"
echo " os.query is-ubuntu [ID], is-debian [ID], is-fedora [ID], is-amazon-linux [ID], is-arch-linux, is-centos [ID], is-opensuse [ID]"
echo " os.query is-ubuntu-gt [ID], is-ubuntu-ge [ID], is-ubuntu-lt [ID], is-ubuntu-le [ID]"
echo " os.query is-pc-amd64, is-pc-i386, is-arm, is-armhf, is-arm64, is-s390x"
@@ -73,19 +73,59 @@ is_core24() {
}
is_core_gt() {
compare_ubuntu "${1:-}" "-gt"
local VERSION=$1
if [ -z "$VERSION" ]; then
echo "os.query: version id is expected"
exit 1
fi
# While ubuntu classic image is used to build a core image
if ! grep -qFx 'ID=ubuntu-core' /etc/os-release; then
VERSION="${VERSION}.04"
fi
compare_ubuntu "$VERSION" "-gt"
}
is_core_ge() {
compare_ubuntu "${1:-}" "-ge"
local VERSION=$1
if [ -z "$VERSION" ]; then
echo "os.query: version id is expected"
exit 1
fi
# While ubuntu classic image is used to build a core image
if ! grep -qFx 'ID=ubuntu-core' /etc/os-release; then
VERSION="${VERSION}.04"
fi
compare_ubuntu "$VERSION" "-ge"
}
is_core_lt() {
compare_ubuntu "${1:-}" "-lt"
local VERSION=$1
if [ -z "$VERSION" ]; then
echo "os.query: version id is expected"
exit 1
fi
# While ubuntu classic image is used to build a core image
if ! grep -qFx 'ID=ubuntu-core' /etc/os-release; then
VERSION="${VERSION}.04"
fi
compare_ubuntu "$VERSION" "-lt"
}
is_core_le() {
compare_ubuntu "${1:-}" "-le"
local VERSION=$1
if [ -z "$VERSION" ]; then
echo "os.query: version id is expected"
exit 1
fi
# This case is when ubuntu classic image is used to build a core image
if ! grep -qFx 'ID=ubuntu-core' /etc/os-release; then
VERSION="${VERSION}.04"
fi
compare_ubuntu "$VERSION" "-le"
}
is_classic() {
@@ -112,6 +152,10 @@ is_jammy() {
grep -qFx 'UBUNTU_CODENAME=jammy' /etc/os-release
}
is_noble() {
grep -qFx 'UBUNTU_CODENAME=noble' /etc/os-release
}
is_ubuntu() {
VERSION=$1
if [ -z "$VERSION" ]; then
@@ -168,7 +212,6 @@ compare_ubuntu() {
test "$SYS_VERSION" "$OPERAND" "$NUM_VERSION"
}
is_debian() {
VERSION=$1
if [ -z "$VERSION" ]; then

View File

@@ -400,6 +400,13 @@ nested_secboot_sign_gadget() {
nested_secboot_sign_file "$GADGET_DIR/shim.efi.signed" "$KEY" "$CERT"
}
nested_secboot_sign_kernel() {
local KERNEL_DIR="$1"
local KEY="$2"
local CERT="$3"
nested_secboot_sign_file "$KERNEL_DIR/kernel.efi" "$KEY" "$CERT"
}
nested_prepare_env() {
mkdir -p "$NESTED_IMAGES_DIR"
mkdir -p "$NESTED_RUNTIME_DIR"

View File

@@ -785,6 +785,65 @@ EOF
rm -rf repacked-kernel
}
uc24_build_initramfs_kernel_snap() {
local ORIG_SNAP="$1"
local TARGET="$2"
unsquashfs -d pc-kernel "$ORIG_SNAP"
objcopy -O binary -j .initrd pc-kernel/kernel.efi initrd.img
unmkinitramfs initrd.img initrd
local output_initrd="${PWD}/initrd.img"
local unpacked_initrd_root="${PWD}/initrd"
if os.query is-pc-amd64; then
unpacked_initrd_root="${unpacked_initrd_root}/main"
fi
# copy in snap-bootstrap from the current build
cp /usr/lib/snapd/snap-bootstrap "${unpacked_initrd_root}/usr/lib/snapd/snap-bootstrap"
# copy in extra files that tests may need for the initrd
if [ -d ./extra-initrd/ ]; then
cp -a ./extra-initrd/* "${unpacked_initrd_root}/"
fi
cd "${unpacked_initrd_root}"
find . | cpio --create --quiet --format=newc --owner=0:0 | lz4 -l -7 > "${output_initrd}"
cd -
quiet apt download systemd-boot-efi
quiet apt install -y llvm
dpkg --fsys-tarfile systemd-boot-efi_*.deb |
tar xf - ./usr/lib/systemd/boot/efi/linuxx64.efi.stub
objcopy -O binary -j .linux pc-kernel/kernel.efi linux
llvm-objcopy --add-section .linux=linux --set-section-flags .linux=readonly,data \
--add-section .initrd=initrd.img --set-section-flags .initrd=readonly,data \
usr/lib/systemd/boot/efi/linuxx64.efi.stub \
pc-kernel/kernel.efi
#shellcheck source=tests/lib/nested.sh
. "$TESTSLIB/nested.sh"
KEY_NAME=$(nested_get_snakeoil_key)
SNAKEOIL_KEY="$PWD/$KEY_NAME.key"
SNAKEOIL_CERT="$PWD/$KEY_NAME.pem"
# sign the kernel
nested_secboot_sign_kernel pc-kernel "$SNAKEOIL_KEY" "$SNAKEOIL_CERT"
# copy any extra files that tests may need for the kernel
if [ -d ./extra-kernel-snap/ ]; then
cp -a ./extra-kernel-snap/* ./pc-kernel
fi
snap pack pc-kernel
mv pc-kernel_*.snap "$TARGET"
rm -rf pc-kernel
}
setup_core_for_testing_by_modify_writable() {
UNPACK_DIR="$1"
@@ -931,6 +990,11 @@ setup_reflash_magic() {
core_name="core20"
elif os.query is-core22; then
core_name="core22"
elif os.query is-core24; then
core_name="core24"
# TODO: revert this once snaps are ready in target channel
KERNEL_CHANNEL=beta
GADGET_CHANNEL=edge
fi
# XXX: we get "error: too early for operation, device not yet
# seeded or device model not acknowledged" here sometimes. To
@@ -983,6 +1047,9 @@ setup_reflash_magic() {
else
cp "$TESTSLIB/assertions/ubuntu-core-22-amd64.model" "$IMAGE_HOME/pc.model"
fi
elif os.query is-core24; then
repack_snapd_snap_with_deb_content_and_run_mode_firstboot_tweaks "$IMAGE_HOME"
cp "$TESTSLIB/assertions/ubuntu-core-24-amd64.model" "$IMAGE_HOME/pc.model"
else
# FIXME: install would be better but we don't have dpkg on
# the image
@@ -1048,25 +1115,46 @@ EOF
fi
fi
if os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 20; then
if os.query is-core20; then
BRANCH=20
elif os.query is-core22; then
BRANCH=22
elif os.query is-core24; then
BRANCH=24
fi
snap download --basename=pc-kernel --channel="${BRANCH}/${KERNEL_CHANNEL}" pc-kernel
# make sure we have the snap
test -e pc-kernel.snap
# build the initramfs with our snapd assets into the kernel snap
uc20_build_initramfs_kernel_snap "$PWD/pc-kernel.snap" "$IMAGE_HOME"
if os.query is-core-ge 24; then
uc24_build_initramfs_kernel_snap "$PWD/pc-kernel.snap" "$IMAGE_HOME"
else
uc20_build_initramfs_kernel_snap "$PWD/pc-kernel.snap" "$IMAGE_HOME"
fi
EXTRA_FUNDAMENTAL="--snap $IMAGE_HOME/pc-kernel_*.snap"
# also add debug command line parameters to the kernel command line via
# the gadget in case things go side ways and we need to debug
snap download --basename=pc --channel="${BRANCH}/${KERNEL_CHANNEL}" pc
if os.query is-core24; then
# TODO: remove this once pc snap is available in beta channel
snap download --basename=pc --channel="${BRANCH}/edge" pc
# TODO: remove this once 24/edge channel is fixed
snap download --basename=pc-23 --channel="classic-23.10/edge" pc
else
snap download --basename=pc --channel="${BRANCH}/${KERNEL_CHANNEL}" pc
fi
test -e pc.snap
unsquashfs -d pc-gadget pc.snap
# TODO: remove this once 24/edge channel is fixed
if os.query is-core24; then
unsquashfs -d pc-gadget-23 pc-23.snap
cp pc-gadget-23/shim.efi.signed pc-gadget/shim.efi.signed
cp pc-gadget-23/grubx64.efi pc-gadget/grubx64.efi
rm -r pc-gadget-23 pc-23.{snap,assert}
fi
# TODO: it would be desirable when we need to do in-depth debugging of
# UC20 runs in google to have snapd.debug=1 always on the kernel command
# line, but we can't do this universally because the logic for the env
@@ -1114,7 +1202,7 @@ EOF
# on core18 we need to use the modified snapd snap and on core16
# it is the modified core that contains our freshly build snapd
if os.query is-core18 || os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 18; then
extra_snap=("$IMAGE_HOME"/snapd_*.snap)
else
extra_snap=("$IMAGE_HOME"/core_*.snap)
@@ -1127,7 +1215,7 @@ EOF
fi
# download the core20 snap manually from the specified channel for UC20
if os.query is-core20 || os.query is-core22; then
if os.query os.query is-core-ge 20; then
if os.query is-core20; then
BASE=core20
elif os.query is-core22; then
@@ -1177,7 +1265,7 @@ EOF
if os.query is-arm; then
LOOP_PARTITION=1
elif os.query is-core20 || os.query is-core22; then
elif os.query is-core-ge 20; then
# (ab)use ubuntu-seed
LOOP_PARTITION=2
else
@@ -1187,7 +1275,7 @@ EOF
# expand the uc16 and uc18 images a little bit (400M) as it currently will
# run out of space easily from local spread runs if there are extra files in
# the project not included in the git ignore and spread ignore, etc.
if ! (os.query is-core20 || os.query is-core22); then
if os.query is-core-le 18; then
# grow the image by 400M
truncate --size=+400M "$IMAGE_HOME/$IMAGE"
# fix the GPT table because old versions of parted complain about this
@@ -1211,7 +1299,7 @@ EOF
dev=$(basename "$devloop")
# resize the 2nd partition from that loop device to fix the size
if ! (os.query is-core20 || os.query is-core22); then
if os.query is-core-le 18; then
resize2fs -p "/dev/mapper/${dev}p${LOOP_PARTITION}"
fi
@@ -1223,7 +1311,7 @@ EOF
# - built debs
# - golang archive files and built packages dir
# - govendor .cache directory and the binary,
if os.query is-core16 || os.query is-core18; then
if os.query is-core-le 18; then
mkdir -p /mnt/user-data/
# we need to include "core" here because -C option says to ignore
# files the way CVS(?!) does, so it ignores files named "core" which
@@ -1238,7 +1326,7 @@ EOF
--exclude /gopath/pkg/ \
--include core/ \
/home/gopath /mnt/user-data/
elif os.query is-core20 || os.query is-core22; then
else
# prepare passwd for run-mode-overlay-data
# use /etc/{group,passwd,shadow,gshadow} from the core20 snap, merged
@@ -1276,7 +1364,7 @@ EOF
fi
# now modify the image writable partition - only possible on uc16 / uc18
if os.query is-core16 || os.query is-core18; then
if os.query is-core-le 18; then
# modify the writable partition of "core" so that we have the
# test user
setup_core_for_testing_by_modify_writable "$UNPACK_DIR"
@@ -1334,7 +1422,7 @@ prepare_ubuntu_core() {
done
echo "Ensure the snapd snap is available"
if os.query is-core18 || os.query is-core20 || os.query is-core22; then
if os.query is-core-ge 18; then
if ! snap list snapd; then
echo "snapd snap on core18 is missing"
snap list
@@ -1365,7 +1453,7 @@ prepare_ubuntu_core() {
echo "Ensure the core snap is cached"
# Cache snaps
if os.query is-core18 || os.query is-core20 || os.query is-core22 || os.query is-core24; then
if os.query is-core-ge 18; then
if snap list core >& /dev/null; then
echo "core snap on core18 should not be installed yet"
snap list
@@ -1381,6 +1469,10 @@ prepare_ubuntu_core() {
if os.query is-core22; then
cache_snaps test-snapd-sh-core22
fi
if os.query is-core24; then
# TODO: move to test-snapd-sh-core24
cache_snaps test-snapd-sh-core22
fi
fi
disable_refreshes