Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before branching day: integration tests #3227

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions hack/lib/branchcuts/test-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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::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}"

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

_diffs=$(diff --recursive "${_want_test_files_dir}" "${_src_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

return $_exit_status
}
readonly -f branchcuts::run_tests_template
41 changes: 41 additions & 0 deletions test/integration/br-cuts-generated-release-jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/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 _test_case_data="${1}"
local -n _cfg=$2
local _release_repo_path="${_test_case_data}/release"

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

os::log::info "${_cmd}"

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
40 changes: 40 additions & 0 deletions test/integration/br-cuts-release-controller-configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/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 _test_case_data="${1}"
local -n _cfg=$2
local _release_repo_path="${_test_case_data}/release"

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

os::log::info "${_cmd}"

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
41 changes: 41 additions & 0 deletions test/integration/br-cuts-rpm-mirroring-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/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 _test_case_data="${1}"
local -n _cfg=$2
local _release_repo_path="${_test_case_data}/release"
local _current_release="${_cfg['current_ocp_release']}"

local _cmd=$(printf "%s\n%s %s\n%s %s\n%s %s" \
rpm-deps-mirroring-services \
--release-repo "${_release_repo_path}" \
--current-release "${_current_release}")

os::log::info "${_cmd}"

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to separate this file into a folder named test1. We need to have all the input files in one place like we have them in the release repo. And to extend different cases you need to add more configs that include those cases. The tool should run only once and generate the desired output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test cases are much like the ones you can find into the cluster-init integration tests here: test/integration/cluster-init. I can adhere to the same naming conventions input and expected instead of data and want and renaming test1, test2, ... testN to something more meaningful but, other than that, both have test cases split into several folders, each of which recreates part of the openshift/release repository folders structure.
If you take a look at test/integration/cluster-init.sh you'll notice that cluster-init tool runs more than once.

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.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,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