Skip to content

Commit

Permalink
tests/*: allow switching to a different remote/image by exporting TES…
Browse files Browse the repository at this point in the history
…T_IMG

Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Jan 15, 2024
1 parent df1d99c commit 672fe5b
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion tests/cgroup
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -x

# Start a container with no limits
echo "=> Start a container with no limits"
lxc launch ubuntu-daily:22.04 c1
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1

echo "==> Validate default values"
[ "$(lxc exec c1 -- nproc)" = "$(nproc)" ]
Expand Down
6 changes: 3 additions & 3 deletions tests/cluster
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extra_cleanup() {
}

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

sleep 10

Expand Down Expand Up @@ -88,8 +88,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 ubuntu-daily:22.04 u1
lxc exec "${PREFIX}-1" -- lxc launch ubuntu-daily:22.04 u2
lxc exec "${PREFIX}-1" -- lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" u1
lxc exec "${PREFIX}-1" -- lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" u2

echo "==> Wait for addresses"
sleep 10
Expand Down
2 changes: 1 addition & 1 deletion tests/cpu-vm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo "==> Create storage pool using driver ${poolDriver}"
lxc storage create "${poolName}" "${poolDriver}"

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

Expand Down
4 changes: 2 additions & 2 deletions tests/devlxd-vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo "==> Create storage pool using driver ${poolDriver}"
lxc storage create "${poolName}" "${poolDriver}"

echo "==> Create VM and boot"
lxc launch ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
waitInstanceReady v1
lxc info v1

Expand Down Expand Up @@ -88,7 +88,7 @@ lxc exec v1 -- snap wait system seed.loaded
lxc exec v1 -- snap remove --purge lxd || true
lxc exec v1 -- snap install lxd --channel="${LXD_SNAP_CHANNEL}"
lxc exec v1 -- /snap/bin/lxd init --auto
lxc exec v1 -- /snap/bin/lxc launch ubuntu-daily:22.04 v1v1 --vm
lxc exec v1 -- /snap/bin/lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" v1v1 --vm
sleep 30
lxc exec v1 -- /snap/bin/lxc info v1v1 | grep -F RUNNING

Expand Down
2 changes: 1 addition & 1 deletion tests/docker
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lxd init --auto
CNAME="docker-$$"

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

(
cat << EOF
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu-container
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ total_nvidia_gpu_with_product_id="$(lxc query /1.0/resources | jq -r ".gpu.cards

# Launch a test container
echo "==> Launching a test container"
lxc launch ubuntu-daily:22.04 c1
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1
waitInstanceReady c1

# Confirm no GPU
Expand Down
8 changes: 4 additions & 4 deletions tests/gpu-mig
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ UUID3="$(echo "$UUIDS" | sed -n '3p')"
UUID4="$(echo "$UUIDS" | sed -n '4p')"

# Launch test containers
lxc init ubuntu-daily:22.04 nvidia-mig1 -c nvidia.runtime=true
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" nvidia-mig1 -c nvidia.runtime=true
lxc config device add nvidia-mig1 gpu0 gpu gputype=mig mig.uuid="$UUID1" pci="${first_card_pci_slot}"
lxc init ubuntu-daily:22.04 nvidia-mig2 -c nvidia.runtime=true
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" nvidia-mig2 -c nvidia.runtime=true
lxc config device add nvidia-mig2 gpu0 gpu gputype=mig mig.uuid="$UUID2" pci="${first_card_pci_slot}"
lxc init ubuntu-daily:22.04 nvidia-mig3 -c nvidia.runtime=true
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" nvidia-mig3 -c nvidia.runtime=true
lxc config device add nvidia-mig3 gpu0 gpu gputype=mig mig.uuid="$UUID3" pci="${first_card_pci_slot}"
lxc init ubuntu-daily:22.04 nvidia-mig4 -c nvidia.runtime=true
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" nvidia-mig4 -c nvidia.runtime=true
lxc config device add nvidia-mig4 gpu0 gpu gputype=mig mig.uuid="$UUID4" pci="${first_card_pci_slot}"
lxc start nvidia-mig1
lxc exec nvidia-mig1 -- nvidia-smi
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu-vm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lxc info --resources

# Launch test instances
for i in $(seq 1 4); do
lxc init ubuntu-daily:22.04 "v${i}" --vm -c security.secureboot=false
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" "v${i}" --vm -c security.secureboot=false
if [ "${1}" = "nvidia" ]; then
lxc config device add "v${i}" vgpu gpu gputype=mdev pci=0000:07:00.0 mdev=nvidia-468
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/interception
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lxd init --auto
# Test
set -x

lxc launch ubuntu-daily:22.04 c1
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1
sleep 10
lxc exec c1 -- apt-get update
lxc exec c1 -- apt-get install --no-install-recommends --yes attr fuse2fs
Expand Down
8 changes: 4 additions & 4 deletions tests/network
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ lxc config device add v1-physical eth0 nic nictype=physical parent="${parentNIC}
lxc start v1-physical

echo "==> Container on default VLAN with physical"
lxc init ubuntu-daily:22.04 c1-physical
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c1-physical
lxc config device add c1-physical eth0 nic nictype=physical parent="${parentNIC}v2" name=eth0
lxc start c1-physical

# Launch instances with macvlan NICs
echo "==> VM on default VLAN with macvlan"
lxc init ubuntu-daily:22.04 v1-macvlan --vm -c limits.cpu=3
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1-macvlan --vm -c limits.cpu=3
lxc config device add v1-macvlan eth0 nic nictype=macvlan parent="${parentNIC}" name=eth0
lxc start v1-macvlan

echo "==> Container on default VLAN with macvlan"
lxc init ubuntu-daily:22.04 c1-macvlan
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c1-macvlan
lxc config device add c1-macvlan eth0 nic nictype=macvlan parent="${parentNIC}" name=eth0
lxc start c1-macvlan

Expand All @@ -45,7 +45,7 @@ lxc config device add v1-sriov eth0 nic nictype=sriov parent="${parentNIC}" name
lxc start v1-sriov

echo "==> Container on default VLAN with sriov"
lxc init ubuntu-daily:22.04 c1-sriov
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c1-sriov
lxc config device add c1-sriov eth0 nic nictype=sriov parent="${parentNIC}" name=eth0
lxc start c1-sriov

Expand Down
4 changes: 2 additions & 2 deletions tests/network-bridge-firewall
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ modprobe br_netfilter
ip link add lxdbr0unmanaged type bridge

firewallTests() {
lxc launch ubuntu-daily:22.04 c1
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1
sleep 10

managed=0
Expand Down Expand Up @@ -118,7 +118,7 @@ firewallTests() {
}

networkLimitsPriorityNftablesTest() {
lxc launch ubuntu-daily:22.04 c1
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" c1
sleep 10

prio=7
Expand Down
2 changes: 1 addition & 1 deletion tests/network-ovn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ovs-vsctl set open_vswitch . \
lxc project switch default
lxc storage create default zfs

instanceImage="ubuntu-daily:22.04"
instanceImage=""${TEST_IMG:-ubuntu-daily:22.04}""

Check warning

Code scanning / shellcheck

The surrounding quotes actually unquote this. Remove or escape them. Warning test

The surrounding quotes actually unquote this. Remove or escape them.

ovn_basic_tests() {
lxc network create lxdbr0 \
Expand Down
2 changes: 1 addition & 1 deletion tests/network-routed
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ip addr add 192.0.2.1/32 dev dummy0
ip addr add 2001:db8::1/128 dev dummy0

# Create VM and add routed NIC.
lxc init ubuntu-daily:22.04 v1 --vm -s default -c limits.memory=512MiB
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s default -c limits.memory=512MiB
lxc config device add v1 eth0 nic \
nictype=routed \
parent=dummy0 \
Expand Down
8 changes: 4 additions & 4 deletions tests/network-sriov
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,21 @@ lxc delete -f v2 v3 v4

# Launch a few containers.
echo "==> Container on default VLAN"
lxc init ubuntu-daily:22.04 c1
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c1
lxc start c1

echo "==> Container on default VLAN with filtering"
lxc init ubuntu-daily:22.04 c2
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c2
lxc config device override c2 eth0 security.mac_filtering=true
lxc start c2

echo "==> Container on alternate VLAN"
lxc init ubuntu-daily:22.04 c3
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c3
lxc config device override c3 eth0 vlan=4000
lxc start c3

echo "==> Container on alternate VLAN with filtering"
lxc init ubuntu-daily:22.04 c4
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" c4
lxc config device override c4 eth0 vlan=4000 security.mac_filtering=true
lxc start c4

Expand Down
16 changes: 8 additions & 8 deletions tests/rbac
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ lxc project create test-auditor -c features.profiles=false

# Create containers in all projects
echo "==> Creating some instances in those projects"
lxc launch ubuntu-daily:22.04 a1 --project test-admin
lxc launch ubuntu-daily:22.04 a2 --project test-operator
lxc launch ubuntu-daily:22.04 a3 --project test-user
lxc launch ubuntu-daily:22.04 a4 --project test-auditor
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a1 --project test-admin
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a2 --project test-operator
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a3 --project test-user
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a4 --project test-auditor

echo "==> Configuring rbac-user for access to projects"
bhttp --raw --agent /var/snap/bhttp/common/rbac-test.admin https://services.stgraber.org/rbac/api/rbac/v1/resource > resources.json
Expand Down Expand Up @@ -138,10 +138,10 @@ lxc snapshot a3 --project test-user

# Validate create permissions
echo "==> Validate create permissions"
lxc launch ubuntu-daily:22.04 a5 --project test-admin
lxc launch ubuntu-daily:22.04 a6 --project test-operator
! lxc launch ubuntu-daily:22.04 a7 --project test-user || false
! lxc launch ubuntu-daily:22.04 a8 --project test-auditor || false
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a5 --project test-admin
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a6 --project test-operator
! lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a7 --project test-user || false
! lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" a8 --project test-auditor || false

# Validate project permissions
echo "==> Validate project permissions"
Expand Down
2 changes: 1 addition & 1 deletion tests/storage-disks-vm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lxc profile device add default eth0 nic network=lxdbr0
lxc profile show default

# Create instance and add check relative source paths are not allowed.
lxc init ubuntu-daily:22.04 v1 --vm
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm
! lxc config device add v1 d1 disk source=foo path=/mnt || false

# Check adding a disk with a source path above the restricted parent source path isn't allowed.
Expand Down
12 changes: 6 additions & 6 deletions tests/storage-vm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ do
fi

echo "==> Create VM and boot"
lxc init ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
lxc start v1
waitInstanceReady v1
lxc info v1
Expand Down Expand Up @@ -208,7 +208,7 @@ do
truncate -s 5m "/tmp/lxd-test-${poolName}/lxd-test-block"

echo "==> Checking disk device hotplug support"
lxc launch ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc launch "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
waitInstanceReady v1

# Hotplug disks
Expand Down Expand Up @@ -250,7 +250,7 @@ do

echo "==> Change volume.size on pool and create VM"
lxc storage set "${poolName}" volume.size 6GiB
lxc init ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
lxc start v1
waitInstanceReady v1
lxc info v1
Expand All @@ -265,7 +265,7 @@ do
if [ "${poolDriver}" = "lvm" ]; then
echo "==> Change volume.block.filesystem on pool and create VM"
lxc storage set "${poolName}" volume.block.filesystem xfs
lxc init ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
lxc start v1
waitInstanceReady v1
lxc info v1
Expand All @@ -282,7 +282,7 @@ do
echo "==> Create VM from profile with small disk size"
lxc profile copy default vmsmall
lxc profile device add vmsmall root disk pool="${poolName}" path=/ size=7GiB
lxc init ubuntu-daily:22.04 v1 --vm -p vmsmall
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -p vmsmall
lxc start v1
waitInstanceReady v1
lxc info v1
Expand Down Expand Up @@ -372,7 +372,7 @@ do
lxc profile delete vmsmall

echo "==> Checking VM Generation UUID with QEMU"
lxc init ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
lxc start v1
waitInstanceReady v1
lxc info v1
Expand Down
4 changes: 2 additions & 2 deletions tests/storage-volumes-vm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ do
fi

echo "==> Create VM"
lxc init ubuntu-daily:22.04 v1 --vm -s "${poolName}"
lxc init ubuntu-daily:22.04 v2 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v1 --vm -s "${poolName}"
lxc init "${TEST_IMG:-ubuntu-daily:22.04}" v2 --vm -s "${poolName}"

echo "==> Create custom block volume and attach it to VM"
lxc storage volume create "${poolName}" vol1 --type=block size=10MB
Expand Down
2 changes: 1 addition & 1 deletion tests/vm-nesting
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lxc project switch default
lxc storage create default zfs size=30GiB
lxc network create lxdbr0

instanceImage="ubuntu-daily:22.04"
instanceImage=""${TEST_IMG:-ubuntu-daily:22.04}""

Check warning

Code scanning / shellcheck

The surrounding quotes actually unquote this. Remove or escape them. Warning test

The surrounding quotes actually unquote this. Remove or escape them.

function parallel() {
seq "$1" | xargs -P "$1" -I "{}" "${@:2}"
Expand Down

0 comments on commit 672fe5b

Please sign in to comment.