Browse Source

Merge pull request #549 from kacf/jammy

QA-554: Update to Ubuntu 22.04 Jammy and fix test.
master
Kristian Amlie 2 years ago
committed by GitHub
parent
commit
a731e33a36
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      configs/ubuntu-qemux86-64_config
  2. 16
      scripts/test/generate-image.sh
  3. 14
      scripts/test/run-tests.sh
  4. 68
      tests/test_grub_integration.py

4
configs/ubuntu-qemux86-64_config

@ -8,11 +8,11 @@
#
# Locally, converted with the following command:
#
# MENDER_ARTIFACT_NAME=release-1 ./docker-mender-convert --disk-image input/Ubuntu-Focal-x86-64.img --overlay rootfs_overlay_demo --config configs/qemux86-64_config
# MENDER_ARTIFACT_NAME=release-1 ./docker-mender-convert --disk-image input/Ubuntu-Jammy-x86-64.img --config configs/ubuntu-qemux86-64_config
#
# and qemu is executed with the following command:
#
# qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/OVMF/OVMF_CODE.fd -drive format=raw,file=deploy/Ubuntu-Focal-x86-64-qemux86-64-mender.img
# qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/OVMF/OVMF_CODE.fd -drive format=raw,file=deploy/Ubuntu-Jammy-x86-64-qemux86-64-mender.img
MENDER_STORAGE_DEVICE_BASE=/dev/sda
MENDER_DEVICE_TYPE="qemux86-64"

16
scripts/test/generate-image.sh

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2022 Northern.tech AS
# Copyright 2023 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -26,6 +26,12 @@ if [ "$UID" -ne 0 ]; then
exec sudo "$0" "$@"
fi
DEBIAN_CODENAME="bullseye"
DEBIAN_IMAGE_ID="Debian-11"
UBUNTU_CODENAME="jammy"
UBUNTU_IMAGE_ID="Ubuntu-Jammy"
while [ -n "$1" ]; do
case "$1" in
"ubuntu")
@ -53,9 +59,9 @@ cleanup_losetup() {
}
generate_debian() {
local -r image="Debian-11-x86-64.img"
local -r image="${DEBIAN_IMAGE_ID}-x86-64.img"
mkosi --root-size=2G --distribution=debian --release=bullseye --format=gpt_ext4 --bootable --checksum \
mkosi --root-size=2G --distribution=debian --release="$DEBIAN_CODENAME" --format=gpt_ext4 --bootable --checksum \
--password password --package=openssh-server,dhcpcd5 --package grub-efi-amd64-signed \
--package shim-signed --package lsb-release --output="$image" build
@ -65,9 +71,9 @@ generate_debian() {
}
generate_ubuntu() {
local -r image="Ubuntu-Focal-x86-64.img"
local -r image="${UBUNTU_IMAGE_ID}-x86-64.img"
mkosi --root-size=2G --distribution=ubuntu --release=focal --format=gpt_ext4 --bootable --checksum \
mkosi --root-size=2G --distribution=ubuntu --release="$UBUNTU_CODENAME" --format=gpt_ext4 --bootable --checksum \
--password password --package=openssh-server,dhcpcd5 --package grub-efi-amd64-signed \
--package shim-signed --package lsb-release --output="$image" build

14
scripts/test/run-tests.sh

@ -38,7 +38,7 @@ BBB_DEBIAN_EMMC_IMAGE_URL="https://rcn-ee.com/rootfs/bb.org/testing/2022-03-02/b
## Auto-update
RASPBIAN_IMAGE_URL="https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-09-26/2022-09-22-raspios-bullseye-armhf-lite.img.xz"
UBUNTU_IMAGE_URL="https://downloads.mender.io/mender-convert/images/Ubuntu-Focal-x86-64.img.gz"
UBUNTU_IMAGE_URL="https://downloads.mender.io/mender-convert/images/Ubuntu-Jammy-x86-64.img.gz"
DEBIAN_IMAGE_URL="https://downloads.mender.io/mender-convert/images/Debian-11-x86-64.img.gz"
@ -109,7 +109,7 @@ else
sudo cp -r "tests/ssh-public-key-overlay" "input/tests/"
convert_and_test "qemux86-64" \
"release-1" \
"input/image/Ubuntu-Focal-x86-64.img.gz" \
"input/image/Ubuntu-Jammy-x86-64.img.gz" \
"--overlay input/tests/ssh-public-key-overlay" \
"--config configs/ubuntu-qemux86-64_config $EXTRA_CONFIG" \
"--" \
@ -120,13 +120,13 @@ else
echo >&2 "Running the uncompressed test"
echo >&2 "----------------------------------------"
rm -rf deploy
gunzip --force "input/image/Ubuntu-Focal-x86-64.img.gz"
gunzip --force "input/image/Ubuntu-Jammy-x86-64.img.gz"
run_convert "release-2" \
"input/image/Ubuntu-Focal-x86-64.img" \
"input/image/Ubuntu-Jammy-x86-64.img" \
"--config configs/ubuntu-qemux86-64_config $EXTRA_CONFIG" || test_result=$?
ret=0
test -f deploy/Ubuntu-Focal-x86-64-qemux86-64-mender.img || ret=$?
assert "${ret}" "0" "Expected uncompressed file deploy/Ubuntu-Focal-x86-64-qemux86-64-mender.img"
test -f deploy/Ubuntu-Jammy-x86-64-qemux86-64-mender.img || ret=$?
assert "${ret}" "0" "Expected uncompressed file deploy/Ubuntu-Jammy-x86-64-qemux86-64-mender.img"
fi
if [ "$TEST_ALL" == "1" -o "$TEST_PLATFORM" == "ubuntu-qemux86-64-no-grub-d" ]; then
@ -137,7 +137,7 @@ else
convert_and_test \
"qemux86-64" \
"release-1" \
"input/image/Ubuntu-Focal-x86-64.img.gz" \
"input/image/Ubuntu-Jammy-x86-64.img.gz" \
"--overlay input/tests/ssh-public-key-overlay" \
"--config configs/ubuntu-qemux86-64_config" \
"--config configs/testing/no-grub.d_config $EXTRA_CONFIG" \

68
tests/test_grub_integration.py

@ -152,12 +152,22 @@ class TestGrubIntegration:
connection.run("rm -f /data/new-grub-efi-modified.cfg")
# Another few differences we work around in the main grub files:
#
# * `--hint` parameters are not generated in offline copy.
#
# * `root` variable is not set in offline copy.
#
# * `fwsetup` is added somewhat randomly depending on availability both
# on build host and device.
#
# * locale, lang and gettext settings and module may or may not be
# present depending on test host.
#
# * Inside the `00_header` section, ignore the `search` functions which
# set the root variable. This is safe because we have a later script
# which sets the root again (`07_mender_choose_partitions_grub.cfg` at
# the time of writing). These are sometimes inside an if condition
# using `feature_platform_search_hint`, which we also need to ignore.
try:
connection.run("cp /data/grub-main.cfg /data/old-grub-modified.cfg")
connection.run("cp /boot/grub/grub.cfg /data/new-grub-modified.cfg")
@ -169,7 +179,36 @@ class TestGrubIntegration:
"-e p "
"/data/old-grub-modified.cfg /data/new-grub-modified.cfg"
)
connection.run("diff -u /data/old-grub-modified.cfg /data/new-grub-modified.cfg")
connection.run(
"sed -i -En -e '"
r"""
\%BEGIN /etc/grub.d/00_header% {
:header_loop;
/if .*feature_platform_search_hint/ {
:hint_loop;
/^ *fi *$/ ! {
n;
b hint_loop;
};
n;
};
/^ *search .*--set=root/ {
n;
b header_loop;
};
\%END /etc/grub.d/00_header% ! {
p;
n;
b header_loop;
};
};
p;
' """
"/data/old-grub-modified.cfg /data/new-grub-modified.cfg"
)
connection.run(
"diff -u /data/old-grub-modified.cfg /data/new-grub-modified.cfg"
)
finally:
connection.run("rm -f /data/old-grub-modified.cfg /data/new-grub-modified.cfg")
@ -185,6 +224,33 @@ class TestGrubIntegration:
"-e p "
"/data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
)
connection.run(
"sed -i -En -e '"
r"""
\%BEGIN /etc/grub.d/00_header% {
:header_loop;
/if .*feature_platform_search_hint/ {
:hint_loop;
/^ *fi *$/ ! {
n;
b hint_loop;
};
n;
};
/^ *search .*--set=root/ {
n;
b header_loop;
};
\%END /etc/grub.d/00_header% ! {
p;
n;
b header_loop;
};
};
p;
' """
"/data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
)
connection.run(
"diff -u /data/old-grub-mender-grubenv-modified.cfg /data/new-grub-mender-grubenv-modified.cfg"
)

Loading…
Cancel
Save