Skip to content

Commit

Permalink
Merge pull request #167 from simondeziel/secureboot
Browse files Browse the repository at this point in the history
Fix name of `secureboot` requirement
  • Loading branch information
tomponline authored May 2, 2024
2 parents 25c917e + 245ea90 commit ec914d0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
8 changes: 3 additions & 5 deletions .github/actions/image-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ runs:
echo "==> TEST: ${TEST_ID}"
VIRT_ENABLED=$(lxc query /1.0 | jq '.environment.driver | contains("qemu")')
if [ ${TYPE} = "vm" ] && [ "${VIRT_ENABLED}" != "true" ]; then
if [ "${TYPE}" = "vm" ] && [ "${VIRT_ENABLED}" != "true" ]; then
echo "==> FAIL: Virtualization is not supported"
exit 1
fi
./bin/test-image "${TYPE}" "${DISTRO}" "${RELEASE}" "${VARIANT}" "${TARGET}"
if [ "$?" = "0" ]; then
if ./bin/test-image "${TYPE}" "${DISTRO}" "${RELEASE}" "${VARIANT}" "${TARGET}"; then
echo "==> PASS: ${TEST_ID}"
exit 0
fi
echo "==> FAIL: ${TEST_ID}"
exit 0
exit 1
52 changes: 29 additions & 23 deletions bin/test-image
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ "${1:-}" = "" ] || [ "${2:-}" = "" ] || [ "${3:-}" = "" ] || [ "${4:-}" = "
fi

TYPE=${1}
DIST=${2}
DISTRO=${2}
RELEASE=${3}
VARIANT=${4}
TARGET=${5}
Expand All @@ -30,18 +30,18 @@ fi

# Setup the test environment.
TEST_DIR="${HOME}/build-test"
TEST_IMAGE="${TYPE}-${DIST}-${VARIANT}"
TEST_IMAGE="${TYPE}-${DISTRO}-${VARIANT}"

rm -Rf "${TEST_DIR}"
mkdir -p "${TEST_DIR}"

echo "==> Fetching the image"
if [ "${TYPE}" = "container" ]; then
cp "${TARGET}/lxd.tar.xz" "${TEST_DIR}/meta"
cp "${TARGET}/rootfs.squashfs" "${TEST_DIR}/root"
TEST_IMAGE_META="${TARGET}/lxd.tar.xz"
TEST_IMAGE_ROOT="${TARGET}/rootfs.squashfs"
elif [ "${TYPE}" = "vm" ]; then
cp "${TARGET}/lxd.tar.xz" "${TEST_DIR}/meta"
cp "${TARGET}/disk.qcow2" "${TEST_DIR}/root"
TEST_IMAGE_META="${TARGET}/lxd.tar.xz"
TEST_IMAGE_ROOT="${TARGET}/disk.qcow2"
else
echo "==> FAIL: Invalid instance type '${TYPE}'. Valid types: [container, vm]"
exit 1
Expand All @@ -64,16 +64,22 @@ cleanup() {
FAIL=1
trap cleanup EXIT HUP INT TERM

lxc image import "${TEST_DIR}/meta" "${TEST_DIR}/root" --alias "${TEST_IMAGE}"
lxc image import "${TEST_IMAGE_META}" "${TEST_IMAGE_ROOT}" --alias "${TEST_IMAGE}"

echo "==> Creating the instances"
INSTANCES=""
if [ "${TYPE}" = "vm" ]; then
lxc init "${TEST_IMAGE}" "${TEST_IMAGE}" \
--vm \
-c limits.cpu=4 \
-c limits.memory=4GB \
-c security.secureboot=false
-c limits.memory=4GiB

# Some distros don't support secure boot.
case "${DISTRO}" in
alpine|archlinux|gentoo|nixos)
lxc config set "${TEST_IMAGE}" security.secureboot=false
;;
esac

INSTANCES="${TEST_IMAGE}"

Expand All @@ -96,7 +102,7 @@ EOF
fi
else
for PRIV in "priv" "unpriv"; do
if [ "${PRIV}" = "priv" ] && [ "${DIST}" = "nixos" ] && [ "${RELEASE}" = "23.11" ]; then
if [ "${PRIV}" = "priv" ] && [ "${DISTRO}" = "nixos" ] && [ "${RELEASE}" = "23.11" ]; then
# NixOS 23.11 will never support privileged containers, but future versions do.
continue
fi
Expand All @@ -111,12 +117,12 @@ else
lxc config set "${TEST_IMAGE}-${PRIV}" security.privileged=true
fi

if [ "${DIST}" = "voidlinux" ]; then
if [ "${DISTRO}" = "voidlinux" ]; then
# Workaround weird init system.
lxc config set "${TEST_IMAGE}-${PRIV}" raw.lxc lxc.signal.halt=SIGCONT
fi

if [ "${DIST}" = "slackware" ]; then
if [ "${DISTRO}" = "slackware" ]; then
# Workaround weird init system.
lxc config set "${TEST_IMAGE}-${PRIV}" raw.lxc lxc.signal.halt=SIGKILL
fi
Expand Down Expand Up @@ -150,12 +156,12 @@ done
# Wait for things to settle.
echo "==> Waiting for instances to start"
for i in ${INSTANCES}; do
if [ "${DIST}" == "busybox" ]; then
if [ "${DISTRO}" == "busybox" ]; then
# Busybox has only 1 process running when ready.
MIN_PROC_COUNT=1
fi

if [ "${DIST}" == "centos" ]; then
if [ "${DISTRO}" == "centos" ]; then
# Give CentOS a bit more time to boot.
MAX_WAIT_SECONDS=180
fi
Expand All @@ -174,20 +180,20 @@ for url in $(lxc query "/1.0/instances" | jq -r .[] | grep "${TEST_IMAGE}"); do
name=$(echo "${url}" | cut -d/ -f4)

# Skip busybox as it wouldn't pass any test
if [ "${DIST}" = "busybox" ]; then
if [ "${DISTRO}" = "busybox" ]; then
echo "===> SKIP: Busybox is untestable"
continue
fi

# Skip CentOS 7 VMs due to racy agent
if [ "${TYPE}" = "vm" ] && [ "${DIST}" = "centos" ] && [ "${RELEASE}" = "7" ]; then
if [ "${TYPE}" = "vm" ] && [ "${DISTRO}" = "centos" ] && [ "${RELEASE}" = "7" ]; then
echo "===> SKIP: CentOS 7 has an unstable agent: ${name}"
continue
fi

# Systemd cleanliness.
if lxc exec "${name}" -- sh -c "type systemctl" >/dev/null 2>&1; then
if lxc exec "${name}" -- systemctl --failed 2>&1 | grep -q '\sfailed\s'; then
if lxc exec "${name}" -- test -d /run/systemd/system/; then
if lxc exec "${name}" -- systemctl --failed 2>&1 | grep -qwF 'failed'; then
echo "===> FAIL: systemd clean: ${name}"

# Show the systemd failures.
Expand Down Expand Up @@ -218,15 +224,15 @@ for url in $(lxc query "/1.0/instances" | jq -r .[] | grep "${TEST_IMAGE}"); do
fi

# IPv4 address
if echo "${address}" | grep "\." -q; then
if echo "${address}" | grep -qF "."; then
echo "===> PASS: IPv4 address: ${name}"
else
echo "===> FAIL: IPv4 address: ${name}"
FAIL=1
fi

# IPv6 address
if echo "${address}" | grep ":" -q; then
if echo "${address}" | grep -qF ":"; then
echo "===> PASS: IPv6 address: ${name}"
else
echo "===> FAIL: IPv6 address: ${name}"
Expand All @@ -235,7 +241,7 @@ for url in $(lxc query "/1.0/instances" | jq -r .[] | grep "${TEST_IMAGE}"); do

# DNS resolution
DNS=0
for i in $(seq 3); do
for _ in $(seq 3); do
if lxc exec "${name}" -- getent hosts canonical.com >/dev/null 2>&1; then
DNS=1
break
Expand Down Expand Up @@ -276,13 +282,13 @@ done
# Check that all instances can be stopped.
echo "==> Performing shutdown test"
STOPPED=0
for i in $(seq 10); do
for _ in $(seq 10); do
# shellcheck disable=SC2086
if lxc stop ${INSTANCES} --timeout=30 >/dev/null 2>&1; then
STOPPED=1
break
else
COUNT="$(lxc list "${TEST_IMAGE}" | grep -c RUNNING)"
COUNT="$(lxc list -f csv -c n,s "${TEST_IMAGE}" | grep -cw 'RUNNING$')"
if [ "${COUNT}" = "0" ]; then
STOPPED=1
break
Expand Down
2 changes: 1 addition & 1 deletion images/alpine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ image:
simplestream:
requirements:
- requirements:
secure_boot: false
secureboot: false

source:
downloader: alpinelinux-http
Expand Down
2 changes: 1 addition & 1 deletion images/archlinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ simplestream:
distro_name: Arch Linux
requirements:
- requirements:
secure_boot: false
secureboot: false

source:
downloader: archlinux-http
Expand Down
2 changes: 1 addition & 1 deletion images/gentoo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ image:
simplestream:
requirements:
- requirements:
secure_boot: false
secureboot: false

source:
downloader: gentoo-http
Expand Down
2 changes: 1 addition & 1 deletion images/nixos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ simplestream:
distro_name: NixOS
requirements:
- requirements:
secure_boot: false
secureboot: false

source:
downloader: nixos-http
Expand Down

0 comments on commit ec914d0

Please sign in to comment.