From a4ac008aaf52a7ada06f67a30c3786fec53ea1b9 Mon Sep 17 00:00:00 2001 From: Max Asnaashari Date: Wed, 31 Jan 2024 07:20:43 +0000 Subject: [PATCH] microcloud/test/suites: Add tests for adding services Signed-off-by: Max Asnaashari --- microcloud/test/includes/microcloud.sh | 7 +- microcloud/test/main.sh | 1 + microcloud/test/suites/basic.sh | 98 ++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) diff --git a/microcloud/test/includes/microcloud.sh b/microcloud/test/includes/microcloud.sh index f960933e8..773bb8dbf 100644 --- a/microcloud/test/includes/microcloud.sh +++ b/microcloud/test/includes/microcloud.sh @@ -3,7 +3,8 @@ 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 \ - SETUP_OVN OVN_WARNING OVN_FILTER IPV4_SUBNET IPV4_START IPV4_END DNS_ADDRESSES IPV6_SUBNET + SETUP_OVN OVN_WARNING OVN_FILTER IPV4_SUBNET IPV4_START IPV4_END DNS_ADDRESSES IPV6_SUBNET \ + SKIP_LOOKUP } # microcloud_interactive: outputs text that can be passed to `TEST_CONSOLE=1 microcloud init` @@ -11,6 +12,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. @@ -32,6 +34,8 @@ microcloud_interactive() { DNS_ADDRESSES=${DNS_ADDRESSES:-} # OVN custom DNS addresses. IPV6_SUBNET=${IPV6_SUBNET:-} # OVN ipv6 range. + setup="" + if ! [ "${SKIP_LOOKUP}" = 1 ]; then setup=$(cat << EOF ${LOOKUP_IFACE} # filter the lookup interface $([ -n "${LOOKUP_IFACE}" ] && printf "select") # select the interface @@ -43,6 +47,7 @@ select-all # select all the sys --- EOF ) + fi if [ -n "${REUSE_EXISTING}" ]; then for i in $(seq 1 "${REUSE_EXISTING_COUNT}") ; do diff --git a/microcloud/test/main.sh b/microcloud/test/main.sh index 739df24ec..128b88aef 100755 --- a/microcloud/test/main.sh +++ b/microcloud/test/main.sh @@ -142,6 +142,7 @@ run_basic_tests() { run_test test_interactive_combinations "interactive combinations" run_test test_auto "auto" run_test test_reuse_cluster "reuse_cluster" + run_test test_add_services "add services" } run_preseed_tests() { diff --git a/microcloud/test/suites/basic.sh b/microcloud/test/suites/basic.sh index d41ee5580..7a79d58fa 100644 --- a/microcloud/test/suites/basic.sh +++ b/microcloud/test/suites/basic.sh @@ -829,6 +829,7 @@ services_validator() { } test_reuse_cluster() { + unset_interactive_vars # Set the default config for interactive setup. export LOOKUP_IFACE="enp5s0" export LIMIT_SUBNET="yes" @@ -948,3 +949,100 @@ storage: lxc exec micro01 -- sh -c "cat /root/preseed.yaml | TEST_CONSOLE=0 microcloud init --preseed" services_validator } + +test_add_services() { + unset_interactive_vars + # Set the default config for interactive setup. + 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 CUSTOM_DNS_ADDRESSES="10.1.123.1,8.8.8.8" + export IPV6_SUBNET="fd42:1:1234:1234::1/64" + + reset_systems 3 3 3 + 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 + 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 + echo 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 + 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="reuse" + 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 + 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 + 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 +}