Skip to content

Commit

Permalink
Add test for Log Out options in workbenches (#679)
Browse files Browse the repository at this point in the history
* add ODS-1971

Signed-off-by: bdattoma <[email protected]>

* fix comments

Signed-off-by: bdattoma <[email protected]>

* fix robocop alerts

Signed-off-by: bdattoma <[email protected]>

Signed-off-by: bdattoma <[email protected]>
  • Loading branch information
bdattoma authored Jan 24, 2023
1 parent cd70161 commit 11e1931
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 31 deletions.
10 changes: 10 additions & 0 deletions tests/Resources/Page/LoginPage.robot
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ Login To Openshift
Input Text id=inputPassword ${ocp_user_pw}
Click Element xpath=/html/body/div/div/main/div/form/div[4]/button
Maybe Skip Tour

Log In Should Be Requested
[Documentation] Passes if the login page appears and fails otherwise
${present} = Is OpenShift Login Visible
IF ${present} == ${FALSE} Fail msg=Log in page did not appear as expected

Log In Should Not Be Requested
[Documentation] Fails if the login page appears and passes otherwise
${present} = Is OpenShift Login Visible
IF ${present} == ${TRUE} Fail msg=Log in page did not appear as expected
3 changes: 1 addition & 2 deletions tests/Resources/Page/ODH/JupyterHub/JupyterLabLauncher.robot
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ Start JupyterLab Notebook Server

Open JupyterLab Control Panel
Open With JupyterLab Menu File Hub Control Panel
#Switch Window JupyterHub
SeleniumLibrary.Switch Window NEW

Stop JupyterLab Notebook Server
Open JupyterLab Control Panel
SeleniumLibrary.Switch Window NEW
Handle Control Panel

Logout JupyterLab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,19 @@ Wait Until Workbench Is Stopped From Projects Home Page
Wait Until Keyword Succeeds ${timeout} 5s Workbench Status Should Be From Projects Home Page
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_STOPPED} project_title=${project_title}

Launch Workbench From Projects Home Page
Launch And Access Workbench From Projects Home Page
[Documentation] Launches a running workbench from DS Projects home page.
[Arguments] ${workbench_title} ${project_title}
[Arguments] ${workbench_title} ${project_title} ${username}=${TEST_USER_3.USERNAME}
... ${password}=${TEST_USER_3.PASSWORD} ${auth_type}=${TEST_USER_3.AUTH_TYPE}
${is_started}= Run Keyword And Return Status Workbench Status Should Be From Projects Home Page
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_RUNNING} project_title=${project_title}
IF ${is_started} == ${TRUE}
Click Element xpath=//tr[td/div/a[text()="${project_title}"]]/td//a[text()="${workbench_title}"]
Access To Workbench
Switch Window NEW
Access To Workbench username=${username} password=${password}
... auth_type=${auth_type}
ELSE
Fail msg=Cannot launch workbench ${workbench_title} because it is not running...
Fail msg=Cannot Launch And Access Workbench ${workbench_title} because it is not running...
END

Workbench Launch Link Should Be Disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Create Workbench
... the DS Project data. It allows to add new or existent PV storage,
... add Environment variables and select Jupyter image
[Arguments] ${workbench_title} ${workbench_description} ${prj_title} ${image_name} ${deployment_size}
... ${storage} ${pv_existent} ${pv_name} ${pv_description} ${pv_size}
... ${storage} ${pv_existent} ${pv_name} ${pv_description} ${pv_size}
... ${press_cancel}=${FALSE} ${envs}=${NONE}
Click Element ${WORKBENCH_CREATE_BTN_XP}
Wait Until Page Contains Element ${WORKBENCH_NAME_INPUT_XP}
Expand Down Expand Up @@ -95,7 +95,7 @@ Add Environment Variables In Workbench
${n_pairs}= Get Length ${env_variable.keys()}
FOR ${pair_idx} ${key} ${value} IN ENUMERATE &{env_variable}
Log ${pair_idx}-${key}-${value}
Run Keyword And Continue On Failure Wait Until Page Contains Element
Run Keyword And Continue On Failure Wait Until Page Contains Element
... xpath=//input[@aria-label="key of item ${pair_idx}"]
Input Text ${ENV_VARIABLES_SECTION_XP}/div[@class="pf-l-split"][${idx}]//input[@aria-label="key of item ${pair_idx}"]
... ${key}
Expand All @@ -119,7 +119,7 @@ Select Environment Variable Types
Click Element ${ENV_VARIABLES_SECTION_XP}/div[@class="pf-l-split"][${variable_index}]//div[contains(@class,"pf-c-select")]/button
Wait Until Page Contains Element xpath=//ul[@role="listbox"]/li/button[text()="${k8s_type}"]
Click Element xpath=//ul[@role="listbox"]/li/button[text()="${k8s_type}"]
Run Keyword And Continue On Failure
Run Keyword And Continue On Failure
... Wait Until Page Contains Element ${ENV_VARIABLES_SECTION_XP}//button[div/span[text()="Select one"]]
Click Element ${ENV_VARIABLES_SECTION_XP}/div[@class="pf-l-split"][${variable_index}]//button[div/span[text()="Select one"]]
Wait Until Page Contains Element xpath=//ul[@role="listbox"]/li/button[text()="${input_type}"]
Expand All @@ -135,7 +135,7 @@ Remove All Environment Variables
Select An Existent PV
[Documentation] Selects an existent PV Storage in the workbench creation page
[Arguments] ${name}
Run Keyword And Continue On Failure
Run Keyword And Continue On Failure
... Wait Until Element Is Enabled xpath=//input[@placeholder="Select a persistent storage"]
Click Element xpath=//input[@placeholder="Select a persistent storage"]
Wait Until Page Contains Element xpath=//ul/li/button[text()="${name}"]
Expand All @@ -161,22 +161,22 @@ Select Workbench Container Size
Workbench Should Be Listed
[Documentation] Checks a workbench is listed in the DS Project details page
[Arguments] ${workbench_title}
Run keyword And Continue On Failure
... Wait Until Page Contains Element
Run keyword And Continue On Failure
... Wait Until Page Contains Element
... ${WORKBENCH_SECTION_XP}//td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]

Workbench Should Not Be Listed
[Documentation] Checks a workbench is not listed in the DS Project details page
[Arguments] ${workbench_title}
Run keyword And Continue On Failure
... Wait Until Page Does Not Contain Element
Run keyword And Continue On Failure
... Wait Until Page Does Not Contain Element
... ${WORKBENCH_SECTION_XP}//td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]

Workbench Status Should Be
[Documentation] Checks a workbench status is the expected one in the DS Project details page
[Arguments] ${workbench_title} ${status}
Run keyword And Continue On Failure
... Page Should Contain Element
Run keyword And Continue On Failure
... Page Should Contain Element
... ${WORKBENCH_SECTION_XP}//tr[td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]]/td[@data-label="Status"]//p[text()="${status}"]

Status Error Icon Should Appear
Expand All @@ -192,13 +192,13 @@ Status Error Icon Should Appear
Wait Until Workbench Is Started
[Documentation] Waits until workbench status is "RUNNING" in the DS Project details page
[Arguments] ${workbench_title} ${timeout}=40s
Wait Until Keyword Succeeds ${timeout} 5s Workbench Status Should Be
Wait Until Keyword Succeeds ${timeout} 5s Workbench Status Should Be
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_RUNNING}

Start Workbench
[Documentation] Starts a workbench from the DS Project details page
[Arguments] ${workbench_title}
${is_stopped}= Run Keyword And Return Status Workbench Status Should Be
${is_stopped}= Run Keyword And Return Status Workbench Status Should Be
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_STOPPED}
IF ${is_stopped} == ${TRUE}
Click Element ${WORKBENCH_SECTION_XP}//tr[td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]]/td[@data-label="Status"]//span[@class="pf-c-switch__toggle"]
Expand All @@ -209,30 +209,37 @@ Start Workbench

Access To Workbench
[Documentation] Gets access to a workbench from DS Project details page after it got launched
[Arguments] ${username}=${TEST_USER.USERNAME} ${password}=${TEST_USER.PASSWORD} ${auth_type}=${TEST_USER.AUTH_TYPE}
Switch Window NEW
[Arguments] ${username} ${password} ${auth_type}
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
Wait Until Page Contains Element xpath://div[@id="jp-top-panel"] timeout=60s
Maybe Close Popup

Launch Workbench
Launch And Access Workbench
[Documentation] Launches a workbench from DS Project details page
[Arguments] ${workbench_title}
${is_started}= Run Keyword And Return Status Workbench Status Should Be
[Arguments] ${workbench_title} ${username}=${TEST_USER_3.USERNAME}
... ${password}=${TEST_USER_3.PASSWORD} ${auth_type}=${TEST_USER_3.AUTH_TYPE}
${is_started}= Run Keyword And Return Status Workbench Status Should Be
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_RUNNING}
IF ${is_started} == ${TRUE}
Click Link ${WORKBENCH_SECTION_XP}//tr[td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]]/td//a[text()="Open"]
Access To Workbench
Open Workbench workbench_title=${workbench_title}
Access To Workbench username=${username} password=${password}
... auth_type=${auth_type}
ELSE
Fail msg=Cannot launch workbench ${workbench_title} because it is not running...
Fail msg=Cannot Launch And Access Workbench ${workbench_title} because it is not running...
END

Open Workbench
[Documentation] Clicks on "open" link for a given workbench
[Arguments] ${workbench_title}
Click Link ${WORKBENCH_SECTION_XP}//tr[td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]]/td//a[text()="Open"]
Switch Window NEW

Stop Workbench
[Documentation] Stops a workbench from DS Project details page
[Arguments] ${workbench_title} ${press_cancel}=${FALSE}
${is_started}= Run Keyword And Return Status Workbench Status Should Be
${is_started}= Run Keyword And Return Status Workbench Status Should Be
... workbench_title=${workbench_title} status=${WORKBENCH_STATUS_RUNNING}
IF ${is_started} == ${TRUE}
Click Element ${WORKBENCH_SECTION_XP}//tr[td[@data-label="Name"]/h4[div[text()="${workbench_title}"]]]/td[@data-label="Status"]//span[@class="pf-c-switch__toggle"]
Expand All @@ -246,7 +253,7 @@ Handle Stop Workbench Confirmation Modal
[Documentation] Handles modal to stop workbench
[Arguments] ${press_cancel}=${FALSE}
Run Keyword And Continue On Failure Page Should Contain Stop workbench?
Run Keyword And Continue On Failure
Run Keyword And Continue On Failure
... Page Should Contain Are you sure you want to stop the workbench? Any changes without saving will be erased.
Run Keyword And Continue On Failure Page Should Contain To save changes, access your workbench
Run Keyword And Continue On Failure Page Should Contain Element xpath=//input[@id="dont-show-again"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ Verify User Can Launch A Workbench
${ns_name}= Get Openshift Namespace From Data Science Project project_title=${PRJ_TITLE}
Open Data Science Project Details Page project_title=${PRJ_TITLE}
Start Workbench workbench_title=${WORKBENCH_2_TITLE}
Launch Workbench workbench_title=${WORKBENCH_2_TITLE}
Launch And Access Workbench workbench_title=${WORKBENCH_2_TITLE}
... username=${TEST_USER_3.USERNAME} password=${TEST_USER_3.PASSWORD}
... auth_type=${TEST_USER_3.AUTH_TYPE}
Check Launched Workbench Is The Correct One workbench_title=${WORKBENCH_2_TITLE}
... image=${NB_IMAGE} namespace=${ns_name}

Expand Down Expand Up @@ -270,7 +272,9 @@ Verify User Can Start And Launch A Workbench From Projects Home Page
... namespace=${ns_name}
Start Workbench From Projects Home Page workbench_title=${WORKBENCH_2_TITLE} project_title=${PRJ_TITLE}
... workbench_cr_name=${workbench_cr_name} namespace=${ns_name}
Launch Workbench From Projects Home Page workbench_title=${WORKBENCH_2_TITLE} project_title=${PRJ_TITLE}
Launch And Access Workbench From Projects Home Page workbench_title=${WORKBENCH_2_TITLE}
... project_title=${PRJ_TITLE} username=${TEST_USER_3.USERNAME}
... password=${TEST_USER_3.PASSWORD} auth_type=${TEST_USER_3.AUTH_TYPE}
Check Launched Workbench Is The Correct One workbench_title=${WORKBENCH_2_TITLE}
... image=${NB_IMAGE} namespace=${ns_name}

Expand Down Expand Up @@ -324,9 +328,39 @@ Verify User Can Create A Workbench With Environment Variables
... pv_description=${NONE} pv_size=${NONE}
... press_cancel=${FALSE} envs=${envs_list}
Wait Until Workbench Is Started workbench_title=${WORKBENCH_4_TITLE}
Launch Workbench workbench_title=${WORKBENCH_4_TITLE}
Launch And Access Workbench workbench_title=${WORKBENCH_4_TITLE}
... username=${TEST_USER_3.USERNAME} password=${TEST_USER_3.PASSWORD}
... auth_type=${TEST_USER_3.AUTH_TYPE}
Check Environment Variables Exist exp_env_variables=${envs_list}

Verify User Can Log Out And Return To Project From Jupyter Notebook # robocop: disable
[Tags] Sanity Tier1 ODS-1971
[Documentation] Verifies user can log out and return to the project from Jupyter notebook.
... Users have 2 options:
... 1. click "File" > "Log Out" to actually close the login session
... 2. click "File" > "Hub Control Panel" to return to project details page
Open Data Science Project Details Page project_title=${PRJ_TITLE}
Open Workbench workbench_title=${WORKBENCH_4_TITLE}
Run Keyword And Continue On Failure
... Log In Should Be Requested
Access To Workbench username=${TEST_USER_3.USERNAME} password=${TEST_USER_3.PASSWORD}
... auth_type=${TEST_USER_3.AUTH_TYPE}
Open JupyterLab Control Panel
Wait Until Project Is Open project_title=${PRJ_TITLE}
Workbench Status Should Be workbench_title=${WORKBENCH_4_TITLE}
... status=${WORKBENCH_STATUS_RUNNING}
Open Workbench workbench_title=${WORKBENCH_4_TITLE}
Run Keyword And Continue On Failure
... Log In Should Not Be Requested
Wait Until JupyterLab Is Loaded
Logout JupyterLab
Wait Until Project Is Open project_title=${PRJ_TITLE}
Workbench Status Should Be workbench_title=${WORKBENCH_4_TITLE}
... status=${WORKBENCH_STATUS_RUNNING}
Open Workbench workbench_title=${WORKBENCH_4_TITLE}
Run Keyword And Continue On Failure
... Log In Should Be Requested

Verify Event Log Is Accessible While Starting A Workbench
[Tags] Tier1 Sanity
... ODS-1970
Expand Down

0 comments on commit 11e1931

Please sign in to comment.