Skip to content

Commit

Permalink
test/suites: Update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Jul 24, 2024
1 parent afa989d commit eb80dd6
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/includes/microcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# unset_interactive_vars: Unsets all variables related to the test console.
unset_interactive_vars() {
unset LOOKUP_IFACE LIMIT_SUBNET SKIP_SERVICE EXPECT_PEERS REUSE_EXISTING REUSE_EXISTING_COUNT \
unset SKIP_LOOKUP 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 CEPH_ENCRYPT 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
Expand All @@ -13,6 +13,7 @@ unset_interactive_vars() {
# The lines that are output are based on the values passed to the listed environment variables.
# Any unset variables will be omitted.
microcloud_interactive() {
SKIP_LOOKUP=${SKIP_LOOKUP:-} # whether or not to skip the whole lookup block in the interactive command list.
LOOKUP_IFACE=${LOOKUP_IFACE:-} # filter string for the lookup interface table.
LIMIT_SUBNET=${LIMIT_SUBNET:-} # (yes/no) input for limiting lookup of systems to the above subnet.
SKIP_SERVICE=${SKIP_SERVICE:-} # (yes/no) input to skip any missing services. Should be unset if all services are installed.
Expand Down Expand Up @@ -40,7 +41,9 @@ microcloud_interactive() {
DNS_ADDRESSES=${DNS_ADDRESSES:-} # OVN custom DNS addresses.
IPV6_SUBNET=${IPV6_SUBNET:-} # OVN ipv6 range.

setup="
setup=""
if ! [ "${SKIP_LOOKUP}" = 1 ]; then
setup="
${LOOKUP_IFACE} # filter the lookup interface
$([ -n "${LOOKUP_IFACE}" ] && printf "select") # select the interface
$([ -n "${LOOKUP_IFACE}" ] && printf -- "---")
Expand All @@ -51,6 +54,7 @@ select-all # select all the sys
---
$(true) # workaround for set -e
"
fi

if [ -n "${REUSE_EXISTING}" ]; then
for i in $(seq 1 "${REUSE_EXISTING_COUNT}") ; do
Expand Down Expand Up @@ -1237,3 +1241,18 @@ ip_config_to_netaddr () {

echo "${net_addr}$(ip_prefix_by_netmask "${mask}")"
}

set_cluster_subnet() {
num_systems="${1}"
iface="${2}"
prefix="${3}"

shift 3

for n in $(seq 2 $((num_systems + 1))); do
cluster_ip="${prefix}.${n}/24"
name="$(printf "micro%02d" $((n-1)))"
lxc exec "${name}" -- ip addr flush "${iface}"
lxc exec "${name}" -- ip addr add "${cluster_ip}" dev "${iface}"
done
}
112 changes: 112 additions & 0 deletions test/suites/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1173,3 +1173,115 @@ EOF

services_validator
}

test_add_services() {
unset_interactive_vars
# Set the default config for interactive setup.

ceph_cluster_subnet_prefix="10.0.1"
ceph_cluster_subnet_iface="enp7s0"
export LOOKUP_IFACE="enp5s0"
export LIMIT_SUBNET="yes"
export EXPECT_PEERS=2
export SETUP_ZFS="yes"
export ZFS_FILTER="lxd_disk1"
export ZFS_WIPE="yes"
export SETUP_CEPH="yes"
export SETUP_CEPHFS="yes"
export CEPH_FILTER="lxd_disk2"
export CEPH_WIPE="yes"
export SETUP_OVN="yes"
export OVN_FILTER="enp6s0"
export IPV4_SUBNET="10.1.123.1/24"
export IPV4_START="10.1.123.100"
export IPV4_END="10.1.123.254"
export DNS_ADDRESSES="10.1.123.1,8.8.8.8"
export IPV6_SUBNET="fd42:1:1234:1234::1/64"
export CEPH_CLUSTER_NETWORK="${ceph_cluster_subnet_prefix}.0/24"

reset_systems 3 3 3
set_cluster_subnet 3 "${ceph_cluster_subnet_iface}" "${ceph_cluster_subnet_prefix}"
echo Add MicroCeph to MicroCloud that was set up without it, and setup remote storage
lxc exec micro01 -- snap disable microceph
unset SETUP_CEPH
export SKIP_SERVICE="yes"
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
lxc exec micro01 -- snap enable microceph
export SETUP_CEPH="yes"
export SKIP_LOOKUP=1
unset SETUP_ZFS
unset SETUP_OVN
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud service add > out"
services_validator

reset_systems 3 3 3
set_cluster_subnet 3 "${ceph_cluster_subnet_iface}" "${ceph_cluster_subnet_prefix}"

echo Add MicroOVN to MicroCloud that was set up without it, and setup ovn network
lxc exec micro01 -- snap disable microovn
export SETUP_ZFS="yes"
unset SKIP_LOOKUP
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
lxc exec micro01 -- snap enable microovn
export SETUP_OVN="yes"
export SKIP_LOOKUP=1
unset SETUP_ZFS
unset SETUP_CEPH
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud service add > out"
services_validator

reset_systems 3 3 3
set_cluster_subnet 3 "${ceph_cluster_subnet_iface}" "${ceph_cluster_subnet_prefix}"

cho Add both MicroOVN and MicroCeph to a MicroCloud that was set up without it
lxc exec micro01 -- snap disable microovn
lxc exec micro01 -- snap disable microceph
export SETUP_ZFS="yes"
unset SKIP_LOOKUP
unset SETUP_OVN
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
lxc exec micro01 -- snap enable microovn
lxc exec micro01 -- snap enable microceph
export SETUP_OVN="yes"
export SETUP_CEPH="yes"
export SKIP_LOOKUP=1
unset SETUP_ZFS
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud service add > out"
services_validator

reset_systems 3 3 3
set_cluster_subnet 3 "${ceph_cluster_subnet_iface}" "${ceph_cluster_subnet_prefix}"

echo Reuse a MicroCeph that was set up on one node of the MicroCloud
lxc exec micro01 -- snap disable microceph
lxc exec micro02 -- microceph cluster bootstrap
export SETUP_ZFS="yes"
unset SETUP_CEPH
unset SKIP_LOOKUP
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
lxc exec micro01 -- snap enable microceph
export REUSE_EXISTING_COUNT=1
export REUSE_EXISTING="add"
export SETUP_CEPH="yes"
export SKIP_LOOKUP=1
unset SETUP_ZFS
unset SETUP_OVN
unset CEPH_CLUSTER_NETWORK
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud service add > out"
services_validator

reset_systems 3 3 3
set_cluster_subnet 3 "${ceph_cluster_subnet_iface}" "${ceph_cluster_subnet_prefix}"

echo Fail to add any services if they have been set up
export SETUP_ZFS="yes"
export SETUP_OVN="yes"
unset REUSE_EXISTING
unset REUSE_EXISTING_COUNT
unset SKIP_LOOKUP
unset SKIP_SERVICE
export CEPH_CLUSTER_NETWORK="${ceph_cluster_subnet_prefix}.0/24"
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
export SKIP_LOOKUP=1
! microcloud_interactive | lxc exec micro01 -- sh -c "microcloud service add > out" || true
}

0 comments on commit eb80dd6

Please sign in to comment.