Skip to content

Commit

Permalink
Merge pull request #284 from masnax/fix-test
Browse files Browse the repository at this point in the history
Fix DNS nameserver env var in tests
  • Loading branch information
tomponline authored Apr 18, 2024
2 parents 9a50ff6 + c4f7ac8 commit 217f5ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions microcloud/test/includes/microcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ unset_interactive_vars() {
unset LOOKUP_IFACE LIMIT_SUBNET SKIP_SERVICE EXPECT_PEERS \
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 CUSTOM_DNS_ADDRESSES IPV6_SUBNET
SETUP_OVN 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`
Expand All @@ -29,7 +29,7 @@ microcloud_interactive() {
IPV4_SUBNET=${IPV4_SUBNET:-} # OVN ipv4 gateway subnet.
IPV4_START=${IPV4_START:-} # OVN ipv4 range start.
IPV4_END=${IPV4_END:-} # OVN ipv4 range end.
CUSTOM_DNS_ADDRESSES=${CUSTOM_DNS_ADDRESSES:-} # OVN custom DNS addresses.
DNS_ADDRESSES=${DNS_ADDRESSES:-} # OVN custom DNS addresses.
IPV6_SUBNET=${IPV6_SUBNET:-} # OVN ipv6 range.

setup=$(cat << EOF
Expand Down Expand Up @@ -88,7 +88,7 @@ ${IPV4_SUBNET} # setup ipv4/ipv6 gateway
${IPV4_START}
${IPV4_END}
${IPV6_SUBNET}
${CUSTOM_DNS_ADDRESSES}
${DNS_ADDRESSES}
EOF
)
fi
Expand Down Expand Up @@ -275,7 +275,7 @@ validate_system_lxd_ovn() {

# Check that the created UPLINK network has the right DNS servers.
if [ -n "${dns_namesersers}" ] ; then
dns_addresses=$(lxc exec "${name}" -- sh -c "lxc network get UPLINK dns.nameservers")
dns_addresses=$(lxc exec "local:${name}" -- sh -c "lxc network get UPLINK dns.nameservers")
if [ "${dns_addresses}" != "${dns_namesersers}" ] ; then
echo "ERROR: UPLINK network has wrong DNS server addresses: ${dns_addresses}"
return 1
Expand Down
4 changes: 2 additions & 2 deletions microcloud/test/suites/add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ test_add_interactive() {
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" # comma-separated list of custom DNS addresses to be set for the OVN uplink.
export IPV6_SUBNET="fd42:1:1234:1234::1/64"
export DNS_ADDRESSES="10.1.123.1,fd42:1:1234:1234::1"
microcloud_interactive | lxc exec micro01 -- sh -c "microcloud init > out"
lxc exec micro01 -- tail -1 out | grep "MicroCloud is ready" -q

Expand All @@ -149,7 +149,7 @@ test_add_interactive() {
lxc exec micro01 -- tail -1 out | grep "MicroCloud is ready" -q

for m in micro01 micro02 micro03 micro04 ; do
validate_system_lxd "${m}" 4 disk1 1 1 enp6s0 10.1.123.1/24 10.1.123.100-10.1.123.254 fd42:1:1234:1234::1/64
validate_system_lxd "${m}" 4 disk1 1 1 enp6s0 10.1.123.1/24 10.1.123.100-10.1.123.254 fd42:1:1234:1234::1/64 10.1.123.1,fd42:1:1234:1234::1
validate_system_microceph "${m}" 1 disk2
validate_system_microovn "${m}"
done
Expand Down
8 changes: 5 additions & 3 deletions microcloud/test/suites/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ test_interactive() {
export IPV4_START="10.1.123.100"
export IPV4_END="10.1.123.254"
export IPV6_SUBNET="fd42:1:1234:1234::1/64"
export DNS_ADDRESSES="10.1.123.1,8.8.8.8"
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 0 0 "${OVN_FILTER}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}"
validate_system_lxd "${m}" 3 disk1 0 0 "${OVN_FILTER}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}" "${DNS_ADDRESSES}"
validate_system_microovn "${m}"
done

Expand All @@ -98,7 +99,7 @@ test_interactive() {

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_lxd "${m}" 3 disk1 3 1 "${OVN_FILTER}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}" "${DNS_ADDRESSES}"
validate_system_microceph "${m}" 1 disk2
validate_system_microovn "${m}"
done
Expand Down Expand Up @@ -354,6 +355,7 @@ test_case() {
IPV4_START="10.1.123.100"
IPV4_END="10.1.123.254"
IPV6_SUBNET="fd42:1:1234:1234::1/64"
DNS_ADDRESSES="10.1.123.1,8.8.8.8"

expected_ovn_iface="enp6s0"
else
Expand All @@ -367,7 +369,7 @@ test_case() {
name="$(printf "micro%02d" "${i}")"

if [ -n "${expected_ovn_iface}" ]; then
validate_system_lxd "${name}" "${num_systems}" "${expected_zfs_disk}" "${expected_ceph_disks}" "${expected_cephfs}" "${expected_ovn_iface}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}"
validate_system_lxd "${name}" "${num_systems}" "${expected_zfs_disk}" "${expected_ceph_disks}" "${expected_cephfs}" "${expected_ovn_iface}" "${IPV4_SUBNET}" "${IPV4_START}"-"${IPV4_END}" "${IPV6_SUBNET}" "${DNS_ADDRESSES}"
else
validate_system_lxd "${name}" "${num_systems}" "${expected_zfs_disk}" "${expected_ceph_disks}" "${expected_cephfs}" "${expected_ovn_iface}"
fi
Expand Down

0 comments on commit 217f5ae

Please sign in to comment.