Skip to content

Commit

Permalink
e2e: add test for several control plane versions
Browse files Browse the repository at this point in the history
Signed-off-by: Iceber Gu <[email protected]>
  • Loading branch information
Iceber committed Jun 18, 2024
1 parent 1b58fbd commit c6cd50f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
6 changes: 4 additions & 2 deletions test/environments/multiple.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set -o pipefail
# Create an environment that manages an multiple clusters of different versions

cases="${1}"
control_plane_version="${2}"
control_plane_name="control-${control_plane_version//./-}"

source "$(dirname "${BASH_SOURCE[0]}")/../helper.sh"

Expand All @@ -33,11 +35,11 @@ function cleanup() {
for release in "${releases[@]}"; do
delete_data_plane "data-${release//./-}" >/dev/null 2>&1
done
delete_control_plane control-v1-30 >/dev/null 2>&1
delete_control_plane ${control_plane_name} >/dev/null 2>&1
}
trap cleanup EXIT

create_control_plane control-v1-30 v1.30.0 || {
create_control_plane ${control_plane_name} ${control_plane_version} || {
echo "Failed to create control plane"
exit 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ set -o pipefail
# Create an environment that manages a single cluster

cases="${1}"
version="${2}"
control_plane_name="control-${version//./-}"
data_plane_name="data-${version//./-}"

source "$(dirname "${BASH_SOURCE[0]}")/../helper.sh"

function cleanup() {
"${ROOT}/hack/clean-clusterconfigs.sh" >/dev/null 2>&1
delete_data_plane data-v1-30 >/dev/null 2>&1
delete_control_plane control-v1-30 >/dev/null 2>&1
delete_data_plane ${data_plane_name} >/dev/null 2>&1
delete_control_plane ${control_plane_name} >/dev/null 2>&1
}
trap cleanup EXIT

create_control_plane control-v1-30 v1.30.0 || {
create_control_plane ${control_plane_name} ${version} || {
echo "Failed to create control plane"
exit 1
}
create_data_plane data-v1-30 v1.30.0 || {
create_data_plane ${data_plane_name} ${version} || {
echo "Failed to create data plane"
exit 1
}
Expand Down
44 changes: 36 additions & 8 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ TEST_ROOT="$(dirname "${BASH_SOURCE[0]}")"

source "$(dirname "${BASH_SOURCE[0]}")/helper.sh"

single_versions=(
v1.30.0
v1.23.17
v1.18.20
v1.14.10
)

multiple_versions=(
v1.30.0
v1.14.10
)

function main() {
local name
local env_name
Expand All @@ -17,18 +29,34 @@ function main() {
build_image
echo "::endgroup::"

for env in "${TEST_ROOT}"/environments/*.env.sh; do
[[ -e "${env}" ]] || continue
env_name="${env##*/}"
env_name="${env_name%.env.sh}"
for version in "${single_versions[@]}"; do
for file in "${TEST_ROOT}"/cases/*.test.sh; do
[[ -e "${file}" ]] || continue
name="${file##*/}"
name="${name%.test.sh}"

echo "::group::Running [single cluster] test ${name} on ${version}"
if ! "${TEST_ROOT}/environments/single.env.sh" "${file}" "${version}"; then
failed+=("'${name} on ${version}'")
mv "${TEST_ROOT}/logs" "${TEST_ROOT}/logs-${name}-single-cluster-${version}"
else
# Clean up logs
rm -rf "${TEST_ROOT}/logs"
fi
echo "::endgroup::"
done
done

for version in "${multi_versions[@]}"; do
for file in "${TEST_ROOT}"/cases/*.test.sh; do
[[ -e "${file}" ]] || continue
name="${file##*/}"
name="${name%.test.sh}"
echo "::group::Running test ${name} on ${env_name}"
if ! "${env}" "${file}"; then
failed+=("'${name} on ${env_name}'")
mv "${TEST_ROOT}/logs" "${TEST_ROOT}/logs-${name}-${env_name}"

echo "::group::Running [multi clusters] test ${name} on ${version}"
if ! "${TEST_ROOT}/environments/multi.env.sh" "${file}" "${version}"; then
failed+=("'${name} on ${version}'")
mv "${TEST_ROOT}/logs" "${TEST_ROOT}/logs-${name}-multi-clusters-${version}"
else
# Clean up logs
rm -rf "${TEST_ROOT}/logs"
Expand Down

0 comments on commit c6cd50f

Please sign in to comment.