Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testflinger #39

Merged
merged 44 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e8799da
bin/openstack-run: mention which snap channel is used for the test
simondeziel Nov 30, 2023
cda5559
bin/testflinger-run: add new runner script
simondeziel Nov 29, 2023
2d40637
tests/cluster: use ubuntu-daily:22.04 image
simondeziel Nov 30, 2023
1dc904a
tests/cpu-vm: use helper functions
simondeziel Nov 30, 2023
643148e
tests/cpu-vm: use ubuntu-daily:22.04 image
simondeziel Nov 30, 2023
9a932bb
tests/cluster: add FAIL and use a shorter PREFIX
simondeziel Nov 30, 2023
fd37eac
tests/devlxd-vm: use helper functions
simondeziel Nov 30, 2023
d931f3e
tests/devlxd-vm: use ubuntu-daily:22.04
simondeziel Nov 30, 2023
84f3073
tests/docker: use helper functions
simondeziel Nov 30, 2023
30a2580
tests/docker: use ubuntu-daily:22.04 image
simondeziel Nov 30, 2023
07373b2
tests/kernel: use helper functions
simondeziel Nov 30, 2023
798a6b8
tests/network: use helper functions
simondeziel Nov 30, 2023
a7d6b7d
tests/network: use ubuntu-daily:22.04 image
simondeziel Nov 30, 2023
0c817e6
tests/vm-nesting: use helper functions
simondeziel Nov 30, 2023
47fe6d4
tests/vm-nesting: use helper functions
simondeziel Nov 30, 2023
3b7f0fc
tests/vm-nesting: use helper functions
simondeziel Nov 30, 2023
24b6de7
tests/vm-nesting: use ubuntu-daily:22.04 image
simondeziel Nov 30, 2023
8902e06
tests/gpu-vm: import test
simondeziel Dec 1, 2023
d1df8f4
tests/gpu-vm: use helper functions
simondeziel Dec 1, 2023
0d057c9
tests/gpu-vm: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
662b6f6
tests/gpu-mig: import test
simondeziel Dec 1, 2023
6b5710e
tests/gpu-mig: use helper functions
simondeziel Dec 1, 2023
ee60b5a
tests/gpu-mig: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
977fd77
bin/helpers: add waitInstanceReady and setupCloudInitReady functions
simondeziel Dec 1, 2023
cd3d646
bin/helpers: add enableNICSRIOV function
simondeziel Dec 1, 2023
79951e0
tests/network: use setupCloudInitReady helper function
simondeziel Dec 1, 2023
568250e
tests/network: use enableNICSRIOV helper function
simondeziel Dec 1, 2023
6c2abfb
tests/network-ovn: use helper functions
simondeziel Dec 1, 2023
865e5a4
tests/network-ovn: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
01a1651
tests/network-routed: use helper functions
simondeziel Dec 1, 2023
c4d614d
tests/network-routed: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
f0130d5
tests/network-routed: remove unneeded cat
simondeziel Dec 1, 2023
0d707a9
tests/network-sriov: use helper functions
simondeziel Dec 1, 2023
a7a929c
tests/network-sriov: use helper functions
simondeziel Dec 1, 2023
a6037bf
tests/network-sriov: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
98e2dc2
tests/pylxd: add trailing line
simondeziel Dec 1, 2023
afa0c9f
tests/storage-buckets: use helper functions
simondeziel Dec 1, 2023
e92827b
tests/storage-buckets: skip some parts if ceph isn't being tested
simondeziel Dec 1, 2023
861bed3
tests/storage-vm: use helper functions
simondeziel Dec 1, 2023
35302d0
tests/storage-volumes-vm: use helper functions
simondeziel Dec 1, 2023
7cdd1b9
tests/storage-volumes-vm: use ubuntu-daily:22.04 image
simondeziel Dec 1, 2023
6a1e687
tests/storage-volumes-vm: use "lxc delete" instead of "lxc rm"
simondeziel Dec 1, 2023
b116691
tests/main-testflinger: allow running many tests scripts through test…
simondeziel Dec 1, 2023
21885e5
gitignore: ignore out/ dir
simondeziel Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/openstack-run
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ if [ "${kernel}" != "default" ]; then
fi

# Connect and run something
echo "==> Running the job (${test_name})" >&2
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}"
if echo "${IP}" | grep -q ":"; then
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${_script}" "ubuntu@[${IP}]:test-script"
Expand Down
58 changes: 58 additions & 0 deletions bin/testflinger-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
set -eux

serie="${1}"
kernel="${2}"
Fixed Show fixed Hide fixed
script="${3}"
lxd_snap_channel="${4}"
shift 4
_script="$(mktemp)"
test_name="$(basename "${script}")"

testflinger_yaml_job() {
cat << EOF
job_queue: anything
provision_data:
distro: ${serie}
test_data:
test_cmds: |
#!/bin/bash
set -eux
export SSH_OPTS="-q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=30 -o ServerAliveCountMax=3"
SCP="scp \$SSH_OPTS"
SSH="ssh -n \$SSH_OPTS"

# Get lxd-ci scripts
git clone https://github.com/canonical/lxd-ci.git
cd lxd-ci

echo "Desired kernel: ${kernel}"

# 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
EOF
}

setup_testflinger() {
# Test connectivity
if ! wget --method HEAD -qO /dev/null https://testflinger.canonical.com/agents; then
echo "Failed to connect to testflinger.canonical.com, make sure you are connected to the VPN" >&2
exit 1
fi

command -v testflinger >/dev/null && return

echo "Installing testflinger snap" >&2
snap install testflinger-cli
}

setup_testflinger

# Submit the job
echo "==> Running the job ${test_name} against ${lxd_snap_channel}" >&2
testflinger_yaml_job | testflinger submit --poll -
28 changes: 11 additions & 17 deletions tests/cluster
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh -eu
PREFIX="cluster-$(uuidgen)"
#!/bin/sh
set -eu

PREFIX="cluster-$$"

if [ -z "${1:-""}" ] || [ -z "${2:-""}" ] || [ -z "${3:-""}" ]; then
echo "Usage: ${0} <count> <source channel> <destination channel>"
Expand Down Expand Up @@ -31,21 +33,11 @@ cleanup() {
trap cleanup EXIT HUP INT TERM

# Launch the container
lxc launch images:ubuntu/jammy "${PREFIX}-1" -c security.nesting=true
lxc launch ubuntu-daily:22.04 "${PREFIX}-1" -c security.nesting=true

sleep 10

lxc file push - "${PREFIX}-1"/etc/apt/sources.list << EOF
deb http://us.archive.ubuntu.com/ubuntu jammy main universe
deb http://us.archive.ubuntu.com/ubuntu jammy-updates main universe
deb http://us.archive.ubuntu.com/ubuntu jammy-security main universe
EOF

lxc exec "${PREFIX}-1" -- apt-get update
lxc exec "${PREFIX}-1" -- apt-get install --no-install-recommends snapd fuse3 curl --yes
lxc exec "${PREFIX}-1" -- snap install core20
lxc exec "${PREFIX}-1" -- snap install core22
lxc exec "${PREFIX}-1" -- snap install lxd --channel="$2"
lxc exec "${PREFIX}-1" -- snap refresh lxd --channel="$2"

for i in $(seq 2 "$1"); do
lxc copy "${PREFIX}-1" "${PREFIX}-$i"
Expand All @@ -55,7 +47,6 @@ done
for i in $(seq "$1"); do
sleep 10


# Configure the cluster
if [ "$i" = "1" ]; then
CLUSTER_IP=$(lxc exec "${PREFIX}-$i" -- ip -4 addr show dev eth0 scope global | grep inet | cut -d' ' -f6 | cut -d/ -f1)
Expand Down Expand Up @@ -92,8 +83,8 @@ lxc exec "${PREFIX}-1" -- lxc cluster list

# Test fan networking (intra fan from container and host, as well as external NAT comms)
echo "==> Test fan networking"
lxc exec "${PREFIX}-1" -- lxc launch images:ubuntu/focal u1
lxc exec "${PREFIX}-1" -- lxc launch images:ubuntu/focal u2
lxc exec "${PREFIX}-1" -- lxc launch ubuntu-daily:22.04 u1
lxc exec "${PREFIX}-1" -- lxc launch ubuntu-daily:22.04 u2

echo "==> Wait for addresses"
sleep 10
Expand Down Expand Up @@ -121,3 +112,6 @@ sleep 5m
echo "==> Validating the cluster"
lxc exec "${PREFIX}-1" -- lxc info
lxc exec "${PREFIX}-1" -- lxc cluster list

# shellcheck disable=SC2034
FAIL=0
56 changes: 3 additions & 53 deletions tests/cpu-vm
Original file line number Diff line number Diff line change
@@ -1,64 +1,13 @@
#!/bin/sh
set -eux

waitSnapdSeed() (
set +x
for i in $(seq 60); do # Wait up to 60s.
if systemctl show snapd.seeded.service --value --property SubState | grep -qx exited; then
return 0 # Success.
fi

sleep 1
done

echo "snapd not seeded after ${i}s"
return 1 # Failed.
)

cleanup() {
echo ""
if [ "${FAIL}" = "1" ]; then
echo "Test failed"
exit 1
fi

echo "Test passed"
exit 0
}

architecture="$(uname -m)"

if [ "${architecture}" != "x86_64" ] && [ "${architecture}" != "s390x" ]; then
echo "Skipping test as CPU hotplugging not supported on ${architecture}"
fi

FAIL=1
trap cleanup EXIT HUP INT TERM

# Wait for snapd seeding
waitSnapdSeed

# Install LXD
snap remove lxd || true
snap install lxd --channel=latest/edge
lxd waitready --timeout=300

waitVMAgent() (
set +x
# shellcheck disable=SC3043
local vmName="$1"
for i in $(seq 90) # Wait up to 90s.
do
if lxc info "${vmName}" | grep -qF 127.0.0.1; then
return 0 # Success.
fi

sleep 1
done

echo "VM ${vmName} agent not running after ${i}s"
return 1 # Failed.
)
install_lxd

# Configure LXD
lxc network create lxdbr0
Expand All @@ -71,7 +20,7 @@ echo "==> Create storage pool using driver ${poolDriver}"
lxc storage create "${poolName}" "${poolDriver}"

echo "==> Create ephemeral VM and boot"
lxc launch images:ubuntu/22.04 v1 --vm -s "${poolName}" --ephemeral
lxc launch ubuntu-daily:22.04 v1 --vm -s "${poolName}" --ephemeral
waitVMAgent v1
lxc info v1

Expand Down Expand Up @@ -123,4 +72,5 @@ lxc storage delete "${poolName}"
echo "==> Deleting storage pool"
lxc network delete lxdbr0

# shellcheck disable=SC2034
FAIL=0
67 changes: 9 additions & 58 deletions tests/devlxd-vm
Original file line number Diff line number Diff line change
@@ -1,59 +1,14 @@
#!/bin/sh
set -eux

waitSnapdSeed() (
set +x
for i in $(seq 60); do # Wait up to 60s.
if systemctl show snapd.seeded.service --value --property SubState | grep -qx exited; then
return 0 # Success.
fi
# Refresh apt
apt-get update

sleep 1
done

echo "snapd not seeded after ${i}s"
return 1 # Failed.
)

cleanup() {
echo ""
if [ "${FAIL}" = "1" ]; then
echo "Test failed"
exit 1
fi

echo "Test passed"
exit 0
}

FAIL=1
trap cleanup EXIT HUP INT TERM

# Wait for snapd seeding
waitSnapdSeed

# Install LXD
snap remove lxd || true
snap install lxd --channel=latest/edge
# Install dependencies
apt-get install --no-install-recommends --yes jq
lxd waitready --timeout=300

waitVMAgent() (
set +x
# shellcheck disable=SC3043
local vmName="$1"
for i in $(seq 90) # Wait up to 90s.
do
if lxc info "${vmName}" | grep -qF 127.0.0.1; then
return 0 # Success.
fi

sleep 1
done

echo "VM ${vmName} agent not running after ${i}s"
return 1 # Failed.
)
# Install LXD
install_lxd

# Configure LXD
lxc network create lxdbr0
Expand All @@ -66,14 +21,10 @@ echo "==> Create storage pool using driver ${poolDriver}"
lxc storage create "${poolName}" "${poolDriver}"

echo "==> Create VM and boot"
lxc init images:ubuntu/22.04/cloud v1 --vm -s "${poolName}"
lxc start v1
lxc launch ubuntu-daily:22.04 v1 --vm -s "${poolName}"
waitVMAgent v1
lxc info v1

# Install curl
lxc exec v1 -- sh -c "apt-get update && apt-get install --no-install-recommends --yes curl"

echo "==> Checking devlxd is working"

# devlxd is enabled by default and should work
Expand Down Expand Up @@ -136,10 +87,9 @@ lxc start v1
waitVMAgent v1

# Configure to use the proxy
lxc exec v1 -- apt-get install --no-install-recommends snapd --yes
lxc exec v1 -- snap install lxd --channel=latest/edge
lxc exec v1 -- snap install lxd --channel="${LXD_SNAP_CHANNEL:-"latest/edge"}"
lxc exec v1 -- /snap/bin/lxd init --auto
lxc exec v1 -- /snap/bin/lxc launch images:ubuntu/22.04/cloud v1v1 --vm
lxc exec v1 -- /snap/bin/lxc launch ubuntu-daily:22.04 v1v1 --vm
sleep 30
lxc exec v1 -- /snap/bin/lxc info v1v1 | grep -F RUNNING

Expand All @@ -153,4 +103,5 @@ lxc storage delete "${poolName}"
echo "==> Deleting storage pool"
lxc network delete lxdbr0

# shellcheck disable=SC2034
FAIL=0
52 changes: 9 additions & 43 deletions tests/docker
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
#!/bin/sh -eux
CNAME="docker-$(uuidgen)"

waitSnapdSeed() (
set +x
for i in $(seq 60); do # Wait up to 60s.
if systemctl show snapd.seeded.service --value --property SubState | grep -qx exited; then
return 0 # Success.
fi

sleep 1
done

echo "snapd not seeded after ${i}s"
return 1 # Failed.
)

cleanup() {
echo ""
if [ "${FAIL}" = "1" ]; then
echo "Test failed"
exit 1
fi

echo "Test passed"
exit 0
}

FAIL=1
trap cleanup EXIT HUP INT TERM
#!/bin/sh
set -eux

# Wait for snapd seeding
waitSnapdSeed
CNAME="docker-$$"

# Install LXD
snap remove lxd || true
snap install lxd --channel=latest/edge
apt-get install --no-install-recommends --yes jq
lxd waitready --timeout=300

lxd init --auto
set -x
install_lxd

# Create the container
lxc launch images:ubuntu/bionic "${CNAME}" -c security.nesting=true "$@"
lxc launch ubuntu-daily:22.04 "${CNAME}" -c security.nesting=true "$@"

(
cat << EOF
Expand All @@ -52,9 +17,8 @@ sleep 10
set -eux

# Install distro docker
apt-get update --yes --force-yes
apt-get install --no-install-recommends --yes --force-yes apparmor docker.io wget
systemctl start apparmor
apt-get update
apt-get install --no-install-recommends --yes --force-yes docker.io

# Stop the distro docker
systemctl stop docker.service
Expand Down Expand Up @@ -85,4 +49,6 @@ EOF
) | lxc exec "${CNAME}" -- sh -eux

lxc delete --force "${CNAME}"

# shellcheck disable=SC2034
FAIL=0
Loading