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

Polish tests/network-sriov test #54

Merged
merged 13 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions tests/main-testflinger
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ run_test jammy default tests/devlxd-vm "${lxd_snap_channel}"
#run_test jammy default tests/docker "${lxd_snap_channel}"

# gpu
# XXX: requires nvidia graphic card to be present in the host and to
# know which PCI address it has
#run_test jammy default tests/gpu-container "${lxd_snap_channel}"
# XXX: requires nvidia graphic card to be present in the host
run_test jammy default tests/gpu-container "${lxd_snap_channel}"
# XXX: requires a specific nvidia graphic card to be present in the host
#run_test jammy default tests/gpu-mig "${lxd_snap_channel}"
run_test jammy default tests/gpu-mig "${lxd_snap_channel}"
# XXX: requires nvidia graphic card to be present in the host and a
# compatible driver to be installed
#run_test jammy default tests/gpu-vm "${lxd_snap_channel}" nvidia
Expand All @@ -72,7 +71,7 @@ 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
#run_test jammy default tests/network-sriov "${lxd_snap_channel}"
run_test jammy default tests/network-sriov "${lxd_snap_channel}"

# pylxd
run_test jammy default tests/pylxd "${lxd_snap_channel}"
Expand Down
52 changes: 40 additions & 12 deletions tests/network-sriov
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
#!/bin/sh
set -eu
set -eux

# testflinger_queue: luma

# Check if IOMMU is configured
if [ -n "$(find /sys/kernel/iommu_groups/ -empty)" ]; then
echo "System not IOMMU ready, hint: \"./bin/custom-kernel iommu\"" >&2
exit 1
fi

# Install LXD
install_lxd

parentNIC="${1}"
# Install dependencies
install_deps jq

parentNIC="${1:-}"

if [ -z "${parentNIC}" ]; then
# Consult available resources
first_sriov_nic="$(lxc query /1.0/resources | jq -r '[.network.cards | .[] | select(.sriov != null) | .ports][0] | .[0].id')"
parentNIC="${first_sriov_nic}"
fi

# Enable SR-IOV on nic and bring up
enableNICSRIOV "${parentNIC}"
Expand Down Expand Up @@ -37,28 +54,36 @@ networkTests() {
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}"
FAIL=1
echo "WARN: IPv6 address: ${name}"
#FAIL=1
fi

# DNS resolution
if lxc exec "${name}" -- getent hosts linuxcontainers.org >/dev/null 2>&1 || lxc exec "${name}" -- ping -c1 -W1 linuxcontainers.org >/dev/null 2>&1; then
if lxc exec "${name}" -- getent hosts archive.ubuntu.com >/dev/null 2>&1; then
echo "PASS: DNS resolution: ${name}"
else
echo "FAIL: DNS resolution: ${name}"
FAIL=1
fi

# TCP connectivity
if lxc exec "${name}" -- nc -zv archive.ubuntu.com 80 >/dev/null 2>&1; then
echo "PASS: TCP connectivity: ${name}"
else
echo "FAIL: TCP connectivity: ${name}"
FAIL=1
fi
done

if [ "${FAIL}" = "1" ]; then
Expand All @@ -76,21 +101,21 @@ lxc profile device add default eth0 nic nictype=sriov parent="${parentNIC}" name
# Launch a few VMs.
# Do this first before containers to ensure VF free search handles VFs unbound from host.
echo "==> VM on default VLAN"
lxc init ubuntu-daily:23.10 v1 --vm
lxc init ubuntu-daily:24.04 v1 --vm
lxc start v1

echo "==> VM on default VLAN with filtering"
lxc init ubuntu-daily:23.10 v2 --vm
lxc init ubuntu-daily:24.04 v2 --vm
lxc config device override v2 eth0 security.mac_filtering=true
lxc start v2

echo "==> VM on alternate VLAN"
lxc init ubuntu-daily:23.10 v3 --vm
lxc init ubuntu-daily:24.04 v3 --vm
lxc config device override v3 eth0 vlan=4000
lxc start v3

echo "==> VM on alternate VLAN with filtering"
lxc init ubuntu-daily:23.10 v4 --vm
lxc init ubuntu-daily:24.04 v4 --vm
lxc config device override v4 eth0 vlan=4000 security.mac_filtering=true
lxc start v4

Expand Down Expand Up @@ -128,7 +153,10 @@ lxc config device override c4 eth0 vlan=4000 security.mac_filtering=true
lxc start c4

# Wait for containers to start.
sleep 30s
waitInstanceReady c1
waitInstanceReady c2
waitInstanceReady c3
waitInstanceReady c4

lxc list
networkTests
Expand Down
Loading