From e3764e8356710a99fc720b5c571419ccc6347e8e Mon Sep 17 00:00:00 2001 From: Jian Li Date: Thu, 23 Jan 2025 14:54:24 +0800 Subject: [PATCH] Enabled test step 9 of test case OCP-77520 oc adm upgreade recommend --- .../cucushift-upgrade-toimage-commands.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ci-operator/step-registry/cucushift/upgrade/toimage/cucushift-upgrade-toimage-commands.sh b/ci-operator/step-registry/cucushift/upgrade/toimage/cucushift-upgrade-toimage-commands.sh index 1a426596ef61..4adb1942493e 100644 --- a/ci-operator/step-registry/cucushift/upgrade/toimage/cucushift-upgrade-toimage-commands.sh +++ b/ci-operator/step-registry/cucushift/upgrade/toimage/cucushift-upgrade-toimage-commands.sh @@ -340,6 +340,37 @@ function upgrade() { echo "Upgrading cluster to ${TARGET} gets started..." } +# this is the test step 9 for https://polarion.engineering.redhat.com/polarion/#/project/OSE/workitem?id=OCP-77520 +function check_upgrade_recommend_when_upgrade_inprogress() { + if [[ -n "${SOURCE_MINOR_VERSION}" ]] && [[ "${SOURCE_MINOR_VERSION}" -le "17" ]] ; then + echo "oc adm upgrade recommend is enabled in OCP 4.18, skip" + return 0 + fi + # So far, this is a TP feature in OCP 4.18 and OCP 4.19, so need to enable the gate + export OC_ENABLE_CMD_UPGRADE_RECOMMEND=true + local out + local info="info: An update is in progress. You may wish to let this update complete before requesting a new update." + local no_update="No updates available. You may still upgrade to a specific release image with --to-image or wait for new updates to be available." + local error="error: no updates available, so cannot display context for the requested release 4.999.999" + + out="$(oc adm upgrade recommend)" + if [[ "${out}" != *"${info}"* ]] || [[ "${out}" != *"${no_update}"* ]]; then + echo "OCP-77520: Command \"oc adm upgrade recommend\" should output \"${info}\" and \"${no_update}\", but actualy not: \"${out}\"" + return 1 + fi + out="$(oc adm upgrade recommend --show-outdated-releases)" + if [[ "${out}" != *"${info}"* ]] || [[ "${out}" != *"${no_update}"* ]]; then + echo "OCP-77520: Command \"oc adm upgrade recommend --show-outdated-releases\" should output \"${info}\" and \"${no_update}\", but actualy not: \"${out}\"" + return 1 + fi + out="$(oc adm upgrade recommend --version 4.999.999)" + if [[ "${out}" != *"${info}"* ]] || [[ "${out}" != *"${error}"* ]]; then + echo "OCP-77520: Command \"oc adm upgrade recommend --version 4.999.999\" should output \"${info}\" and \"${error}\", but actualy not: \"${out}\"" + return 1 + fi + return 0 +} + # Monitor the upgrade status function check_upgrade_status() { local wait_upgrade="${TIMEOUT}" interval=1 out avail progress cluster_version stat_cmd stat='empty' oldstat='empty' filter='[0-9]+h|[0-9]+m|[0-9]+s|[0-9]+%|[0-9]+.[0-9]+s|[0-9]+ of|\s+|\n' start_time end_time @@ -378,6 +409,9 @@ function check_upgrade_status() { echo -e "Eclipsed Time: $(( ($end_time - $start_time) / 60 ))m\n" return 0 fi + if ! check_upgrade_recommend_when_upgrade_inprogress; then + echo "OCP-77520: failed" + fi if [[ "${UPGRADE_RHEL_WORKER_BEFOREHAND}" == "true" && ${avail} == "True" && ${progress} == "True" && ${out} == *"Unable to apply ${cluster_version}"* ]]; then UPGRADE_RHEL_WORKER_BEFOREHAND="triggered" echo -e "Upgrade stuck at updating RHEL worker, need to run the RHEL worker upgrade later...\n\n"