Skip to content

Commit

Permalink
test-image: Cleanup test logic
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Oct 20, 2023
1 parent 3f1159c commit 3d55b3c
Showing 1 changed file with 24 additions and 38 deletions.
62 changes: 24 additions & 38 deletions bin/test-image
Original file line number Diff line number Diff line change
Expand Up @@ -66,61 +66,47 @@ EOF
)"
fi
else
incus init "${TEST_IMAGE}" "${TEST_IMAGE}-unpriv"
INSTANCES="${TEST_IMAGE}-unpriv"

if [ "${DIST}" = "nixos" ]; then
# NixOS can't do privileged containers at this point
continue
fi

incus init "${TEST_IMAGE}" "${TEST_IMAGE}-priv" -c security.privileged=true
INSTANCES="${INSTANCES} ${TEST_IMAGE}-priv"
for PRIV in "priv" "unpriv"; do
if [ "${PRIV}" = "priv" ] && [ "${DIST}" = "nixos" ]; then
# NixOS can't do privileged containers at this point
continue
fi

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

if [ "${DIST}" = "slackware" ]; then
# Workaround weird init system
incus config set "${TEST_IMAGE}-unpriv" raw.lxc lxc.signal.halt=SIGKILL
incus config set "${TEST_IMAGE}-priv" raw.lxc lxc.signal.halt=SIGKILL
fi
if [ "${PRIV}" = "priv" ]; then
incus config set "${TEST_IMAGE}-${PRIV}" security.privileged=true
fi

# Cloud-init testing
if [ "${VARIANT}" = "cloud" ]; then
incus config set "${TEST_IMAGE}-unpriv" user.user-data "$(cat << EOF
#cloud-config
write_files:
- content: "foo\n"
path: /user-data
EOF
)"
if [ "${DIST}" = "voidlinux" ]; then
# Workaround weird init system
incus config set "${TEST_IMAGE}-${PRIV}" raw.lxc lxc.signal.halt=SIGCONT
fi

incus config set "${TEST_IMAGE}-unpriv" user.vendor-data "$(cat << EOF
#cloud-config
bootcmd:
- "echo bar > /vendor-data"
EOF
)"
if [ "${DIST}" = "slackware" ]; then
# Workaround weird init system
incus config set "${TEST_IMAGE}-${PRIV}" raw.lxc lxc.signal.halt=SIGKILL
fi

incus config set "${TEST_IMAGE}-priv" user.user-data "$(cat << EOF
# Cloud-init testing
if [ "${VARIANT}" = "cloud" ]; then
incus config set "${TEST_IMAGE}-${PRIV}" user.user-data "$(cat << EOF
#cloud-config
write_files:
- content: "foo\n"
path: /user-data
EOF
)"

incus config set "${TEST_IMAGE}-priv" user.vendor-data "$(cat << EOF
incus config set "${TEST_IMAGE}-${PRIV}" user.vendor-data "$(cat << EOF
#cloud-config
bootcmd:
- "echo bar > /vendor-data"
EOF
)"
fi
fi
done
fi

# Start them all
Expand Down

0 comments on commit 3d55b3c

Please sign in to comment.