Skip to content

Commit

Permalink
tests: integration tests for branching day tools
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-gemoli committed Jan 5, 2023
1 parent c297e6f commit ac02382
Show file tree
Hide file tree
Showing 20 changed files with 787 additions and 0 deletions.
117 changes: 117 additions & 0 deletions hack/lib/branchcuts/test-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
readonly src_test_files_relative_dir="data"
readonly want_test_files_relative_dir="want"
readonly test_config_relative_path="test_config"

function branchcuts::read_test_config() {
local -n _cfg=$1
local _test_config_path="${2}"
for key_value in $(cat "${_test_config_path}")
do
if [[ "${key_value}" =~ (.+?)=(.*) ]]
then
_cfg["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}"
fi
done
}
readonly -f branchcuts::read_test_config

function branchcuts::cleanup() {
local _testRootDir="${1}"
if test -d "${_testRootDir}"
then
os::log::info "deleting ${_testRootDir}"
rm --recursive --force "${_testRootDir}"
fi
}
readonly -f branchcuts::cleanup

function branchcuts::setup_dirs() {
local _release_repo_absolute_dir="${1}"
local _src_test_files_dir="${2}"

mkdir --parents "${_release_repo_absolute_dir}"
cp --recursive "${_src_test_files_dir}"/* "${_release_repo_absolute_dir}/"
}
readonly -f branchcuts::setup_dirs

function branchcuts::check_result() {
local _result_files_dir="${1}"
local _want_files_dir="${2}"
local _exit_status=0
for want_file in $(ls "${_want_files_dir}")
do
local want_file_path="${_want_files_dir}/${want_file}"
local want_file_filename=$(basename "${want_file_path}")
local want_file_in_result_dir="${_result_files_dir}/${want_file_filename}"
if test ! -f "${want_file_in_result_dir}"
then
os::log::warning "${want_file_in_result_dir} expected but not found"
_exit_status=1
continue
fi

os::integration::compare "${want_file_path}" "${want_file_in_result_dir}"
if test $? -ne 0
then
_exit_status=1
fi
done

return $_exit_status
}
readonly -f branchcuts::check_result

function branchcuts::run_tests_template() {
local run_cfg_manager_fn="${1}"
local _diffs=""
local _exit_status=0

for test_case in $(ls "${test_cases_dir}")
do
os::log::info "Test case: '${test_case}' - Starts"
local _src_test_files_dir="${test_cases_dir}/${test_case}/${src_test_files_relative_dir}"
local _want_test_files_dir="${test_cases_dir}/${test_case}/${want_test_files_relative_dir}"

# Read test config from file and set some vars
local _test_config_file_path="${test_cases_dir}/${test_case}/${test_config_relative_path}"
declare -A _test_config
branchcuts::read_test_config _test_config "${_test_config_file_path}"

# Set test dirs
local _test_root_dir=$(mktemp --tmpdir="${BASETMPDIR}" --directory --suffix "_${test_case}")
local _release_repo_absolute_dir="${_test_root_dir}/${release_repo_relative_dir}"

branchcuts::setup_dirs "${_release_repo_absolute_dir}" "${_src_test_files_dir}"

# Function 'run_config_manager' should be defined into the caller script
if test $(type -t "${run_cfg_manager_fn}") == "function"
then
# This is the same as running:
# "${run_cfg_manager_fn}" "${_test_root_dir}" "${_ocp_lifecycle_path}" _test_config
os::cmd::expect_success "${run_cfg_manager_fn} \"${_test_root_dir}\" _test_config"
else
os::log::error "function '${run_cfg_manager_fn}' is not defined"
exit 1
fi

_diffs=$(branchcuts::check_result "${_release_repo_absolute_dir}" "${_want_test_files_dir}")
if test $? -ne 0
then
os::log::info "${_diffs}"
_exit_status=1
os::log::error "Test case: '${test_case}' - FAILURE!"
else
os::log::info "Test case: '${test_case}' - SUCCESS"
fi
done

# Clean tests folder only if everything went well.
# Otherwise it reserve some time to inspect the failure.
if test $_exit_status -eq 0
then
branchcuts::cleanup "${_test_root_dir}"
fi

return $_exit_status
}
readonly -f branchcuts::run_tests_template
39 changes: 39 additions & 0 deletions test/integration/br-cuts-generated-release-jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

source "$(dirname "${BASH_SOURCE}")/../../hack/lib/init.sh"

readonly release_repo_relative_dir="ci-operator/config/openshift/release"
readonly test_cases_dir="${OS_ROOT}/test/integration/branchcuts/generated-release-gating-jobs"

function cleanup() {
os::test::junit::reconcile_output
os::cleanup::processes
}
trap "cleanup" EXIT

function branchcuts::generated_release_jobs::run_config_manager() {
local _release_repo_path="${1}"
local -n _cfg=$2

printf "%s\n%s %s\n%s %s\n%s %s\n\n" \
generated-release-gating-jobs \
--release-repo "${_release_repo_path}" \
--current-release "${_cfg['current_ocp_release']}" \
--interval "${_cfg['interval']}"

generated-release-gating-jobs \
--release-repo "${_release_repo_path}" \
--current-release "${_cfg['current_ocp_release']}" \
--interval "${_cfg['interval']}"
}
readonly -f branchcuts::generated_release_jobs::run_config_manager

function branchcuts::generated_release_jobs::run_tests() {
branchcuts::run_tests_template branchcuts::generated_release_jobs::run_config_manager
}
readonly -f branchcuts::generated_release_jobs::run_tests


os::test::junit::declare_suite_start "integration/branchcuts/generated-release-gating-jobs"
os::cmd::expect_success "branchcuts::generated_release_jobs::run_tests"
os::test::junit::declare_suite_end
37 changes: 37 additions & 0 deletions test/integration/br-cuts-release-controller-configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

source "$(dirname "${BASH_SOURCE}")/../../hack/lib/init.sh"

readonly release_repo_relative_dir="core-services/release-controller/_releases"
readonly test_cases_dir="${OS_ROOT}/test/integration/branchcuts/release-controller-configs"

function cleanup() {
os::test::junit::reconcile_output
os::cleanup::processes
}
trap "cleanup" EXIT

function branchcuts::release_controller_cfg::run_config_manager() {
local _release_repo_path="${1}"
local -n _cfg=$2

printf "%s\n%s %s\n%s %s\n\n" \
release-controller-config-manager \
--release-repo "${_release_repo_path}" \
--current-release "${_cfg['current_ocp_release']}"

release-controller-config-manager \
--release-repo "${_release_repo_path}" \
--current-release "${_cfg['current_ocp_release']}"
}
readonly -f branchcuts::release_controller_cfg::run_config_manager


function branchcuts::release_controller_cfg::run_tests() {
branchcuts::run_tests_template branchcuts::release_controller_cfg::run_config_manager
}
readonly -f branchcuts::release_controller_cfg::run_tests

os::test::junit::declare_suite_start "integration/branchcuts/release-controller-configs"
os::cmd::expect_success "branchcuts::release_controller_cfg::run_tests"
os::test::junit::declare_suite_end
38 changes: 38 additions & 0 deletions test/integration/br-cuts-rpm-mirroring-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

source "$(dirname "${BASH_SOURCE}")/../../hack/lib/init.sh"

readonly release_repo_relative_dir="core-services/release-controller/_repos"
readonly test_cases_dir="${OS_ROOT}/test/integration/branchcuts/rpm-deps-mirroring-services"

function cleanup() {
os::test::junit::reconcile_output
os::cleanup::processes
}
trap "cleanup" EXIT

function branchcuts::rpm_mirroring::run_config_manager() {
local _release_repo_path="${1}"
local -n _cfg=$2
local _current_release="${_cfg['current_ocp_release']}"

printf "%s\n%s %s\n%s %s\n%s %s\n\n" \
rpm-deps-mirroring-services \
--release-repo "${_release_repo_path}" \
--current-release "${_current_release}"

rpm-deps-mirroring-services \
--release-repo "${_release_repo_path}" \
--current-release "${_current_release}"
}
readonly -f branchcuts::rpm_mirroring::run_config_manager


function branchcuts::rpm_mirroring::run_tests() {
branchcuts::run_tests_template branchcuts::rpm_mirroring::run_config_manager
}
readonly -f branchcuts::rpm_mirroring::run_tests

os::test::junit::declare_suite_start "integration/branchcuts/rpm-deps-mirroring-services"
os::cmd::expect_success "branchcuts::rpm_mirroring::run_tests"
os::test::junit::declare_suite_end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
releases:
initial:
candidate:
product: ocp
relative: 1
stream: ci
version: "4.10"
latest:
candidate:
product: ocp
stream: ci
version: "4.10"
resources:
'*':
requests:
cpu: 100m
memory: 200Mi
tests:
- as: e2e-aws
interval: 24h
steps:
cluster_profile: aws-2
env:
BASE_DOMAIN: aws-2.ci.openshift.org
workflow: openshift-e2e-aws
- as: e2e-aws-techpreview
interval: 48h
steps:
cluster_profile: aws-2
env:
BASE_DOMAIN: aws-2.ci.openshift.org
workflow: openshift-e2e-aws-techpreview
zz_generated_metadata:
branch: master
org: openshift
repo: release
variant: ci-4.10
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
current_ocp_release=4.10
future_ocp_release=4.11
interval=168
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
releases:
initial:
candidate:
product: ocp
relative: 1
stream: ci
version: "4.11"
latest:
candidate:
product: ocp
stream: ci
version: "4.11"
resources:
'*':
requests:
cpu: 100m
memory: 200Mi
tests:
- as: e2e-aws
interval: 168h
steps:
cluster_profile: aws-2
env:
BASE_DOMAIN: aws-2.ci.openshift.org
workflow: openshift-e2e-aws
- as: e2e-aws-techpreview
interval: 168h
steps:
cluster_profile: aws-2
env:
BASE_DOMAIN: aws-2.ci.openshift.org
workflow: openshift-e2e-aws-techpreview
zz_generated_metadata:
branch: master
org: openshift
repo: release
variant: ci-4.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
releases:
initial:
prerelease:
product: ocp
version_bounds:
lower: 4.4.0-0
upper: 4.5.0-0
latest:
candidate:
product: ocp
stream: ci
version: "4.5"
resources:
'*':
requests:
cpu: 100m
memory: 200Mi
tests:
- as: e2e-aws-upgrade
interval: 720h
steps:
cluster_profile: aws
workflow: openshift-upgrade-aws
- as: e2e-gcp-upgrade
interval: 720h
steps:
cluster_profile: gcp
workflow: openshift-upgrade-gcp
- as: e2e-azure-upgrade
interval: 720h
steps:
cluster_profile: azure-2
env:
BASE_DOMAIN: ci2.azure.devcluster.openshift.com
workflow: openshift-upgrade-azure
- as: e2e-ovirt-upgrade
interval: 720h
steps:
cluster_profile: ovirt
env:
BASE_DOMAIN: ci2.azure.devcluster.openshift.com
test:
- as: test
commands: make upgrade_test
credentials:
- mount_path: /var/run/cnv-ci-brew-pull-secret
name: cnv-ci-brew-pull-secret
namespace: test-credentials
env:
- default: '|7820aea2-0d75-11e7-9259-28d244ea5a6d.hhav.f63e13'
name: BREW_IMAGE_REGISTRY_USERNAME
- default: /var/run/cnv-ci-brew-pull-secret/token
name: BREW_IMAGE_REGISTRY_TOKEN_PATH
- default: v0.45.0
name: KUBEVIRT_RELEASE
- default: "4.5"
name: OCP_VERSION
- default: /tmp/artifacts
name: ARTIFACTS_DIR
- default: openshift-cnv
name: TARGET_NAMESPACE
- default: "true"
name: PRODUCTION_RELEASE
from: cnv-ci-src-upgrade
resources:
requests:
cpu: 100m
memory: 600Mi
workflow: openshift-upgrade-ovirt-release-4.4-4.5
zz_generated_metadata:
branch: master
org: openshift
repo: release
variant: ci-4.5-upgrade-from-stable-4.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
current_ocp_release=4.5
future_ocp_release=4.6
interval=168

0 comments on commit ac02382

Please sign in to comment.