Skip to content

Commit

Permalink
tests: Add test for OVN uplink attached to VLAN
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Bolton <[email protected]>
  • Loading branch information
boltmark committed Oct 15, 2024
1 parent e49fb3b commit e93fec1
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/network-ovn
Original file line number Diff line number Diff line change
Expand Up @@ -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 -s default
lxc launch "${IMAGE}" c1-lxdbr0 -n lxdbr0 -s default
sleep 2

# Configure lxdbr0 to handle tagged traffic for VLAN 10 and retain the 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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e93fec1

Please sign in to comment.