Skip to content

Commit

Permalink
add the option to install previous rhoai version on psi operatorhub t…
Browse files Browse the repository at this point in the history
…hen to upgrade

Signed-off-by: Kobi Hakimi <khakimi@redhat.com>
  • Loading branch information
kobihk committed Nov 25, 2024
1 parent 471dc03 commit 3f86a41
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 49 deletions.
3 changes: 2 additions & 1 deletion ods_ci/tasks/Resources/RHODS_OLM/install/cs_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ items:
namespace: <OPERATOR_NAMESPACE>
spec:
channel: <UPDATE_CHANNEL>
installPlanApproval: Automatic
installPlanApproval: <INSTALL_PLAN_APPROVAL>
name: <OPERATOR_NAME>
source: <CATALOG_SOURCE>
sourceNamespace: openshift-marketplace
startingCSV: <STARTING_CSV>
- apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
Expand Down
6 changes: 4 additions & 2 deletions ods_ci/tasks/Resources/RHODS_OLM/install/install.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ Resource oc_install.robot


*** Keywords ***
Installing RHODS Operator ${image_url}
Installing RHODS Operator
[Documentation] Installing the RHOAI operator
[Arguments] ${image_url} ${install_plan_approval} ${rhoai_version}=${EMPTY}
${is_operator_installed} = Is RHODS Installed
IF not ${is_operator_installed} Run Keywords
... Log Installing RHODS operator in ${cluster_type} console=yes AND
... Set Suite Variable ${image_url} AND
... Set Test Variable ${RHODS_OSD_INSTALL_REPO} AND
... Install RHODS ${cluster_type} ${image_url}
... Install RHODS ${cluster_type} ${image_url} ${install_plan_approval} ${rhoai_version}

RHODS Operator Should Be installed
Verify RHODS Installation
Expand Down
65 changes: 42 additions & 23 deletions ods_ci/tasks/Resources/RHODS_OLM/install/oc_install.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,49 @@ ${SERVICEMESH_SUB_NAME}= servicemeshoperator
${AUTHORINO_OP_NAME}= authorino-operator
${AUTHORINO_SUB_NAME}= authorino-operator
${AUTHORINO_CHANNEL_NAME}= tech-preview-v1
${RHODS_CSV_DISPLAY}= Red Hat OpenShift AI
${ODH_CSV_DISPLAY}= Open Data Hub Operator
${CUSTOM_MANIFESTS}= ${EMPTY}
${RHODS_OSD_INSTALL_REPO} ${EMPTY}
${OLM_DIR} rhodsolm
@{SUPPORTED_TEST_ENV} AWS AWS_DIS GCP PSI PSI_DIS ROSA IBM_CLOUD CRC AZURE ROSA_HCP
${install_plan_approval} Manual
${rhoai_version} ${EMPTY}

*** Keywords ***
Install RHODS
[Arguments] ${cluster_type} ${image_url}
[Arguments] ${cluster_type} ${image_url} ${install_plan_approval} ${rhoai_version}=${EMPTY} ${is_upgrade}=False
Log To Console Start installing RHOAI with:\n\- cluster type: ${cluster_type}\n\- image_url: ${image_url}\n\- update_channel: ${UPDATE_CHANNEL}
Log To Console \- rhoai_version: ${rhoai_version}\n\- is_upgrade: ${is_upgrade}\n\- install_plan_approval: ${install_plan_approval}
Assign Vars According To Product
Install Kserve Dependencies
Clone OLM Install Repo
IF "${PRODUCT}" == "ODH"
${csv_display_name} = Set Variable ${ODH_CSV_DISPLAY}
ELSE
${csv_display_name} = Set Variable ${RHODS_CSV_DISPLAY}
END
IF "${cluster_type}" == "selfmanaged"
IF "${TEST_ENV}" in "${SUPPORTED_TEST_ENV}" and "${INSTALL_TYPE}" == "CLi"
Install RHODS In Self Managed Cluster Using CLI ${cluster_type} ${image_url}
ELSE IF "${TEST_ENV}" in "${SUPPORTED_TEST_ENV}" and "${INSTALL_TYPE}" == "OperatorHub"
${file_path} = Set Variable tasks/Resources/RHODS_OLM/install/
Copy File source=${file_path}cs_template.yaml destination=${file_path}cs_apply.yaml
IF "${PRODUCT}" == "ODH"
Run sed -i'' -e 's/<CATALOG_SOURCE>/community-operators/' ${file_path}cs_apply.yaml
IF "${is_upgrade}" == "False"
${file_path} = Set Variable tasks/Resources/RHODS_OLM/install/
${starting_csv} = Set Variable ""
IF "${rhoai_version}" != "${EMPTY}"
Log To Console Start installing "${OPERATOR_NAME}" with version: ${rhoai_version}
${starting_csv} = Set Variable ${OPERATOR_DEPLOYMENT_NAME}.${rhoai_version}
END
Copy File source=${file_path}cs_template.yaml destination=${file_path}cs_apply.yaml
Run sed -i'' -e 's/<CATALOG_SOURCE>/${CATALOG_SOURCE}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<OPERATOR_NAME>/${OPERATOR_DEPLOYMENT_NAME}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<OPERATOR_NAMESPACE>/${OPERATOR_NAMESPACE}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<UPDATE_CHANNEL>/${UPDATE_CHANNEL}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<STARTING_CSV>/${starting_csv}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<INSTALL_PLAN_APPROVAL>/${install_plan_approval}/' ${file_path}cs_apply.yaml
Oc Apply kind=List src=${file_path}cs_apply.yaml
Remove File ${file_path}cs_apply.yml
ELSE
Run sed -i'' -e 's/<CATALOG_SOURCE>/redhat-operators/' ${file_path}cs_apply.yaml
${patch_update_channel_status} = Run And Return Rc oc patch subscription ${OPERATOR_DEPLOYMENT_NAME} -n ${OPERATOR_NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/channel", "value": ${UPDATE_CHANNEL}}]' #robocop:disable
Should Be Equal As Integers ${patch_update_channel_status} 0 msg=Error while changing the UPDATE_CHANNEL
Sleep 30s reason=wait for thirty seconds until old CSV is removed and new one is ready
END
IF "${rhoai_version}" != "${EMPTY}"
Wait For Installplan And Approve It ${OPERATOR_NAMESPACE} ${OPERATOR_DEPLOYMENT_NAME} ${rhoai_version}
END
Run sed -i'' -e 's/<OPERATOR_NAME>/${OPERATOR_NAME}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<OPERATOR_NAMESPACE>/${OPERATOR_NAMESPACE}/' ${file_path}cs_apply.yaml
Run sed -i'' -e 's/<UPDATE_CHANNEL>/${UPDATE_CHANNEL}/' ${file_path}cs_apply.yaml
Oc Apply kind=List src=${file_path}cs_apply.yaml
Remove File ${file_path}cs_apply.yml
ELSE
FAIL Provided test environment and install type is not supported
END
Expand All @@ -71,15 +84,15 @@ Install RHODS
FAIL Provided test environment is not supported
END
END
Wait Until Csv Is Ready display_name=${csv_display_name} operators_namespace=${OPERATOR_NAMESPACE}
Wait Until Csv Is Ready display_name=${OPERATOR_NAME} operators_namespace=${OPERATOR_NAMESPACE}

Verify RHODS Installation
Set Global Variable ${DASHBOARD_APP_NAME} ${PRODUCT.lower()}-dashboard
Log Verifying RHODS installation console=yes
Log To Console Waiting for all RHODS resources to be up and running
Wait For Pods Numbers 1
... namespace=${OPERATOR_NAMESPACE}
... label_selector=name=${OPERATOR_NAME}
... label_selector=name=${OPERATOR_DEPLOYMENT_NAME}
... timeout=2000
Wait For Pods Status namespace=${OPERATOR_NAMESPACE} timeout=1200
Log Verified ${OPERATOR_NAMESPACE} console=yes
Expand Down Expand Up @@ -190,9 +203,14 @@ Verify Builds In redhat-ods-applications

Clone OLM Install Repo
[Documentation] Clone OLM git repo
${return_code} ${output} Run And Return Rc And Output git clone ${RHODS_OSD_INSTALL_REPO} ${EXECDIR}/${OLM_DIR}
Log To Console ${output}
Should Be Equal As Integers ${return_code} 0
${status} = Run Keyword And Return Status Directory Should Exist ${EXECDIR}/${OLM_DIR}
IF ${status}
Log To Console "The directory ${EXECDIR}/${OLM_DIR} already exist, skipping clone of the repo."
ELSE
${return_code} ${output} Run And Return Rc And Output git clone ${RHODS_OSD_INSTALL_REPO} ${EXECDIR}/${OLM_DIR}
Log To Console ${output}
Should Be Equal As Integers ${return_code} 0
END

Install RHODS In Self Managed Cluster Using CLI
[Documentation] Install rhods on self managed cluster using cli
Expand All @@ -213,6 +231,7 @@ Wait For Pods Numbers
${status} Set Variable False
FOR ${counter} IN RANGE ${timeout}
${return_code} ${output} Run And Return Rc And Output oc get pod -n ${namespace} -l ${label_selector} | tail -n +2 | wc -l
Log To Console Output: ${output} RC: ${return_code} counter: ${counter} timeout: ${timeout} NS: ${namespace} label: ${label_selector}
IF ${output} == ${count}
${status} Set Variable True
Log To Console pods ${label_selector} created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Check A RHODS Family Operator Is Installed
[Arguments] ${namespace} ${subscription}
Log Getting CSV from subscription ${subscription} namespace ${namespace} console=yes
${rc} ${current_csv_name} = Run And Return Rc And Output
... oc get subscription ${subscription} -n ${namespace} -ojson | jq '.status.currentCSV' | tr -d '"'
... oc get subscription ${subscription} -n ${namespace} -ojson | jq '.status.installedCSV' | tr -d '"'
Log Got CSV ${current_csv_name} from subscription ${subscription}, result: ${rc} console=yes
IF "${rc}" == "0" and "${current_csv_name}" != "${EMPTY}"
${result} = Run Keyword And Return Status
Expand Down
17 changes: 7 additions & 10 deletions ods_ci/tasks/Tasks/rhods_olm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ Library String
***Variables***
${cluster_type} selfmanaged
${image_url} ${EMPTY}
${RHODS_OSD_INSTALL_REPO} None
@{SUPPORTED_TEST_ENV} AWS AWS_DIS GCP PSI PSI_DIS ROSA IBM_CLOUD CRC AZURE ROSA_HCP
${TEST_ENV} AWS
${INSTALL_TYPE} OperatorHub
${UPDATE_CHANNEL} odh-nightlies
${OLM_DIR} rhodsolm
${RHODS_VERSION} None

*** Tasks ***
Expand All @@ -24,15 +21,15 @@ Can Install RHODS Operator
IF "${PRODUCT}" == "ODH"
Set Global Variable ${OPERATOR_NAMESPACE} opendatahub-operators
IF "${UPDATE_CHANNEL}" == "odh-nightlies"
Set Global Variable ${OPERATOR_NAME} rhods-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} rhods-operator
ELSE
Set Global Variable ${OPERATOR_NAME} opendatahub-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} opendatahub-operator
END
ELSE
Set Global Variable ${OPERATOR_NAME} rhods-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} rhods-operator
END
Given Selected Cluster Type ${cluster_type}
When Installing RHODS Operator ${image_url}
When Installing RHODS Operator ${image_url} ${install_plan_approval} ${RHOAI_VERSION}
Then RHODS Operator Should Be Installed
[Teardown] Install Teardown

Expand All @@ -41,12 +38,12 @@ Can Uninstall RHODS Operator
IF "${PRODUCT}" == "ODH"
Set Global Variable ${OPERATOR_NAMESPACE} opendatahub-operators
IF "${UPDATE_CHANNEL}" == "odh-nightlies"
Set Global Variable ${OPERATOR_NAME} rhods-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} rhods-operator
ELSE
Set Global Variable ${OPERATOR_NAME} opendatahub-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} opendatahub-operator
END
ELSE
Set Global Variable ${OPERATOR_NAME} rhods-operator
Set Global Variable ${OPERATOR_DEPLOYMENT_NAME} rhods-operator
END
Given Selected Cluster Type ${cluster_type}
When Uninstalling RHODS Operator
Expand Down
22 changes: 19 additions & 3 deletions ods_ci/tests/Resources/Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Get RHODS Version
${RHODS_VERSION}= Run oc get csv -n ${OPERATOR_NAMESPACE} | grep "opendatahub" | awk -F ' {2,}' '{print $3}'
END
END
Log Product:${PRODUCT} Version:${RHODS_VERSION}
Log To Console Product:${PRODUCT} Version:${RHODS_VERSION}
RETURN ${RHODS_VERSION}

#robocop: disable: line-too-long
Expand All @@ -176,17 +176,33 @@ Get CodeFlare Version
#robocop: disable: line-too-long
Wait Until Csv Is Ready
[Documentation] Waits ${timeout} for Operators CSV '${display_name}' to have status phase 'Succeeded'
[Arguments] ${display_name} ${timeout}=10m ${operators_namespace}=openshift-operators
[Arguments] ${display_name} ${timeout}=10m ${operators_namespace}=openshift-operators ${check_interval}=5s
Log Waiting ${timeout} for Operator CSV '${display_name}' in ${operators_namespace} to have status phase 'Succeeded' console=yes
WHILE True limit=${timeout}
... on_limit_message=${timeout} Timeout exceeded waiting for CSV '${display_name}' to be created
Sleep ${check_interval}
${csv_created}= Run Process oc get csv --no-headers -n ${operators_namespace} | awk '/${display_name}/ {print \$1}' shell=yes
IF "${csv_created.stdout}" == "${EMPTY}" CONTINUE
Log To Console The Result of csv_created Output is: ${csv_created.stdout} RC: ${csv_created.rc}
IF '${csv_created.stdout}' == '${EMPTY}' CONTINUE
# In case of upgrade there are 2 operators, we need to wait until only one will be available
${lines}= Split String ${csv_created.stdout} \n
${line_count}= Get Length ${lines}
IF ${line_count} > 1 CONTINUE
${csv_ready}= Run Process
... oc wait --timeout\=${timeout} --for jsonpath\='{.status.phase}'\=Succeeded csv -n ${operators_namespace} ${csv_created.stdout} shell=yes
Log To Console The Result of csv_ready Output is: ${csv_ready.stdout} RC: ${csv_ready.rc}
IF ${csv_ready.rc} == ${0} BREAK
END

Check If Resource Exists By Command Output
[Documentation] Check if resource exists with specific command,
... Fail if the output is empty or contains the string 'No resources found'
[Arguments] ${command}
${result}= Run Process ${command} shell=True stdout=PIPE
Log To Console The Result of Check If Resource Exists By Command Output is: ${result.stdout} RC: ${result.rc}
Should Not Be Empty ${result.stdout}
Should Not Contain ${result.stdout} 'No resources found'

Get Cluster ID
[Documentation] Retrieves the ID of the currently connected cluster
${cluster_id}= Run oc get clusterversion -o json | jq .items[].spec.clusterID
Expand Down
27 changes: 26 additions & 1 deletion ods_ci/tests/Resources/OCP.resource
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,32 @@ Get Resource Attribute
Should Be Equal "${rc}" "0" msg=${value}
IF "${value}" != "${EMPTY}"
Log To Console ${resource_type} ${resource_name} in the namespace ${namespace} attribute ${attribute_path} value is ${value}
ELSE
ELSE
Log To Console ${resource_type} ${resource_name} in the namespace ${namespace} attribute ${attribute_path} value is EMPTY
END
RETURN ${value}

Wait For Installplan And Approve It
[Documentation] Wait for the operator's installplan to appear then approve it in case of Manual installplan approval
[Arguments] ${namespace} ${operator_name} ${operator_version}=${EMPTY}
Wait Until Keyword Succeeds 10m 5s Check If Resource Exists By Command Output oc get installplans -n ${namespace} -o yaml | grep "${operator_name}"
${installplan_name}= Run oc get subscription ${operator_name} -n ${namespace} -o json | jq '.status.installplan.name'
IF "${operator_version}" != "${EMPTY}"
${installplan_version_exist}= Run And Return Rc oc get installplan -n ${namespace} | grep "${operator_version}"
IF ${installplan_version_exist} != 0
${installplans}= Run oc get installplan -n ${namespace}
FAIL Failed to find installplan for operator: ${operator_name} version: ${operator_version}\nExisting installplans:\n${installplans}
END
END
${installplan_approval}= Get Resource Attribute ${namespace}
... InstallPlan ${installplan_name} .spec.approval
Log To Console The installplan approval for: ${installplan_name} is ${installplan_approval}
IF "${installplan_approval}" == "Manual"
Log To Console Start approving the installplan: ${installplan_name}...
${patch_status} = Run And Return Rc oc patch installplan ${installplan_name} -n ${namespace} -p '{"spec":{"approved": true}}' --type=merge
IF ${patch_status} == 0
Log To Console Approving the installplan ${installplan_name} successfully!!
ELSE
Log To Console Failed to approving the installplan ${installplan_name}
END
END
4 changes: 3 additions & 1 deletion ods_ci/tests/Resources/Page/Operators/ISVs.resource
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Install ISV Operator From OperatorHub Via CLI # robocop: disable
Oc Apply kind=Subscription src=${operator_sub_filepath}
Wait Until Keyword Succeeds 1 min 0 sec
... Is Resource Present Subscription ${subscription_name} ${namespace} ${IS_PRESENT}
# Wait For Installplan And Approve It ${namespace} ${operator_name}
WHILE "${installplan_name}" == "${EMPTY}" limit=5m
${installplan_name}= Get Resource Attribute ${namespace}
... Subscription ${subscription_name} .status.installPlanRef.name
Expand All @@ -49,6 +50,7 @@ Install ISV Operator From OperatorHub Via CLI # robocop: disable
${return_code} ${out}= Run And Return Rc And Output oc patch installplan ${installplan_name} -n ${namespace} --type='json' -p '[{"op": "replace", "path": "/spec/approved", "value": true}]' #robocop:disable
Should Be Equal As Integers ${return_code} 0 msg=Error while approving installplan
END
# until here

Create Operator Group
[Documentation] Creates the Operator Group object which might be needed by an operator.
Expand Down Expand Up @@ -83,7 +85,7 @@ Wait Until Operator Subscription Last Condition Is # robocop: disable
[Arguments] ${type} ${status} ${reason}
... ${subcription_name} ${namespace}=openshift-operators
... ${retry}=60
... ${retry_interval}=3s
... ${retry_interval}=5s
Wait Until Keyword Succeeds ${retry} times ${retry_interval} Operator Subscription Last Condition Should Be # robocop: disable
... type=${type} status=${status}
... reason=${reason} subcription_name=${subcription_name}
Expand Down
2 changes: 2 additions & 0 deletions ods_ci/tests/Resources/RHOSi.resource
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Assign Vars According To Product
IF "${PRODUCT}" == "RHODS"
Set Suite Variable ${OPERATOR_APPNAME} Red Hat OpenShift AI
Set Suite Variable ${OPERATOR_NAME} Red Hat OpenShift AI
Set Suite Variable ${CATALOG_SOURCE} redhat-operators
Set Suite Variable ${OPERATOR_DEPLOYMENT_NAME} rhods-operator
Set Suite Variable ${OPERATOR_LABEL_SELECTOR} name=rhods-operator
Set Suite Variable ${AUTHORINO_CR_NS} redhat-ods-applications-auth-provider
Expand All @@ -99,6 +100,7 @@ Assign Vars According To Product
ELSE IF "${PRODUCT}" == "ODH"
Set Suite Variable ${OPERATOR_APPNAME} Open Data Hub Operator
Set Suite Variable ${OPERATOR_NAME} Open Data Hub Operator
Set Suite Variable ${CATALOG_SOURCE} community-operators
Set Suite Variable ${OPERATOR_DEPLOYMENT_NAME} opendatahub-operator-controller-manager
Set Suite Variable ${OPERATOR_LABEL_SELECTOR} control-plane=controller-manager
Set Suite Variable ${AUTHORINO_CR_NS} opendatahub-auth-provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Resource ../../../Resources/Page/DistributedWorkloads/DistributedWorkl
Resource ../../../Resources/Page/DistributedWorkloads/WorkloadMetricsUI.resource
Suite Setup Dashboard Suite Setup
Suite Teardown RHOSi Teardown
Test Tags PreUpgrade
Test Tags PreUpgradeKobi


*** Variables ***
Expand All @@ -39,6 +39,11 @@ ${MODEL_CREATED}= ${FALSE}
${RUNTIME_NAME}= Model Serving Test

*** Test Cases ***
Test PreUpgrade
[Documentation] Test for pre upgrade
[Tags] PreUpgrade
Log To Console This is test of PreUpgrade

Set PVC Size Via UI
[Documentation] Sets a Pod toleration via the admin UI
[Tags] Upgrade
Expand Down
Loading

0 comments on commit 3f86a41

Please sign in to comment.