From 51d2c42c9a5fabf59e78d1a262ef6137d79fc84c Mon Sep 17 00:00:00 2001 From: Mark Bolton Date: Tue, 8 Oct 2024 22:30:02 -0700 Subject: [PATCH] tests: Add test for OVN uplink attached to VLAN Signed-off-by: Mark Bolton --- tests/network-ovn | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/network-ovn b/tests/network-ovn index 5877cc4fe..5e61baf01 100755 --- a/tests/network-ovn +++ b/tests/network-ovn @@ -2127,6 +2127,57 @@ ovn_leases_tests() { lxc network delete lxdbr0 } +ovn_vlan_uplink_tests() { + echo "==> vlan uplink" + + sudo ovs-vsctl set open_vswitch . \ + external_ids:ovn-remote=unix:/var/run/ovn/ovnsb_db.sock \ + external_ids:ovn-encap-type=geneve \ + external_ids:ovn-encap-ip=127.0.0.1 + + lxc network create lxdbr0 \ + ipv4.address=10.10.10.1/24 ipv4.nat=true \ + ipv4.dhcp.ranges=10.10.10.2-10.10.10.199 \ + ipv6.address=fd42:4242:4242:1010::1/64 ipv6.nat=true \ + ipv6.ovn.ranges=fd42:4242:4242:1010::200-fd42:4242:4242:1010::254 + + echo "==> Create physical UPLINK network with VLAN config set to 10" + lxc network create UPLINK --type=physical parent=lxdbr0 \ + ipv4.ovn.ranges=10.10.10.200-10.10.10.254 \ + ipv4.gateway=10.10.10.1/24 \ + vlan=10 + + echo "==> Create OVN network" + lxc network create ovn-virtual-network --type=ovn network=UPLINK + sleep 2 + + echo "==> Set up containers" + lxc launch "${IMAGE}" c1-ovn -n ovn-virtual-network + lxc launch "${IMAGE}" c1-lxdbr0 -n lxdbr0 + sleep 2 + + # Configure lxdbr0 to handle tagged traffic for VLAN 10 and retain VLAN tag + bridge vlan add dev lxdbr0 vid 10 tagged self + + lxc config device set c1-lxdbr0 eth0 vlan=10 + lxc exec c1-lxdbr0 -- ip addr add 10.10.10.100/24 dev eth0 + lxc exec c1-lxdbr0 -- ip link set dev eth0 up + lxc exec c1-lxdbr0 -- ip route add default via 10.10.10.1 + + echo "==> Ensure OVN network can reach containers on the configured VLAN" + lxc exec c1-ovn -- ping -nc1 -4 -w5 10.10.10.100 + + echo "==> Ensure containers on VLAN can reach OVN network" + ovn_address=$(lxc network get ovn-virtual-network volatile.network.ipv4.address) + lxc exec c1-lxdbr0 -- ping -nc1 -4 -w5 "${ovn_address}" + + echo "==> Cleanup" + lxc delete -f c1-lxdbr0 c1-ovn + lxc network delete ovn-virtual-network + lxc network delete UPLINK + lxc network delete lxdbr0 +} + # Allow for running a specific set of tests. if [ "$#" -gt 0 ]; then TEST_CURRENT="ovn_${1}_tests" @@ -2154,6 +2205,7 @@ else echo "Skipping ovn_l3only_tests, not supported" fi ovn_leases_tests + ovn_vlan_uplink_tests fi lxc storage delete default