Skip to content

Commit

Permalink
Merge pull request #40 from simondeziel/testflinger-alt-kernel
Browse files Browse the repository at this point in the history
Testflinger alt kernel
  • Loading branch information
tomponline authored Dec 6, 2023
2 parents c67d440 + 4ef0657 commit 7b22f8e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
15 changes: 10 additions & 5 deletions bin/custom-kernel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
export DEBIAN_FRONTEND="noninteractive"
for i in $(echo "${1}" | tr ',' ' '); do
case "$i" in
Expand All @@ -12,31 +12,27 @@ case "$i" in

# shellcheck disable=SC2016
echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} systemd.unified_cgroup_hierarchy=0"' > /etc/default/grub.d/99-cgroup.cfg
update-grub
;;

cgroup2)
echo "===> CGroup2"

# shellcheck disable=SC2016
echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} systemd.unified_cgroup_hierarchy=1"' > /etc/default/grub.d/99-cgroup.cfg
update-grub
;;

swapaccount)
echo "===> CGroup swap accounting"

# shellcheck disable=SC2016
echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} swapaccount=1"' > /etc/default/grub.d/99-cgroup-swap.cfg
update-grub
;;

iommu)
echo "===> Enabling iommu"

# shellcheck disable=SC2016
echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} iommu=pt intel_iommu=on amd_iommu=on"' > /etc/default/grub.d/99-iommu.cfg
update-grub
;;

hwe)
Expand All @@ -45,6 +41,8 @@ case "$i" in
echo "MODULES=dep" > /etc/initramfs-tools/conf.d/modules.conf
apt-get update
apt-get dist-upgrade --yes

# shellcheck disable=SC1091
. /etc/os-release

FLAVOR="generic"
Expand Down Expand Up @@ -115,4 +113,11 @@ case "$i" in
esac
done

# Since we are doing a reboot, might as well also turn off mitigations and have a faster testbed
echo "===> Disabling all mitigations"

# shellcheck disable=SC2016
echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} mitigations=off"' > /etc/default/grub.d/99-mitigations.cfg
update-grub

reboot
2 changes: 2 additions & 0 deletions bin/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ install_lxd() (
snap remove lxd || true
snap install lxd --channel="${LXD_SNAP_CHANNEL:-"latest/edge"}"
snap list lxd
uname -a
cat /proc/cmdline
lxd waitready --timeout=300
)

Expand Down
2 changes: 1 addition & 1 deletion bin/local-run
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ test_name="$(basename "${script}")"

echo "==> Running the job ${test_name} against ${lxd_snap_channel}" >&2
sed -e "1 a LXD_SNAP_CHANNEL=${lxd_snap_channel}" -e "1 r bin/helpers" "${script}" > "${_script}"
exec sh "${_script}"
exec bash "${_script}"
4 changes: 2 additions & 2 deletions bin/openstack-run
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" c
# Setup custom kernel
if [ "${kernel}" != "default" ]; then
echo "==> Installing custom kernel: ${kernel}" >&2
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo sh /dev/stdin "${kernel}" < "bin/custom-kernel" || true
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo bash /dev/stdin "${kernel}" < "bin/custom-kernel" || true
sleep 5
wait_machine
fi
Expand All @@ -101,7 +101,7 @@ if echo "${IP}" | grep -q ":"; then
else
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${_script}" "ubuntu@${IP}:test-script"
fi
ssh -n -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo "https_proxy=http://squid.internal:3128" sh test-script "$@"
ssh -n -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@${IP}" sudo "https_proxy=http://squid.internal:3128" bash test-script "$@"

# Success
RET=0
32 changes: 30 additions & 2 deletions bin/testflinger-run
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,43 @@ test_data:
git clone https://github.com/canonical/lxd-ci.git
cd lxd-ci
echo "Desired kernel: ${kernel}"
# wait for a machine to be ready
wait_machine() {
echo "==> Waiting for SSH to respond" >&2
# shellcheck disable=SC2034
for i in \$(seq 600); do
nc -w1 -z "\${DEVICE_IP}" 22 && break
sleep 1
done
# Work around regression in cloud-init delaying SSH access
# https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/2039441
for _ in \$(seq 30); do
\$SSH -o ConnectTimeout=1 "ubuntu@\${DEVICE_IP}" true && break
sleep 1
done
}
# Setup custom kernel
if [ "${kernel}" != "default" ]; then
echo "==> Installing custom kernel: ${kernel}" >&2
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "ubuntu@\${DEVICE_IP}" sudo bash /dev/stdin "${kernel}" < "bin/custom-kernel" || true
sleep 5
if ! command -v nc > /dev/null; then
apt-get update
apt-get install -y netcat-openbsd
fi
wait_machine
fi
# Copy test script to DUT
_script="\$(mktemp)"
sed -e "1 a LXD_SNAP_CHANNEL=${lxd_snap_channel}" -e "1 r bin/helpers" "${script}" > "\${_script}"
\$SCP "\${_script}" "ubuntu@\${DEVICE_IP}:test-script"
# Run the test
\$SSH "ubuntu@\${DEVICE_IP}" -- sudo sh test-script
\$SSH "ubuntu@\${DEVICE_IP}" -- sudo bash test-script
EOF
}

Expand Down
8 changes: 4 additions & 4 deletions tests/main-testflinger
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ run_test jammy default tests/cgroup "${lxd_snap_channel}"
# XXX: disable test with Jammy's GA kernel configured for cgroup1
# https://github.com/canonical/lxd-ci/issues/7
#run_test jammy cgroup1 tests/cgroup "${lxd_snap_channel}"
#run_test jammy swapaccount tests/cgroup "${lxd_snap_channel}"
run_test jammy swapaccount tests/cgroup "${lxd_snap_channel}"
run_test focal default tests/cgroup "${lxd_snap_channel}"
#run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"
run_test focal swapaccount tests/cgroup "${lxd_snap_channel}"

# cluster
#run_test jammy default tests/cluster "${lxd_snap_channel}" 3 "5.0/stable" "${lxd_snap_channel}"
Expand Down Expand Up @@ -68,7 +68,7 @@ fi
# network
run_test jammy default tests/network "${lxd_snap_channel}"
run_test jammy default tests/network-bridge-firewall "${lxd_snap_channel}"
#run_test jammy hwe tests/network-bridge-firewall "${lxd_snap_channel}"
run_test jammy hwe tests/network-bridge-firewall "${lxd_snap_channel}"
run_test jammy default tests/network-ovn "${lxd_snap_channel}"
run_test jammy default tests/network-routed "${lxd_snap_channel}"
# XXX: requires SR-IOV capable NIC
Expand All @@ -85,7 +85,7 @@ run_test jammy default tests/storage-volume-vm "${lxd_snap_channel}"

# vm-nesting
run_test jammy default tests/vm-nesting "${lxd_snap_channel}"
#run_test jammy hwe tests/vm-nesting "${lxd_snap_channel}"
run_test jammy hwe tests/vm-nesting "${lxd_snap_channel}"

# Wait for all tests to finish
errors=0
Expand Down
2 changes: 1 addition & 1 deletion tests/vm-nesting
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function start() {
done

echo "Start ${instances[*]}"
lxc start -f "${instances[@]}"
lxc start "${instances[@]}"
}

function wait() {
Expand Down

0 comments on commit 7b22f8e

Please sign in to comment.