Skip to content

Commit

Permalink
test: do not load images
Browse files Browse the repository at this point in the history
Signed-off-by: Sunil Thaha <sthaha@redhat.com>
  • Loading branch information
sthaha committed Mar 26, 2024
1 parent 535473a commit ccdd5d1
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions tests/run-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e -u -o pipefail

trap cleanup INT
# trap cleanup INT

PROJECT_ROOT="$(git rev-parse --show-toplevel)"
declare -r PROJECT_ROOT
Expand Down Expand Up @@ -68,9 +68,10 @@ declare -a __init_exit_todo_list=()
declare -i __init_script_exit_code=0

# on_exit_handler <exit-value>
_on_exit_handler() {
__on_exit_handler() {
# store the script exit code to be used later
__init_script_exit_code=${1:-0}
info "->> exit code: $__init_script_exit_code"

# print callstack
test $__init_script_exit_code -eq 0 || debug.print_callstack
Expand All @@ -95,15 +96,18 @@ on_exit() {

local n=${#__init_exit_todo_list[*]}
if [[ $n -eq 0 ]]; then
trap '_on_exit_handler $?' EXIT
info "will run $cmd on exit"
# install the exit handler on first call
trap '__on_exit_handler $?' EXIT
__init_exit_todo_list=("$cmd")
return 0
fi

__init_exit_todo_list=("$cmd" "${__init_exit_todo_list[@]}") #execute in reverse order

}

init.print_result() {
print_result() {
local exit_code=$__init_script_exit_code

local scr
Expand Down Expand Up @@ -415,31 +419,34 @@ kind_load_images() {
while read -r img; do
kind_load_image "$img"
done < <(yq -r .spec.relatedImages[].image "$OPERATOR_CSV")
prune_images_if_ci

info "loading additional images from $TEST_IMAGES_YAML"
while read -r img; do
kind_load_image "$img"
done < <(yq -r .images[].image "$TEST_IMAGES_YAML")
prune_images_if_ci

return 0
}

docker_prune() {
prune_images_if_ci() {
header "Prune Docker"
run docker system prune -a -f
$CI_MODE || {
info "skipping pruning of docker images when not in CI mode"
return 0
}
# NOTE: ci runs out of disk space at times, hence run images
info "pruning docker images and volumes"
run df -h
run docker images
run docker system prune -a -f --volumes
run df -h
}

deploy_operator() {
header "Build and Deploy Operator"

$CI_MODE && {
# NOTE: ci runs out of disk space at times, hence run images
info "pruning docker images and volumes"
run docker images
docker_prune
run df -h
}

prune_images_if_ci
ensure_imgpullpolicy_always_in_yaml
kind_load_images
delete_olm_subscription || true
Expand All @@ -452,6 +459,7 @@ deploy_operator() {
run_bundle_upgrade
fi
wait_for_operator "$OPERATORS_NS"
prune_images_if_ci
}

ensure_imgpullpolicy_always_in_yaml() {
Expand Down Expand Up @@ -559,7 +567,8 @@ main() {
}

cd "$PROJECT_ROOT"
on_exit init.print_result
on_exit print_result
on_exit cleanup

init_operator_img
init_logs_dir
Expand Down

0 comments on commit ccdd5d1

Please sign in to comment.