From 1fdf2d6f3ce726f8c8d059a25cf9a30e2448ae5e Mon Sep 17 00:00:00 2001 From: hamistao Date: Tue, 15 Oct 2024 02:24:40 -0300 Subject: [PATCH] test: Test showing instances from different projects Signed-off-by: hamistao --- test/suites/network.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/suites/network.sh b/test/suites/network.sh index c99367dafff5..6967e948b484 100644 --- a/test/suites/network.sh +++ b/test/suites/network.sh @@ -91,8 +91,18 @@ test_network() { grep -q "${v6_addr}.*nettest" "${LXD_DIR}/networks/lxdt$$/dnsmasq.hosts/nettest.eth0" lxc start nettest - lxc network list-leases lxdt$$ | grep STATIC | grep -q "${v4_addr}" - lxc network list-leases lxdt$$ | grep STATIC | grep -q "${v6_addr}" + # Create new project with an instance on lxdbr0 for the next tests. + lxc project create foo -c features.networks=false -c features.images=false -c features.profiles=false + lxc launch testimage outsider -n lxdt$$ --project foo + v4_addr_foo="$(lxc network get lxdt$$ ipv4.address | cut -d/ -f1)1" + v6_addr_foo="$(lxc network get lxdt$$ ipv6.address | cut -d/ -f1)01" + lxc config device set outsider eth0 ipv4.address "${v4_addr_foo}" --project foo + lxc config device set outsider eth0 ipv6.address "${v6_addr_foo}" --project foo + + lxc network list-leases lxdt$$ --format csv | grep STATIC | grep -q "nettest,${v4_addr}" + lxc network list-leases lxdt$$ --format csv | grep STATIC | grep -q "nettest,${v6_addr}" + lxc network list-leases lxdt$$ --format csv --project foo | grep STATIC | grep -q "outsider,${v4_addr_foo}" + lxc network list-leases lxdt$$ --format csv --project foo | grep STATIC | grep -q "outsider,${v6_addr_foo}" # Request DHCPv6 lease (if udhcpc6 is in busybox image). busyboxUdhcpc6=1 @@ -114,7 +124,11 @@ test_network() { lxc network list-allocations localhost: | grep -e "${net_ipv4}" -e "${net_ipv6}" lxc network list-allocations localhost: | grep -e "/1.0/networks/lxdt$$" -e "/1.0/instances/nettest" lxc network list-allocations localhost: | grep -e "${v4_addr}" -e "${v6_addr}" + lxc network list-allocations --format csv | grep -q "/1.0/instances/outsider?project=foo,${v4_addr_foo}" + lxc network list-allocations --format csv | grep -q "/1.0/instances/outsider?project=foo,${v6_addr_foo}" + lxc delete -f outsider --project foo + lxc project delete foo lxc delete nettest -f lxc network delete lxdt$$ }