-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Check that creating / joining a MicroOVN cluster works and tha…
…t the cluster state is healthy Signed-off-by: Gabriel Mougard <[email protected]>
- Loading branch information
1 parent
ef09fdb
commit 543bca5
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This is a bash shell fragment -*- bash -*- | ||
|
||
load "test_helper/setup_teardown/$(basename "${BATS_TEST_FILENAME//.bats/.bash}")" | ||
|
||
setup() { | ||
load test_helper/common.bash | ||
load test_helper/lxd.bash | ||
load test_helper/microovn.bash | ||
load ../.bats/bats-support/load.bash | ||
load ../.bats/bats-assert/load.bash | ||
|
||
# Ensure TEST_CONTAINERS and EAST_WEST_ADDRS are populated, otherwise the tests below will | ||
# provide false positive results. | ||
assert [ -n "$TEST_CONTAINERS" ] | ||
assert [ -n "$EAST_WEST_ADDRS" ] | ||
} | ||
|
||
@test "Check that custom IP encapsulation works" { | ||
local container_services | ||
|
||
for container in $TEST_CONTAINERS; do | ||
container_services=$(microovn_get_cluster_services "$container") | ||
if [[ "$container_services" != *"chassis"* ]]; then | ||
echo "Skip $container, no chassis services" >&3 | ||
continue | ||
fi | ||
|
||
run lxc_exec \ | ||
"$container" \ | ||
"microovn.ovs-vsctl get Open_vSwitch . external_ids:ovn-encap-ip" | ||
assert_output -p "${EAST_WEST_ADDRS[$container]}" | ||
done | ||
|
||
run bats -F junit test_helper/bats/cluster.bats | ||
|
||
echo "# $output" >&3 | ||
echo "#" >&3 | ||
|
||
[ "$status" -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
init_cluster_custom_encap.bats |
45 changes: 45 additions & 0 deletions
45
tests/test_helper/setup_teardown/init_cluster_custom_encap.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
setup_file() { | ||
load test_helper/common.bash | ||
load test_helper/lxd.bash | ||
load test_helper/microovn.bash | ||
load ../.bats/bats-support/load.bash | ||
load ../.bats/bats-assert/load.bash | ||
|
||
|
||
TEST_CONTAINERS=$(container_names "$BATS_TEST_FILENAME" 3) | ||
export TEST_CONTAINERS | ||
launch_containers jammy $TEST_CONTAINERS | ||
wait_containers_ready $TEST_CONTAINERS | ||
|
||
# Create a dedicated bridge for the east-west traffic | ||
network_output=$(create_lxd_network "br-east-west") | ||
IFS='|' read -r ipv4_subnet ipv6_subnet <<< "$network_output" | ||
|
||
# Give each container an IP address from the subnet | ||
east_west_ips_to_containers=$(connect_containers_to_network_ipv4 "$TEST_CONTAINERS" "br-east-west" $ipv4_subnet) | ||
IFS=',' read -ra east_west_addrs <<< "$east_west_ips_to_containers" | ||
EAST_WEST_ADDRS="${east_west_addrs[*]}" | ||
export EAST_WEST_ADDRS | ||
|
||
install_microovn "$MICROOVN_SNAP_PATH" $TEST_CONTAINERS | ||
local leader | ||
for container in $TEST_CONTAINERS; do | ||
local addr | ||
addr=$(container_get_default_ip "$container" \ | ||
"$(test_is_ipv6_test && echo inet6 || echo inet)") | ||
assert [ -n "$addr" ] | ||
if [ -z "$leader" ]; then | ||
microovn_init_create_cluster "$container" "$addr" "${east_west_addrs[$container]}" | ||
leader="$container" | ||
else | ||
local token | ||
token=$(microovn_cluster_get_join_token "$leader" "$container") | ||
microovn_init_join_cluster "$container" "$addr" "$token" "${east_west_addrs[$container]}" | ||
fi | ||
done | ||
} | ||
|
||
teardown_file() { | ||
delete_containers $TEST_CONTAINERS | ||
delete_lxd_network "br-east-west" | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/test_helper/setup_teardown/init_cluster_custom_encap_ipv6.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
setup_file() { | ||
load test_helper/common.bash | ||
load test_helper/lxd.bash | ||
load test_helper/microovn.bash | ||
load ../.bats/bats-support/load.bash | ||
load ../.bats/bats-assert/load.bash | ||
|
||
|
||
TEST_CONTAINERS=$(container_names "$BATS_TEST_FILENAME" 3) | ||
export TEST_CONTAINERS | ||
launch_containers jammy $TEST_CONTAINERS | ||
wait_containers_ready $TEST_CONTAINERS | ||
|
||
# Create a dedicated bridge for the east-west traffic | ||
network_output=$(create_lxd_network "br-east-west") | ||
IFS='|' read -r ipv4_subnet ipv6_subnet <<< "$network_output" | ||
|
||
# Give each container an IP address from the subnet | ||
east_west_ips_to_containers=$(connect_containers_to_network_ipv6 "$TEST_CONTAINERS" "br-east-west") | ||
IFS=',' read -ra east_west_addrs <<< "$east_west_ips_to_containers" | ||
|
||
install_microovn "$MICROOVN_SNAP_PATH" $TEST_CONTAINERS | ||
local leader | ||
for container in $TEST_CONTAINERS; do | ||
local addr | ||
addr=$(container_get_default_ip "$container" \ | ||
"$(test_is_ipv6_test && echo inet6 || echo inet)") | ||
assert [ -n "$addr" ] | ||
if [ -z "$leader" ]; then | ||
microovn_init_create_cluster "$container" "$addr" "${east_west_addrs[$container]}" | ||
leader="$container" | ||
else | ||
local token | ||
token=$(microovn_cluster_get_join_token "$leader" "$container") | ||
microovn_init_join_cluster "$container" "$addr" "$token" "${east_west_addrs[$container]}" | ||
fi | ||
done | ||
} | ||
|
||
teardown_file() { | ||
delete_containers $TEST_CONTAINERS | ||
delete_lxd_network "br-east-west" | ||
} |