Skip to content

Commit

Permalink
Automate tests for Elyra Pipelines in Workbenches (#766)
Browse files Browse the repository at this point in the history
Automate tests for Elyra Pipelines in Workbenches
  • Loading branch information
lugi0 authored Jun 26, 2023
1 parent 951b06a commit 6d65b90
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 26 deletions.
142 changes: 142 additions & 0 deletions ods_ci/tests/Resources/Page/ODH/JupyterHub/Elyra.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
*** Settings ***
Documentation Keywords to interact with Elyra in JupyterLab

*** Variables ***
${SVG_CANVAS} = //*[name()="svg" and @class="svg-area"]
${SVG_INTERACTABLE} = /*[name()="g" and @class="d3-canvas-group"]
${SVG_PIPELINE_NODES} = /*[name()="g" and @class="d3-nodes-links-group"]
${SVG_SINGLE_NODE} = /*[name()="g" and contains(@class, "d3-draggable")]
${PROPERTIES_PANEL_BTN} = //div[@class="toolbar-right-bar"]//button[@class="bx--btn bx--btn--ghost"]
${ELYRA_DIALOG} = //form[@class="elyra-dialog-form"]
${ELYRA_RUNTIME_PLATFORM} = //select[@id="runtime_platform"]
${ELYRA_PIPELINE_NAME} = //input[@id="pipeline_name"]
${ELYRA_RUNTIME_CONFIG} = //select[@id="runtime_config"]


*** Keywords ***
Maybe Migrate Pipeline
[Documentation] Outdated pipelines need to be migrated to the newer Elyra version
${popup} = Run Keyword And Return Status Page Should Contain Element //div[.="Migrate pipeline?"]
IF ${popup}==True
Click Element //button[.="OK"]
Save Pipeline Changes
END

# This functionality is currently bugged, disabling the keyword for the time being
# Set Runtime Image In Pipeline Properties
# [Documentation] Sets a default runtime image for the pipeline (currently bugged)
# [Arguments] ${runtime_image}=Datascience with Python 3.8 (UBI8)
# Open Properties Panel
# Click Element xpath=//div[.="Pipeline Properties"]
# Wait Until Page Contains Element xpath=//div[@id="root_pipeline_defaults_runtime_image"]
# Click Element xpath=//select[@id="root_pipeline_defaults_runtime_image"]
# Click Element xpath=//option[.="${runtime_image}"]
# Close Properties Panel
# Save Pipeline Changes

Open Properties Panel
[Documentation] Opens the Pipeline/Node properties panel (if closed)
${panel_open} = Run Keyword And Return Status Page Should Contain Element
... xpath=//div[.="Pipeline Properties"]
IF ${panel_open}==False
Click Element xpath=${PROPERTIES_PANEL_BTN}
Wait Until Page Contains Element xpath=//div[.="Pipeline Properties"]
END

Close Properties Panel
[Documentation] Closes the Pipeline/Node properties panel (if open)
${panel_open} = Run Keyword And Return Status Page Should Contain Element
... xpath=//div[.="Pipeline Properties"]
IF ${panel_open}==True
Click Element xpath=${PROPERTIES_PANEL_BTN}
Wait Until Page Does Not Contain Element xpath=//div[.="Pipeline Properties"]
END

Save Pipeline Changes
[Documentation] Saves changes to the pipeline
Click Element xpath=//div[contains(@class, 'save-action')]/button
Wait Until Page Contains Saving started
Wait Until Page Contains Saving completed

Run Pipeline
[Documentation] Submits the pipeline for a run
[Arguments] ${runtime_config}=Data Science Pipeline ${pipeline_name}=hello-generic-world
Click Run Button
Set Pipeline Name ${pipeline_name}
Select Runtime Config ${runtime_config}
Click Element xpath=//button[.="OK"]

Click Run Button
[Documentation] Click the `Run` button in Elyra
Click Element xpath=//button[@aria-label="Run Pipeline"]
Wait Until Page Contains Element xpath=${ELYRA_DIALOG}

# This selector has been removed, leaving the keyword here in case it is added back in
# Select Runtime Platform
# [Documentation] Selects the runtime platform when submitting a pipeline run
# [Arguments] ${runtime_platform}
# Wait Until Page Contains Element xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_PLATFORM}
# Click Element xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_PLATFORM}
# Click Element
# ... xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_PLATFORM}/option[@value="${runtime_platform}"]

Set Pipeline Name
[Documentation] Changes the pipeline name when submitting it to be run, if the name is different from the default
[Arguments] ${pipeline_name}
Wait Until Page Contains Element xpath=${ELYRA_DIALOG}${ELYRA_PIPELINE_NAME}
${current_name} = Get Element Attribute xpath=${ELYRA_DIALOG}${ELYRA_PIPELINE_NAME}
... value
IF "${pipeline_name}" != "${current_name}"
Input Text xpath=${ELYRA_DIALOG}${ELYRA_PIPELINE_NAME} ${pipeline_name}
END

Select Runtime Config
[Documentation] Selects the runtime config when submitting a pipeline run
[Arguments] ${runtime_config}=test
Wait Until Page Contains Element xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_CONFIG}
Click Element xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_CONFIG}
Click Element
... xpath=${ELYRA_DIALOG}${ELYRA_RUNTIME_CONFIG}/option[.="${runtime_config}"]

Get Pipeline Run Name
[Documentation] Gets the run ID after a pipeline is successfully submitted
${job_id} = Get Text xpath=//a[.="Run Details."]/../p
${job_id} = Fetch From Right ${job_id} /
${job_id} = Fetch From Left ${job_id} working directory
${job_id} = Strip String ${job_id}
RETURN ${job_id}

Switch To Pipeline Execution Page
[Documentation] Moves to the Kubeflow Pipelines page for the details of a pipeline run
Click Element xpath=//a[.="Run Details."]
${handle} = Switch Window NEW
${oauth_prompt_visible} = Is OpenShift OAuth Login Prompt Visible
IF ${oauth_prompt_visible} Click Button Log in with OpenShift
${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
RETURN ${handle}

Set Runtime Image In All Nodes
[Documentation] Sets the runtime image in the properties of all nodes of a pipeline
[Arguments] ${runtime_image}=Datascience with Python 3.8 (UBI8)
@{tmp} = Get WebElements xpath=${SVG_CANVAS}${SVG_INTERACTABLE}${SVG_PIPELINE_NODES}${SVG_SINGLE_NODE}
FOR ${index} ${node} IN ENUMERATE @{tmp}
@{nodes} = Get WebElements xpath=${SVG_CANVAS}${SVG_INTERACTABLE}${SVG_PIPELINE_NODES}${SVG_SINGLE_NODE}
Log ${nodes}[${index}]
Set Runtime Image In Node Properties ${nodes}[${index}] ${runtime_image}
END

Set Runtime Image In Node Properties
[Documentation] Sets the runtime image in the properties of a pipeline node
[Arguments] ${node} ${runtime_image}=Datascience with Python 3.8 (UBI8)
Click Element ${node}
Open Properties Panel
Click Element xpath=//div[@title="Edit node properties"]
Wait Until Page Contains Element xpath=//div[@id="root_component_parameters_runtime_image"]
Click Element xpath=//select[@id="root_component_parameters_runtime_image"]
Click Element xpath=//option[.="${runtime_image}"]
Close Properties Panel
Save Pipeline Changes
19 changes: 14 additions & 5 deletions ods_ci/tests/Resources/Page/ODH/JupyterHub/JupyterHubSpawner.robot
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@ Select Notebook Image
ELSE IF "${version}"=="previous"
Verify Version Dropdown Is Present ${notebook_image}
Click Element xpath=${KFNBC_IMAGE_ROW}/../..//button[.="Versions"]
Click Element xpath=${KFNBC_IMAGE_DROPDOWN}//span[contains(text(), "Python v${PREVIOUS_PYTHON_VER}")]/../input
Click Element
... xpath=${KFNBC_IMAGE_DROPDOWN}//span[contains(text(), "Python v${PREVIOUS_PYTHON_VER}")]/../input
ELSE
Log To Console Unknown image version requested
Fail Unknown image version requested
Verify Version Dropdown Is Present ${notebook_image}
Click Element xpath=${KFNBC_IMAGE_ROW}/../..//button[.="Versions"]
Sleep 5s
${tag_exists} = Run Keyword And Return Status Page Should Contain Element
... xpath=${KFNBC_IMAGE_DROPDOWN}//input[@data-id="${notebook_image}:${version}"]
IF ${tag_exists}==True
Click Element xpath=${KFNBC_IMAGE_DROPDOWN}//input[@data-id="${notebook_image}:${version}"]
ELSE
Log To Console Unknown image version requested
Fail Unknown image version requested
END
END

Verify Version Dropdown Is Present
Expand Down Expand Up @@ -309,8 +319,7 @@ Spawned Image Check
ELSE IF "${version}"=="previous"
Python Version Check expected_version=${PREVIOUS_PYTHON_VER}
ELSE
Log To Console Unknown image version requested
Fail Unknown image version requested
Log To Console Unknown Tag, Cannot Check Python Version
END
Open With JupyterLab Menu Edit Select All Cells
Open With JupyterLab Menu Edit Delete Cells
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,26 @@ Verify Pipeline Server Deployments # robocop: disable
Verify Deployment ${db} 1 1 ${containerNames}
@{all_pods}= Oc Get kind=Pod namespace=${namespace}
Run Keyword And Continue On Failure Length Should Be ${all_pods} 4

Wait Until Pipeline Server Is Deployed
[Documentation] Waits until all the expected pods of the pipeline server
... are running
[Arguments] ${project_title}
Wait Until Keyword Succeeds 10 times 10s
... Verify Pipeline Server Deployments project_title=${project_title}

Verify Successful Pipeline Run Via Project UI
[Documentation] Validates that a given pipeline run in a given pipeline is in successful end state
... In the DS Project view of a given project
[Arguments] ${pipeline_run_name} ${pipeline_name} ${project_name}
Open Data Science Project Details Page ${project_name}
Wait Until Pipeline Last Run Is Started pipeline_name=${pipeline_name}
... timeout=10s
Wait Until Pipeline Last Run Is Finished pipeline_name=${pipeline_name}
... timeout=180s
Pipeline Last Run Should Be pipeline_name=${pipeline_name}
... run_name=${pipeline_run_name}
Pipeline Last Run Status Should Be pipeline_name=${pipeline_name}
... status=Completed
Pipeline Run Should Be Listed name=${pipeline_run_name}
... pipeline_name=${pipeline_name}
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,18 @@ Delete Data Science Projects From CLI
... It expects to receive a list of project (i.e,${ocp_projects}) as argument
[Arguments] ${ocp_projects}
FOR ${displayed_name} IN @{ocp_projects}
${version_check}= Is RHODS Version Greater Or Equal Than 1.20.0
IF ${version_check}==True
${project_k8s_name}= Run oc get projects -o json | jq '.items[] | select((.metadata.annotations."openshift.io/display-name" != null) and (.metadata.labels."opendatahub.io/dashboard"=="true") and (.metadata.annotations."openshift.io/display-name"=="${displayed_name}")) | .metadata.name' # robocop: disable
ELSE
${dp_with_suffix}= Set Variable ${displayed_name}\[DSP]
${project_k8s_name}= Run oc get projects -o json | jq '.items[] | select((.metadata.annotations."openshift.io/display-name" != null) and (.metadata.annotations."openshift.io/display-name"=="${dp_with_suffix}")) | .metadata.name' # robocop: disable
END
${project_k8s_name}= Run oc get projects -o json | jq '.items[] | select((.metadata.annotations."openshift.io/display-name" != null) and (.metadata.labels."opendatahub.io/dashboard"=="true") and (.metadata.annotations."openshift.io/display-name"=="${displayed_name}")) | .metadata.name' # robocop: disable
${project_k8s_name}= Replace String ${project_k8s_name} " ${EMPTY}
IF "${project_k8s_name}" == "${EMPTY}"
Log msg=There is probably no DS Projects with Diplay Name equal to ${displayed_name}
Continue For Loop
ELSE
Oc Delete kind=Project name=${project_k8s_name}
WHILE ${TRUE}
${exists} = Run And Return Rc oc get project ${project_k8s_name}
IF "${exists}" == "1" BREAK
Sleep 5s reason=let's not overload the API
END
END
END

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ${WORKBENCH_NAME_INPUT_XP}= xpath=//input[@name="workbench-name"]
${WORKBENCH_DESCR_TXT_XP}= xpath=//textarea[@name="workbench-description"]
${WORKBENCH_IMAGE_MENU_BTN_XP}= xpath=//section[@id="notebook-image"]//button[@aria-label="Options menu"]
${WORKBENCH_IMAGE_ITEM_BTN_XP}= xpath=//ul[@id="workbench-image-stream-selection"]/li/button
${WORKBENCH_IMAGE_ITEM_SPAN_XP}= xpath=//ul[@id="workbench-image-stream-selection"]/li//span
${WORKBENCH_SIZE_MENU_BTN_XP}= xpath=//section[@id="deployment-size"]//button[@aria-label="Options menu"]
${WORKBENCH_SIZE_ITEM_BTN_XP}= xpath=//ul[@data-id="container-size-select"]/li/button
${WORKBENCH_GPU_MENU_BTN_XP}= xpath=//section[@id="deployment-size"]//button[contains(@aria-labelledby,"gpu-numbers")] # robocop: disable
Expand Down Expand Up @@ -157,14 +158,19 @@ Select Workbench Jupyter Image
[Arguments] ${image_name} ${version}=default
Wait Until Page Contains Element ${WORKBENCH_IMAGE_MENU_BTN_XP}
Click Button ${WORKBENCH_IMAGE_MENU_BTN_XP}
Wait Until Page Contains Element ${WORKBENCH_IMAGE_ITEM_BTN_XP}\[text()="${image_name}"] timeout=10s
Click Element ${WORKBENCH_IMAGE_ITEM_BTN_XP}\[text()="${image_name}"]
IF "${version}"=="default"
Verify Version Selection Dropdown
ELSE IF "${version}"=="previous"
Select Workbench Image Version ${version}
IF "${image_name}"=="TrustyAI"
Wait Until Page Contains Element ${WORKBENCH_IMAGE_ITEM_SPAN_XP}\[text()="TrustyAI"]/.. timeout=10s
Click Element ${WORKBENCH_IMAGE_ITEM_SPAN_XP}\[text()="TrustyAI"]/..
ELSE
Fail ${version} does not exist, use default/previous
Wait Until Page Contains Element ${WORKBENCH_IMAGE_ITEM_BTN_XP}\[text()="${image_name}"] timeout=10s
Click Element ${WORKBENCH_IMAGE_ITEM_BTN_XP}\[text()="${image_name}"]
IF "${version}"=="default"
Verify Version Selection Dropdown
ELSE IF "${version}"=="previous"
Select Workbench Image Version ${version}
ELSE
Fail ${version} does not exist, use default/previous
END
END

Verify Version Selection Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Verify User Can Create And Run A DS Pipeline From DS Project Details Page # r
... ODS-2206
Create Pipeline Server dc_name=${DC_NAME}
... project_title=${PRJ_TITLE}
Wait Until Pipeline Server Is Deployed
Wait Until Pipeline Server Is Deployed project_title=${PRJ_TITLE}
Import Pipeline name=${PIPELINE_TEST_NAME}
... description=${PIPELINE_TEST_DESC}
... project_title=${PRJ_TITLE}
Expand Down Expand Up @@ -88,12 +88,6 @@ Pipelines Suite Teardown
Delete Data Science Projects From CLI ocp_projects=${PROJECTS_TO_DELETE}
RHOSi Teardown

Wait Until Pipeline Server Is Deployed
[Documentation] Waits until all the expected pods of the pipeline server
... are running
Wait Until Keyword Succeeds 10 times 10s
... Verify Pipeline Server Deployments project_title=${PRJ_TITLE}

Verify Pipeline Run Deployment Is Successful # robocop: disable
[Documentation] Verifies the correct deployment of the test pipeline run in the rhods namespace.
... It checks all the expected pods for the "iris" test pipeline run used in the TC.
Expand Down
Loading

0 comments on commit 6d65b90

Please sign in to comment.