1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00

tests: Fix SR-IOV attached key test

Signed-off-by: Shaderbug <119610832+Shaderbug@users.noreply.github.com>
This commit is contained in:
Shaderbug
2026-02-01 13:25:58 +01:00
parent a0470f7b04
commit 9bbd1361a8

View File

@@ -10,6 +10,8 @@ test_container_devices_nic_sriov() {
ensure_import_testimage
ensure_has_localhost_remote "${INCUS_ADDR}"
IF_UP_TIMEOUT=15
parent=${INCUS_NIC_SRIOV_PARENT:-""}
if [ "$parent" = "" ]; then
@@ -155,14 +157,40 @@ test_container_devices_nic_sriov() {
fi
# Test attached key.
incus config device add "${ctName}" eth0 nic network="${ctName}" name=eth0
incus config device remove "${ctName}" eth0
incus config device add "${ctName}" eth0 nic network="${ctName}net" name=eth0
incus exec "${ctName}" ip link set eth0 up
[ "$(incus file pull "${ctName}/sys/class/net/eth0/operstate" -)" = "up" ]
# Interfaces don't immediately become operationally up
for attempt in $(seq "${IF_UP_TIMEOUT}"); do
if [ "$(incus file pull "${ctName}/sys/class/net/eth0/operstate" -)" = "up" ]; then
break
fi
if [ "${attempt}" -eq "${IF_UP_TIMEOUT}" ]; then
echo "eth0 in instance did not enter operstate up in time"
false
fi
sleep 1
done
incus config device set "${ctName}" eth0 attached=false
! incus file pull "${ctName}/sys/class/net/eth0/operstate" - || false
incus config device set "${ctName}" eth0 attached=true
incus exec "${ctName}" ip link set eth0 up
[ "$(incus file pull "${ctName}/sys/class/net/eth0/operstate" -)" = "up" ]
# Interfaces don't immediately become operationally up
for attempt in $(seq "${IF_UP_TIMEOUT}"); do
if [ "$(incus file pull "${ctName}/sys/class/net/eth0/operstate" -)" = "up" ]; then
break
fi
if [ "${attempt}" -eq "${IF_UP_TIMEOUT}" ]; then
echo "eth0 in instance did not enter operstate up in time"
false
fi
sleep 1
done
incus config device remove "${ctName}" eth0
incus network delete "${ctName}net"