Skip to content

Commit

Permalink
Attempt at optimizing openshift login step (#559)
Browse files Browse the repository at this point in the history
* slightly modify login step

Signed-off-by: Luca Giorgi <[email protected]>

* Use URL in login keyword

Signed-off-by: Luca Giorgi <[email protected]>

* Add keywords to get domain, check domain in login step

Signed-off-by: Luca Giorgi <[email protected]>

* Add examples in documentation

Signed-off-by: Luca Giorgi <[email protected]>

* Remove sleep, change skip tour keyword

Signed-off-by: Luca Giorgi <[email protected]>

* Fix smoke/sanity failures

Signed-off-by: Luca Giorgi <[email protected]>

* Add 0.5s of sleep in Maybe Close Popup

Signed-off-by: Luca Giorgi <[email protected]>

* Clean up comments

Signed-off-by: Luca Giorgi <[email protected]>

Signed-off-by: Luca Giorgi <[email protected]>
  • Loading branch information
lugi0 authored Sep 21, 2022
1 parent 40de688 commit 8a1e223
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 22 deletions.
17 changes: 17 additions & 0 deletions tests/Resources/Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ Skip If RHODS Version Greater Or Equal Than
Skip If condition=${version-check}==True msg=This test is skipped for RHODS ${version} or greater
END

Get Domain From Current URL
[Documentation] Gets the lowest level domain from the current URL (i.e. everything before the first dot in the URL)
... e.g. https://console-openshift-console.apps.<cluster>.rhods.ccitredhat.com -> https://console-openshift-console
... e.g. https://rhods-dashboard-redhat-ods-applications.apps.<cluster>.rhods.ccitredhat.com/ -> https://rhods-dashboard-redhat-ods-applications
${current_url} = Get Location
${domain} = Fetch From Left string=${current_url} marker=.
[Return] ${domain}

Is Current Domain Equal To
[Documentation] Compare the lowest level domain to a given string
... and returns True/False
[Arguments] ${url}
${domain} = Get Domain From Current URL
${comparison} = Run Keyword And Return Status Should Be Equal As Strings
... ${domain} ${url}
[Return] ${comparison}

Get OAuth Cookie
[Documentation] Fetches the "_oauth_proxy" cookie from Dashboard page.
... You can use the value from this cookie to perform login in API calls.
Expand Down
15 changes: 8 additions & 7 deletions tests/Resources/Page/LoginPage.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*** Settings ***
Resource OCPDashboard/OCPDashboard.resource
Resource ../Common.robot
Library DebugLibrary
Library JupyterLibrary

Expand Down Expand Up @@ -33,17 +34,17 @@ Select Login Authentication Type

Login To Openshift
[Arguments] ${ocp_user_name} ${ocp_user_pw} ${ocp_user_auth_type}
# Give the login prompt time to render after browser opens
Wait Until Element is Visible xpath://div[@class="pf-c-login"] timeout=15seconds
# Check if we are in the Openshift auth page
${should_login} = Is Current Domain Equal To https://oauth-openshift
IF ${should_login}==False
Return From Keyword
END
# If here we need to login
Wait Until Element is Visible xpath://div[@class="pf-c-login"] timeout=10s
${select_auth_type} = Does Login Require Authentication Type
Run Keyword If ${select_auth_type} Select Login Authentication Type ${ocp_user_auth_type}
Wait Until Page Contains Log in to your account
Input Text id=inputUsername ${ocp_user_name}
Input Text id=inputPassword ${ocp_user_pw}
Click Element xpath=/html/body/div/div/main/div/form/div[4]/button
# FIXME: replace this sleep for something more efficient, considering that this method is used for
# authentication in OpenShift Console, but also RHODS dashboard and other places
Sleep 10
# FIXME: this only applies to login to OpenShift Console, but this method is used
# for authentication in RHODS dashboard and other places
Maybe Skip Tour
12 changes: 9 additions & 3 deletions tests/Resources/Page/OCPDashboard/OCPMenu.robot
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*** Settings ***
Resource ../../Common.robot
Library JupyterLibrary
Library String

Expand Down Expand Up @@ -43,6 +44,11 @@ Switch To Developer Perspective
END

Maybe Skip Tour
${tour_modal} = Run Keyword And Return Status Page Should Contain Element xpath=//div[@id='guided-tour-modal']
Run Keyword If ${tour_modal} Click Element xpath=//div[@id='guided-tour-modal']/button

[Documentation] If we are in the openshift web console, maybe skip the first time
... tour popup given to users, otherwise return from keyword.
${should_cont} = Is Current Domain Equal To https://console-openshift-console
IF ${should_cont}==False
Return From Keyword
END
${tour_modal} = Run Keyword And Return Status Wait Until Page Contains Element xpath=//div[@id='guided-tour-modal'] timeout=5s
Run Keyword If ${tour_modal} Click Element xpath=//div[@id='guided-tour-modal']/button
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Resource ../../Components/Components.resource
Resource ../../LoginPage.robot
Library JupyterLibrary


*** Variables ***
${OCP_LOADING_ANIMATION_XPATH}= //div[contains(@class, "cos-status-box--loading")]


*** Keywords ***
Open OperatorHub
Open OCP Console
Expand All @@ -16,6 +21,8 @@ Install ODH Operator

Open OCP Console
Open Page ${OCP_CONSOLE_URL}
Wait Until Page Contains Element xpath:${OCP_LOADING_ANIMATION_XPATH} timeout=5s
Wait Until Page Does Not Contain Element xpath:${OCP_LOADING_ANIMATION_XPATH} timeout=10s

Navigate to OperatorHub
Menu.Navigate To Page Operators OperatorHub
Expand All @@ -25,4 +32,3 @@ OperatorHub Should Be Open

ODH Operator Should Be Installed
Operator Should Be Installed Open Data Hub Operator

5 changes: 5 additions & 0 deletions tests/Resources/Page/ODH/JupyterHub/JupyterLabLauncher.robot
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ Maybe Close Popup
# Check if the last button is always the confirmation one
# Server unavailable or unreachable modal has "Dismiss" as last button

# When first loading the JL interface, the popup might take some time to appear (1/2s)
# Given the speed up in PR #559 this has become a problem for this keyword, with some popups
# slipping through. Let's add a small sleep here to try and catch all popups.
Sleep 0.5s

# Sometimes there are multiple tabs already open when loggin into the server and each one might
# Open a pop-up. Closing all tabs at once also might create a pop-up for each tab. Let's get the
# Number of open tabs and try closing popups for each one.
Expand Down
6 changes: 4 additions & 2 deletions tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ${NOTIFICATION_DRAWER_CLOSE_BTN}= //div[@class="pf-c-drawer__panel"]/div/div//b
${NOTIFICATION_DRAWER_CLOSED}= //div[@class="pf-c-drawer__panel" and @hidden=""]
${GROUPS_CONFIG_CM}= groups-config
${RHODS_GROUPS_CONFIG_CM}= rhods-groups-config
${RHODS_LOGO_XPATH}= //img[@alt="Red Hat OpenShift Data Science Logo"]


*** Keywords ***
Expand Down Expand Up @@ -75,8 +76,9 @@ Logout From RHODS Dashboard
Wait Until Page Contains Log in with OpenShift

Wait for RHODS Dashboard to Load
[Arguments] ${dashboard_title}="Red Hat OpenShift Data Science"
Wait For Condition return document.title == ${dashboard_title} timeout=15
[Arguments] ${dashboard_title}="Red Hat OpenShift Data Science"
Wait For Condition return document.title == ${dashboard_title} timeout=15s
Wait Until Page Contains Element xpath:${RHODS_LOGO_XPATH} timeout=15s

Wait Until RHODS Dashboard ${dashboard_app} Is Visible
# Ideally the timeout would be an arg but Robot does not allow "normal" and "embedded" arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ CleanUp JupyterHub And Close All Browsers
Test Setup For Matrics Web Test
[Documentation] Opens openshift console metrics for metrics test
Set Library Search Order SeleniumLibrary
Open Browser ${OCP_CONSOLE_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Open OCP Console
Login To OCP
Wait Until OpenShift Console Is Loaded
Click Button Observe
Expand Down Expand Up @@ -154,7 +154,7 @@ Run OpenShift Metrics Query
... belong to a group with "view" role in OpenShift
... Example command to assign the role: oc adm policy add-cluster-role-to-group view rhods-admins
[Arguments] ${query} ${retry_attempts}=10 ${return_zero_if_result_empty}=False
Open Browser ${OCP_CONSOLE_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Open OCP Console
LoginPage.Login To Openshift ${OCP_ADMIN_USER.USERNAME} ${OCP_ADMIN_USER.PASSWORD} ${OCP_ADMIN_USER.AUTH_TYPE}
OCPMenu.Switch To Administrator Perspective

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ Check Cluster Name Contain "Aisrhods" Or Not
Check Particular Text Is Present In Rhods-operator's Log
[Documentation] Check if text is present in log
[Arguments] ${text_to_check}
Open Browser ${OCP_CONSOLE_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Open OCP Console
Login To Openshift ${OCP_ADMIN_USER.USERNAME} ${OCP_ADMIN_USER.PASSWORD} ${OCP_ADMIN_USER.AUTH_TYPE}
Maybe Skip Tour
${val_result}= Get Pod Logs From UI namespace=redhat-ods-operator
Expand Down
8 changes: 4 additions & 4 deletions tests/Tests/500__jupyterhub/test-jupyterlab-time.robot
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ Spawn and Stop Server
Run Keyword And Return Status Wait Until JupyterHub Spawner Is Ready
${time1} = Get Time format=%H:%M:%S.%f
Spawn Notebook
Run Keyword And Continue On Failure Wait Until Page Does Not Contain Element
... id:progress-bar timeout=600s
#Wait For JupyterLab Splash Screen timeout=30
Run Keyword And Warn On Failure Login To Openshift ${TEST_USER.USERNAME} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
${authorization_required} = Is Service Account Authorization Required
Run Keyword If ${authorization_required} Authorize jupyterhub service account
Wait Until Page Contains Element xpath://div[@id="jp-top-panel"] timeout=60s
# If this fails we waited for 60s. Avg. time will be thrown off, might be acceptable
# given that we weren't able to spawn?
Run Keyword And Continue On Failure Wait Until Page Contains Element xpath://div[@id="jp-top-panel"] timeout=60s
${time2} = Get Time
${time} = Subtract Date From Date ${time2} ${time1}
Sleep 0.5s
Stop JupyterLab Notebook Server
Go To ${ODH_DASHBOARD_URL}
Wait For RHODS Dashboard To Load
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/500__jupyterhub/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Force Tags JupyterHub
*** Test Cases ***
Logged into OpenShift
[Tags] Sanity Smoke ODS-127
Open Browser ${OCP_CONSOLE_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Open OCP Console
Login To Openshift ${TEST_USER.USERNAME} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
Wait Until OpenShift Console Is Loaded

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Verify Pachyderm Pipeline Can Be Created
Pachyderm Suite Setup
Set Library Search Order SeleniumLibrary
RHOSi Setup
Open Browser ${OCP_CONSOLE_URL} browser=${BROWSER.NAME} options=${BROWSER.OPTIONS}
Open OCP Console
Login to OCP
Wait Until OpenShift Console Is Loaded
Check And Install Operator in Openshift ${pachyderm_container_name} ${pachyderm_appname}
Expand Down

0 comments on commit 8a1e223

Please sign in to comment.