Skip to content

Commit

Permalink
Fix Dashboard Suites 0408, 0409, 0410 Tests and Keywords (red-hat-dat…
Browse files Browse the repository at this point in the history
…a-services#2152)

Fix Dashboard Test Suites 0408, 0409, 0410:

- 0408__ods_dashboard_settings_pod_tolerations.robot
- 0409__ods_dashboard_settings_accelerator_profiles.robot
- 0410__ods_dashboard_projects/0410__ods_dashboard_projects.robot
- 0410__ods_dashboard_projects/0410__ods_dashboard_projects_permissions_mgmt.robot

Including fixes to numerous keywords within:
- ODHDashboard.robot
- ODHDashboardSettings.resource
- DataConnections.resource
- Permissions.resource
- Projects.resource
- Storages.resource
- Workbenches.resource
- ODHDashboardSettingsAcceleratorProfiles.resource
- AcceleratorProfiles.resource
- Common.robot
- Menu.robot
- JupyterLabLauncher.robot

Signed-off-by: manosnoam <nmanos@redhat.com>
  • Loading branch information
manosnoam authored and omrirh committed Dec 30, 2024
1 parent 9aaf631 commit 0b621f3
Show file tree
Hide file tree
Showing 36 changed files with 331 additions and 381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ${ACCELERATOR_RESOURCES_DIRPATH}= tests/Resources/Files/accelerator
Create An Accelerator Profile Via CLI
[Documentation] Create an instance of Accelerator Profile using OC
[Arguments] ${name} ${ns}=${APPLICATIONS_NAMESPACE}
${status}= Run Keyword And Return Status Oc Create kind=AcceleratorProfile
${status}= Run Keyword And Return Status Oc Apply kind=AcceleratorProfile
... src=${ACCELERATOR_RESOURCES_DIRPATH}/${name}.yaml namespace=${ns}
... template_data={test_name: '${TEST_NAME}', test_ns: '${ns}'}
Should Be Equal As Integers ${status} ${TRUE}
Expand Down
38 changes: 30 additions & 8 deletions ods_ci/tests/Resources/Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@ Begin Web Test
... ODH dashboard, checking that the spawner is in a ready state before
... handing control over to the test suites.
[Arguments] ${username}=${TEST_USER.USERNAME} ${password}=${TEST_USER.PASSWORD}
... ${auth_type}=${TEST_USER.AUTH_TYPE}
... ${auth_type}=${TEST_USER.AUTH_TYPE} ${jupyter_login}=${TRUE}
Set Library Search Order SeleniumLibrary
RHOSi Setup
Open Browser ${ODH_DASHBOARD_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Login To RHODS Dashboard ${username} ${password} ${auth_type}
Wait For RHODS Dashboard To Load
Launch Jupyter From RHODS Dashboard Link
Login To Jupyterhub ${username} ${password} ${auth_type}
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
Fix Spawner Status
Go To ${ODH_DASHBOARD_URL}
IF ${jupyter_login}
Launch Jupyter From RHODS Dashboard Link
Login To Jupyterhub ${username} ${password} ${auth_type}
${authorization_required}= Is Service Account Authorization Required
IF ${authorization_required} Authorize JupyterLab Service Account
Fix Spawner Status
Go To ${ODH_DASHBOARD_URL}
END

End Web Test
[Arguments] ${username}=${TEST_USER.USERNAME}
Expand Down Expand Up @@ -119,11 +121,21 @@ Get All Text Under Element
${elements}= Get WebElements ${parent_element}
${text_list}= Create List
FOR ${element} IN @{elements}
${text}= Get Element Attribute ${element} textContent
${text}= Run Keyword And Ignore Error
... Get Element Attribute ${element} textContent
Append To List ${text_list} ${text}
END
RETURN ${text_list}

Scroll And Input Text Into Element
[Documentation] Scrolls element into view and inputs text into the element
[Arguments] ${element} ${text}
Scroll Element Into View ${element}
${text_entered}= Run Keyword And Return Status Input Text ${element} ${text}
IF ${text_entered} RETURN
Click Element ${element}
Press Keys NONE ${text}

Get All Strings That Contain
[Documentation] Returns new list of strings, for each item in ${list_of_strings} that contains ${substring_to_search}
[Arguments] ${list_of_strings} ${substring_to_search}
Expand Down Expand Up @@ -597,3 +609,13 @@ Skip If Cluster Type Is Managed
[Documentation] Skips test if cluster type is Managed
${cluster_type}= Is Cluster Type Self-Managed
Skip If condition=${cluster_type}==False msg=This test is skipped for Managed cluster

Delete All ${resource_type} In Namespace By Name
[Documentation] Force delete all ${resource_type} named '${resource_type}' in namespace '${namespace}'
[Arguments] ${namespace} ${resource_name}
${list_resources} = Set Variable oc -n ${namespace} get ${resource_type} -o name | grep /${resource_name}
${xargs_patch} = Set Variable xargs -rt oc -n ${namespace} patch --type=json -p '[{"op": "add", "path": "/metadata/ownerReferences", "value": null}]'
${xargs_delete} = Set Variable xargs -rt oc -n ${namespace} delete
${result} = Run Process ${list_resources} | ${xargs_patch} && ${list_resources} | ${xargs_delete}
... shell=true stderr=STDOUT
Log ${result.stdout} console=yes
6 changes: 4 additions & 2 deletions ods_ci/tests/Resources/Page/Components/Menu.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Settings ***
Library JupyterLibrary
Library String
Resource ../ODH/ODHDashboard/ODHDashboard.robot
Library String
Library JupyterLibrary

*** Keywords ***
Navigate To Page
Expand All @@ -17,6 +18,7 @@ Navigate To Page
IF "${is_menu_expanded}" == "false" Menu.Click Menu ${menu}
Wait Until Page Contains ${submenu}
Menu.Click Submenu ${submenu}
Run Keyword And Ignore Error Wait For Dashboard Page Title ${submenu}

Click Menu
[Arguments]
Expand Down
2 changes: 1 addition & 1 deletion ods_ci/tests/Resources/Page/ODH/JupyterHub/Elyra.resource
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Switch To Pipeline Execution Page
${login-required} = Is OpenShift Login Visible
IF ${login-required} Login To Openshift ${TEST_USER.USERNAME} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account
RETURN ${handle}

Set Runtime Image In All Nodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Spawn Notebook With Arguments # robocop: disable
IF ${oauth_prompt_visible} Click Button Log in with OpenShift
Run Keyword And Warn On Failure Login To Openshift ${username} ${password} ${auth_type}
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account

Wait Notebook To Be Loaded ${image} ${version}
${spawn_fail} = Has Spawn Failed
Expand Down Expand Up @@ -410,7 +410,7 @@ Launch JupyterHub Spawner From Dashboard
Launch Jupyter From RHODS Dashboard Link
Login To Jupyterhub ${username} ${password} ${auth}
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account
Fix Spawner Status
#Wait Until Page Contains Element xpath://span[@id='jupyterhub-logo']
Wait Until Page Contains Start server
Expand Down Expand Up @@ -700,7 +700,7 @@ Log In N Users To JupyterLab And Launch A Notebook For Each Of Them
Login To Jupyterhub ${username} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
Page Should Not Contain 403 : Forbidden
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account
Fix Spawner Status
Spawn Notebook With Arguments
END
Expand All @@ -718,7 +718,7 @@ CleanUp JupyterHub For N Users
Login To Jupyterhub ${username} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
Page Should Not Contain 403 : Forbidden
${authorization_required} = Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account
#Fix Spawner Status stops the current notebook, handling the different possible states
Fix Spawner Status
END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,15 @@ Clean Up User Notebook
Fail msg=This command requires ${admin_username} to be connected to the cluster (oc login ...)
END

Clean All Standalone Notebooks
[Documentation] Deletes all Standalone Jupyter Notebooks in ${NOTEBOOKS_NAMESPACE}
Delete All Notebooks In Namespace By Name ${NOTEBOOKS_NAMESPACE} jupyter-nb
Delete All Services In Namespace By Name ${NOTEBOOKS_NAMESPACE} jupyter-nb

Delete Folder In User Notebook
[Documentation] Delete recursively the folder /opt/app-root/src/${folder} in ${username}'s notebook PVC.
... Note: this command requires ${admin_username} to be logged to the cluster (oc login ...) and to have the user's notebook pod running (e.g. jupyterhub-nb-ldap-2duser1)
... Note: this command requires ${admin_username} to be logged to the cluster (oc login ...)
... and to have the user's notebook pod running (e.g. jupyterhub-nb-ldap-2duser1)
[Arguments] ${admin_username} ${username} ${folder}

# Verify that ${admin_username} is connected to the cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Is Service Account Authorization Required
${result} = Run Keyword And Return Status Should Start With ${title} Authorize service account
RETURN ${result}

Authorize jupyterhub service account
Authorize JupyterLab Service Account
Wait Until Page Contains Authorize Access
Checkbox Should Be Selected user:info
Click Element approve
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
*** Settings ***
Resource ../../../Page/Components/Components.resource
Resource ../../../Page/OCPDashboard/UserManagement/Groups.robot
Resource ../../../Common.robot
Resource ../JupyterHub/ODHJupyterhub.resource
Resource ../../../Common.robot
Resource ../JupyterHub/ODHJupyterhub.resource
Resource ../../../Page/ODH/ODHDashboard/ResourcesPage.resource
Resource ../../../Page/ODH/ODHDashboard/ODHDashboardSettings.resource
Resource ../../../OCP.resource
Resource ../../../Page/ODH/ODHDashboard/ODHDataScienceProject/Projects.resource
Resource ../../../OCP.resource
Library JupyterLibrary


Expand Down Expand Up @@ -869,7 +870,7 @@ Handle Deletion Confirmation Modal
Click Action From Actions Menu
[Documentation] Clicks an action from Actions menu (3-dots menu on the right)
[Arguments] ${item_title} ${action} ${item_type}=${NONE}
${item_row}= Set Variable //tr[td[@data-label="Name"]//*[text()="${item_title}"]]
${item_row}= Set Variable //tr[td[contains(translate(@data-label, 'NAME', 'name'), 'name')]//*[text()="${item_title}"]]
${action_btn}= Set Variable //button[@role="menuitem" and starts-with(.,"${action}")]
Click Element xpath=${item_row}//button[@aria-label="Kebab toggle"]
IF "${item_type}" != "${NONE}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ${ADMIN_GROUPS_SECTION}= //div[@data-testid="data-science-administrator-group
${ADMIN_GROUPS_LIST}= ${ADMIN_GROUPS_SECTION}//div[@role="group" and @aria-label="Current selections"]
${USER_GROUPS_SECTION}= //div[@data-testid="data-science-user-groups"]
${USER_GROUPS_LIST}= ${USER_GROUPS_SECTION}//div[@role="group" and @aria-label="Current selections"]
${SAVE_BUTTON}= //button[@data-testid="save-new-button"]
${SAVE_BUTTON}= //button[contains(., "Save changes")]

*** Keywords ***
Add OpenShift Groups To Data Science Administrators
Expand Down Expand Up @@ -51,7 +51,7 @@ Launch Dashboard And Check User Management Option Is Available For The User
Launch Dashboard ocp_user_name=${username} ocp_user_pw=${password} ocp_user_auth_type=${auth_type}
... dashboard_url=${ODH_DASHBOARD_URL} browser=${BROWSER.NAME} browser_options=${BROWSER.OPTIONS}
${authorization_required}= Is Service Account Authorization Required
IF ${authorization_required} Authorize jupyterhub service account
IF ${authorization_required} Authorize JupyterLab Service Account
IF ${settings_should_be}
# Wait up to 2 minutes as a workaround for bug RHOAIENG-11116
Menu.Navigate To Page Settings User management timeout=2m
Expand Down Expand Up @@ -86,11 +86,13 @@ Save Changes In User Management Setting
[Documentation] Save User Management Settings In Dashboard
[Arguments] ${timeout}=3s
Press Keys None ESC
Scroll Element Into View ${SAVE_BUTTON}
${button_enabled}= Run Keyword And Return Status
... Wait Until Element Is Enabled ${SAVE_BUTTON}
IF ${button_enabled}
Click Button ${SAVE_BUTTON}
Sleep ${timeout} reason=Wait for Dashboard to apply the updated configuration...
Wait Until Keyword Succeeds 30 1
... Wait Until Page Contains changes saved
END

AdminGroups In OdhDashboardConfig CRD Should Be
Expand Down Expand Up @@ -119,6 +121,7 @@ Clear User Management Settings
Set Pod Toleration Via UI
[Documentation] Sets toleration using admin UI
[Arguments] ${toleration}
Scroll Element Into View ${TOLERATION_CHECKBOX}
Wait Until Page Contains Element xpath:${TOLERATION_CHECKBOX}
Sleep 2s
${selected} = Run Keyword And Return Status Checkbox Should Be Selected xpath:${TOLERATION_CHECKBOX}
Expand All @@ -141,17 +144,7 @@ Disable Pod Toleration Via UI
Save Changes In Cluster Settings
[Documentation] Clicks on the "Save changes" button in Cluster settings and
... waits until "Cluster settings changes saved" is shown
Scroll Element Into View xpath://button[.="Save changes"]
Wait Until Page Contains Element xpath://button[.="Save changes"][@aria-disabled="false"] timeout=15s
Click Button Save changes
${clicked}= Run Keyword And Return Status
... Wait Until Page Contains Element xpath://button[.="Save changes"][@aria-disabled="true"]
IF ${clicked} == ${FALSE}
Capture Page Screenshot
Click Button Save changes
END
Wait Until Keyword Succeeds 30 1
... Wait Until Page Contains Cluster settings changes saved
Save Changes In User Management Setting
# New setting applies after a few seconds, empirically >15s.
# Sleep here to make sure it is applied.
Sleep 30s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ${EDIT_ACCELERATOR_PROFILE_BTN}= //table[@id='accelerator-profile-table']//sp
${DELETE_ACCELERATOR_PROFILE_BTN}= //table[@id='accelerator-profile-table']//span[text()='Delete']/ancestor::button
${ACCELERATOR_PROFILE_GRID_COLUMN_NAME}= //table[@id='accelerator-profile-table']//td[@data-label='Name']
${ACCELERATOR_PROFILE_SEARCH_INPUT}= //input[@aria-label="Search input"]
${ACCELERATOR_NAME}= //input[@id="accelerator-name"]
${ACCELERATOR_IDENTIFIER}= //input[@id="accelerator-identifier"]
${ACCELERATOR_DESCRIPTION}= //textarea[@id="accelerator-description"]
${ACCELERATOR_NAME}= //input[@data-testid="accelerator-profile-name"]
${ACCELERATOR_IDENTIFIER}= //input[@data-testid="accelerator-identifier-input"]
${ACCELERATOR_DESCRIPTION}= //textarea[@data-testid="accelerator-profile-description"]
${ACCELERATOR_ENABLED_SWITCH}= //input[@id="accelerator-enabled"]/following-sibling::span
${ACCELERATOR_ADD_TOLERATION_BTN}= //button[@data-testid="add-toleration-button"]
${ACCELERATOR_ADD_TOLERATION_MODAL_FORM}= //div[contains(@id, "pf-modal-part")]//span[text()="Add toleration"]
Expand All @@ -28,8 +28,6 @@ ${ACCELERATOR_TOLERATION_ADD_OR_UPDATE_BUTTON}= //button[@data-testid="modal-
${ACCELERATOR_EDIT_NAV_MENU_TOLERATIONS}= //nav[@aria-label="Jump to section"]//span[text()="Tolerations"]
${ACCELERATOR_EDIT_TOLERATION_KEBAB_BTN}= //section[@aria-label="Tolerations"]//table//button[@aria-label="Kebab toggle"]
${ACCELERATOR_EDIT_TOLERATION_MODAL_FORM}= //div[contains(@id, "pf-modal-part")]//span[text()="Edit toleration"]
${ACCELERATOR_DISABLE_MODAL_DISABLE_BUTTON}= //span[text()='Disable accelerator profile']/ancestor::header/following::footer/button[text()='Disable']
${ACCELERATOR_DELETE_MODAL_DELETE_BUTTON}= //span[text()='Delete accelerator profile?']/ancestor::header/following::footer/button[text()='Delete']
${ACCELERATOR_DELETE_MODAL_INPUT}= //input[@id="delete-modal-input"]


Expand Down Expand Up @@ -67,8 +65,8 @@ Disable Accelerator Profile
... view: Settings -> Accelerator profiles
[Arguments] ${name}
Click On The Enable Switch From Accelerator Profile ${name}
Wait Until Page Contains Element ${ACCELERATOR_DISABLE_MODAL_DISABLE_BUTTON}
Click Button ${ACCELERATOR_DISABLE_MODAL_DISABLE_BUTTON}
Wait Until Page Contains Element ${GENERIC_DISABLE_BTN_XP}
Click Button ${GENERIC_DISABLE_BTN_XP}

Search For Accelerator Profile In Grid
[Documentation] Search for and specific Accelerator Profile in the grid
Expand Down Expand Up @@ -108,10 +106,10 @@ Create An Accelerator Profile Via UI
Wait Until Element Is Visible ${ACCELERATOR_ADD_TOLERATION_MODAL_FORM}
# Select Operator
Click Button ${ACCELERATOR_TOLERATION_OPERATOR_DROPDOWN}
Click Element //li[@data-testid="dropdown-item ${tol_operator}"]
Click Element //li[@data-testid="${tol_operator}"]
# Select Effect
Click Button ${ACCELERATOR_TOLERATION_EFFECT_DROPDOWN}
Click Element //li[@data-testid="dropdown-item ${tol_effect}"]
Click Element //li[@data-testid="${tol_effect}"]
# Input Key and value
Input Text ${ACCELERATOR_TOLERATION_KEY} ${tol_key}
Input Text ${ACCELERATOR_TOLERATION_VALUE} ${tol_value}
Expand Down Expand Up @@ -150,17 +148,18 @@ Edit Accelerator Profile
END
IF "${tolerations}" != "${EMPTY}"
${first_kebab}= Catenate SEPARATOR= ${ACCELERATOR_EDIT_TOLERATION_KEBAB_BTN} [1]
Click Button ${first_kebab}
Click Element ${ACCELERATOR_EDIT_NAV_MENU_TOLERATIONS}
Click Element ${first_kebab}
Wait Until Element Is Visible ${first_kebab}/following::div//span[text()="Edit"] timeout=10
Click Element ${first_kebab}/following::div//span[text()="Edit"]
Wait Until Element Is Visible ${ACCELERATOR_EDIT_TOLERATION_MODAL_FORM} timeout=10
IF "${tol_operator}" != "${EMPTY}"
Click Button ${ACCELERATOR_TOLERATION_OPERATOR_DROPDOWN}
Click Element //li[@data-testid="dropdown-item ${tol_operator}"]
Click Element ${ACCELERATOR_TOLERATION_OPERATOR_DROPDOWN}
Click Element //li[@data-testid="${tol_operator}"]
END
IF "${tol_effect}" != "${EMPTY}"
Click Button ${ACCELERATOR_TOLERATION_EFFECT_DROPDOWN}
Click Element //li[@data-testid="dropdown-item ${tol_effect}"]
Click Element ${ACCELERATOR_TOLERATION_EFFECT_DROPDOWN}
Click Element //li[@data-testid="${tol_effect}"]
END
IF "${tol_key}" != "${EMPTY}"
Clear Element And Input Text ${ACCELERATOR_TOLERATION_KEY} ${tol_key}
Expand Down
Loading

0 comments on commit 0b621f3

Please sign in to comment.