diff --git a/test/includes/microcloud.sh b/test/includes/microcloud.sh index 983da1547..62de17da2 100644 --- a/test/includes/microcloud.sh +++ b/test/includes/microcloud.sh @@ -5,7 +5,7 @@ unset_interactive_vars() { unset LOOKUP_IFACE LIMIT_SUBNET SKIP_SERVICE EXPECT_PEERS REUSE_EXISTING REUSE_EXISTING_COUNT \ SETUP_ZFS ZFS_FILTER ZFS_WIPE \ SETUP_CEPH CEPH_WARNING CEPH_FILTER CEPH_WIPE SETUP_CEPHFS CEPH_CLUSTER_NETWORK IGNORE_CEPH_NETWORKING \ - PROCEED_WITH_NO_OVERLAY_NETWORKING SETUP_OVN OVN_WARNING OVN_FILTER IPV4_SUBNET IPV4_START IPV4_END DNS_ADDRESSES IPV6_SUBNET + PROCEED_WITH_NO_OVERLAY_NETWORKING SETUP_OVN OVN_UNDERLAY_NETWORK OVN_UNDERLAY_FILTER OVN_WARNING OVN_FILTER IPV4_SUBNET IPV4_START IPV4_END DNS_ADDRESSES IPV6_SUBNET } # microcloud_interactive: outputs text that can be passed to `TEST_CONSOLE=1 microcloud init` @@ -37,6 +37,8 @@ microcloud_interactive() { IPV4_START=${IPV4_START:-} # OVN ipv4 range start. IPV4_END=${IPV4_END:-} # OVN ipv4 range end. DNS_ADDRESSES=${DNS_ADDRESSES:-} # OVN custom DNS addresses. + OVN_UNDERLAY_NETWORK=${OVN_UNDERLAY_NETWORK:-} # (yes/no) set up a custom OVN underlay network. + OVN_UNDERLAY_FILTER=${OVN_UNDERLAY_FILTER:-} # filter string for OVN underlay interfaces. IPV6_SUBNET=${IPV6_SUBNET:-} # OVN ipv6 range. setup=" @@ -106,6 +108,18 @@ $(true) # workaround for set -e fi if [ -n "${SETUP_OVN}" ]; then + setup_ovn_underlay="" + if [ "${OVN_UNDERLAY_NETWORK}" = "yes" ]; then + setup_ovn_underlay="${OVN_UNDERLAY_NETWORK} +$(printf "wait 300ms") +${OVN_UNDERLAY_FILTER} +$(printf "select-all") +$(printf -- "---") +" + else + setup_ovn_underlay="no" + fi + setup="${setup} ${SETUP_OVN} # agree to setup OVN ${OVN_WARNING} # continue with some peers missing an interface? (yes/no) @@ -118,6 +132,7 @@ ${IPV4_START} ${IPV4_END} ${IPV6_SUBNET} ${DNS_ADDRESSES} +${setup_ovn_underlay} # setup OVN underlay network $(true) # workaround for set -e " fi @@ -226,11 +241,28 @@ validate_system_microceph() { # validate_system_microovn: Ensures the node with the given name has correctly set up MicroOVN with the given resources. validate_system_microovn() { name=${1} + shift 1 echo "==> ${name} Validating MicroOVN" lxc remote switch local lxc exec "${name}" -- microovn cluster list | grep -q "${name}" + + ovn_underlay_subnet_prefix="" + if echo "${1}" | grep -Pq '^([0-9]{1,3}\.){2}[0-9]{1,3}$'; then + ovn_underlay_subnet_prefix="${1}" + shift 1 + fi + + # Instances are named micro01, micro02, etc. + # We need to extract the instance number to check the OVN Geneve tunnel IP. + instance_idx=$(echo "${name}" | grep -oE '[0-9]+$') + underlay_ip_idx=$((instance_idx + 1)) + if [ -n "${ovn_underlay_subnet_prefix}" ]; then + lxc exec "${name}" -- sh -ceu " + microovn.ovn-sbctl --columns=ip,type find Encap type=geneve | grep -q ${ovn_underlay_subnet_prefix}.${underlay_ip_idx} + " > /dev/null + fi } # validate_system_lxd_zfs: Ensures the node with the given name has the given disk set up for ZFS storage. diff --git a/test/suites/basic.sh b/test/suites/basic.sh index 77f0e2d1f..e61d580dc 100644 --- a/test/suites/basic.sh +++ b/test/suites/basic.sh @@ -228,6 +228,29 @@ test_interactive() { validate_system_microceph "${m}" 1 "${CEPH_CLUSTER_NETWORK}" disk2 validate_system_microovn "${m}" done + + reset_systems 3 3 2 + + ovn_underlay_subnet_prefix="10.0.1" + ovn_underlay_subnet_iface="enp7s0" + + for n in $(seq 2 4); do + ovn_underlay_ip="${ovn_underlay_subnet_prefix}.${n}/24" + lxc exec "micro0$((n-1))" -- ip addr add "${ovn_underlay_ip}" dev "${ovn_underlay_subnet_iface}" + done + + echo "Creating a MicroCloud with ZFS, OVN management network and OVN underlay network" + unset SETUP_CEPH + export OVN_UNDERLAY_NETWORK="yes" + export OVN_UNDERLAY_FILTER="${ovn_underlay_subnet_prefix}" + microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out" + + lxc exec micro01 -- tail -1 out | grep "MicroCloud is ready" -q + for m in micro01 micro02 micro03 ; do + validate_system_lxd "${m}" 3 disk1 3 1 "${OVN_FILTER}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}" + validate_system_microceph "${m}" 1 disk2 + validate_system_microovn "${m}" "${ovn_underlay_subnet_prefix}" + done } test_instances_config() {