mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
Merge pull request #2882 from Shaderbug/fix/sriov-attached-key-test
tests: Fix SR-IOV attached key test
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user