Skip to content

Commit

Permalink
Fix custom image tests (#988)
Browse files Browse the repository at this point in the history
* fix custom image tests

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

* add local registry test

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

* add small sleep

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

* add sleep to wait for page load

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

* remove comments, add polarion

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

---------

Signed-off-by: Luca Giorgi <[email protected]>
  • Loading branch information
lugi0 authored Oct 31, 2023
1 parent f635baa commit 71b3e4b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 30 deletions.
43 changes: 27 additions & 16 deletions ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,12 @@ RHODS Notification Drawer Should Contain
[Documentation] Verifies RHODS Notifications contains given Message
[Arguments] ${message}
Click Element xpath=//*[contains(@class,'notification-badge')]
Wait Until Page Contains text=${message} timeout=300s
Run Keyword And Continue On Failure Wait Until Page Contains text=${message} timeout=10s
Close Notification Drawer

Open Notebook Images Page
[Documentation] Opens the RHODS dashboard and navigates to the Notebook Images page
Wait Until Page Contains Settings
Page Should Contain Settings
Menu.Navigate To Page Settings Notebook images
Wait Until Page Contains Notebook image settings
Expand All @@ -552,11 +553,12 @@ Import New Custom Image
[Arguments] ${repo} ${name} ${description} ${software} ${packages}
Sleep 1
Open Custom Image Import Popup
Input Text xpath://input[@id="notebook-image-repository-input"] ${repo}
Input Text xpath://input[@id="notebook-image-name-input"] ${name}
Input Text xpath://input[@id="notebook-image-description-input"] ${description}
Add Softwares To Custom Image ${software}
Add Packages To Custom Image ${packages}
Input Text xpath://input[@id="byon-image-repository-input"] ${repo}
Input Text xpath://input[@id="byon-image-name-input"] ${name}
Input Text xpath://input[@id="byon-image-description-input"] ${description}
# No button present anymore?
#Add Softwares To Custom Image ${software}
#Add Packages To Custom Image ${packages}
Click Element xpath://button[.="Import"]

Open Custom Image Import Popup
Expand All @@ -567,7 +569,7 @@ Open Custom Image Import Popup
ELSE
Click Element xpath://button[.="Import new image"]
END
Wait Until Page Contains Import Notebook images
Wait Until Page Contains Import notebook images

Add Softwares To Custom Image
[Documentation] Loops through a dictionary to add software to the custom img metadata
Expand Down Expand Up @@ -618,8 +620,8 @@ Delete Custom Image
[Documentation] Deletes a custom image through the dashboard UI.
... Needs an additional check on removed ImageStream
[Arguments] ${image_name}
Click Button xpath://td[.="${image_name}"]/../td[last()]//button
Click Element xpath://td[.="${image_name}"]/../td[last()]//button/..//li[@id="${image_name}-delete-button"]
Click Button xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[last()]//button
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[last()]//button/..//li[@id="${image_name}-delete-button"] # robocop: disable
Wait Until Page Contains Do you wish to permanently delete ${image_name}?
Click Button xpath://button[.="Delete"]

Expand Down Expand Up @@ -650,9 +652,10 @@ Verify Custom Image Description
[Documentation] Verifies that the description shown in the dashboard UI
... matches the given one
[Arguments] ${image_name} ${expected_description}
${exists} = Run Keyword And Return Status Page Should Contain Element xpath://td[.="${image_name}"]/../td[@data-label="Description"][.="${expected_description}"]
${exists} = Run Keyword And Return Status Page Should Contain Element
... xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="Description" and .="${expected_description}"] # robocop: disable
IF ${exists}==False
${desc} = Get Text xpath://td[.="${image_name}"]/../td[@data-label="Description"]
${desc} = Get Text xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="Description"]
Log Description for ${image_name} does not match ${expected_description} - Actual description is ${desc}
FAIL
END
Expand All @@ -662,7 +665,9 @@ Verify Custom Image Is Listed
[Documentation] Verifies that the custom image is displayed in the dashboard
... UI with the correct name
[Arguments] ${image_name}
${exists} = Run Keyword And Return Status Page Should Contain Element xpath://td[.="${image_name}"]
# whitespace after ${image_name} in the xpath is important!
Sleep 2s #wait for page to finish loading
${exists} = Run Keyword And Return Status Page Should Contain Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "] # robocop: disable
IF ${exists}==False
Log ${image_name} not visible in page
FAIL
Expand All @@ -673,9 +678,10 @@ Verify Custom Image Owner
[Documentation] Verifies that the user listed for an image in the dahsboard
... UI matches the given one
[Arguments] ${image_name} ${expected_user}
${exists} = Run Keyword And Return Status Page Should Contain Element xpath://td[.="${image_name}"]/../td[@data-label="User"][.="${expected_user}"]
${exists} = Run Keyword And Return Status Page Should Contain Element
... xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="User" and .="${expected_user}"] # robocop: disable
IF ${exists}==False
${user} = Get Text xpath://td[.="${image_name}"]/../td[@data-label="User"]
${user} = Get Text xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="User"] # robocop: disable
Log User for ${image_name} does not match ${expected_user} - Actual user is ${user}
FAIL
END
Expand All @@ -686,19 +692,24 @@ Enable Custom Image
[Arguments] ${image_name}
${is_enabled} = # Need to find a check
IF ${is_enabled}==False
Click Element xpath://td[.="${image_name}"]/..//input
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../..//input
END

Disable Custom Image
[Documentation] Disables a custom image (i.e. not displayed in JH) [WIP]
[Arguments] ${image_name}
${is_enabled} = # Need to find a check
IF ${is_enabled}==True
Click Element xpath://td[.="${image_name}"]/..//input
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../..//input
END

Close Notification Drawer
[Documentation] Closes the dashboard notification drawer, if it is open
# the notification popup could be present and prevent from closing the drawer, let's check and close if exists
${popup}= Run Keyword And Return Status Page Should Contain Element xpath://div[@aria-label="Danger Alert"]
IF ${popup}==True
Click Element xpath://div[@aria-label="Danger Alert"]//button[contains(@aria-label,"Close Danger alert")]
END
${closed}= Run Keyword And Return Status Page Should Contain Element ${NOTIFICATION_DRAWER_CLOSED}
IF ${closed}==False
Click Element ${NOTIFICATION_DRAWER_CLOSE_BTN}
Expand Down
45 changes: 31 additions & 14 deletions ods_ci/tests/Tests/500__jupyterhub/custom-image.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Force Tags JupyterHub
*** Variables ***
${YAML} = tests/Resources/Files/custom_image.yaml
${IMG_NAME} = custom-test-image
${IMG_URL} = quay.io/thoth-station/s2i-lab-elyra:v0.1.1
${IMG_URL} = quay.io/opendatahub-contrib/workbench-images:jupyter-datascience-c9s-py311_2023c_latest
${IMG_DESCRIPTION} = Testing Only This image is only for illustration purposes, and comes with no support. Do not use.
&{IMG_SOFTWARE} = Software1=x.y.z
&{IMG_PACKAGES} = elyra=2.2.4 foo-pkg=a.b.c
Expand All @@ -36,10 +36,10 @@ Verify Admin User Can Access Custom Notebook Settings
Verify Custom Image Can Be Added
[Documentation] Imports the custom image via UI
... Then loads the spawner and tries using the custom img
[Tags] Sanity Tier1
[Tags] Sanity Tier1 ExcludeOnDisconnected
... ODS-1208 ODS-1365
... ProductBug
Create Custom Image
Sleep 5s #wait a bit from IS to be created
Get ImageStream Metadata And Check Name
Verify Custom Image Is Listed ${IMG_NAME}
Verify Custom Image Description ${IMG_NAME} ${IMG_DESCRIPTION}
Expand All @@ -59,25 +59,27 @@ Verify Custom Image Can Be Added

Test Duplicate Image
[Documentation] Test adding two images with the same name (should fail)
[Tags] Sanity Tier1
[Tags] Sanity Tier1 ExcludeOnDisconnected
... ODS-1368
... ProductBug
Sleep 1
Create Custom Image
Sleep 1
Import New Custom Image ${IMG_URL} ${IMG_NAME} ${IMG_DESCRIPTION}
... software=${IMG_SOFTWARE}
... packages=${IMG_PACKAGES}
RHODS Notification Drawer Should Contain Unable to add notebook image ${IMG_NAME}
Run Keyword And Warn On Failure RHODS Notification Drawer Should Contain
... Unable to add notebook image ${IMG_NAME}
Sleep 1
Delete Custom Image ${IMG_NAME}
# If both imgs can be created they also have to be deleted twice
Sleep 2
Run Keyword And Continue On Failure Delete Custom Image ${IMG_NAME}
Reset Image Name

Test Bad Image URL
[Documentation] Test adding an image with a bad repo URL (should fail)
[Tags] Sanity Tier1
... ODS-1367
... ProductBug
${OG_URL}= Set Variable ${IMG_URL}
${IMG_URL}= Set Variable quay.io/RandomName/RandomImage:v1.2.3
Set Global Variable ${IMG_URL} ${IMG_URL}
Expand All @@ -92,18 +94,28 @@ Test Bad Image Import
... in the JH spawner page
[Tags] Sanity Tier1
... ODS-1364
... ProductBug
${OG_URL}= Set Variable ${IMG_URL}
${IMG_URL}= Set Variable randomstring
Set Global Variable ${IMG_URL} ${IMG_URL}
Create Custom Image
RHODS Notification Drawer Should Contain
... Unable to add notebook image ${IMG_NAME}

Test Image From Local registry
[Documentation] Try creating a custom image using a local registry URL (i.e. OOTB image)
[Tags] Sanity Tier1
... ODS-2470
Open Notebook Images Page
${local_url} = Get Standard Data Science Local Registry URL
${IMG_URL}= Set Variable ${local_url}
Set Suite Variable ${IMG_URL} ${IMG_URL}
Create Custom Image
Get ImageStream Metadata And Check Name
Verify Custom Image Is Listed ${IMG_NAME}
Verify Custom Image Owner ${IMG_NAME} ${TEST_USER.USERNAME}
Launch JupyterHub Spawner From Dashboard
# Imgs imported with a broken/wrong url will be disabled in the spawner
Element Should Be Disabled xpath://input[contains(@id, "${IMAGESTREAM_NAME}")]
${IMG_URL}= Set Variable ${OG_URL}
Set Global Variable ${IMG_URL} ${IMG_URL}
[Teardown] Custom Image Teardown cleanup=False
Spawn Notebook With Arguments image=${IMAGESTREAM_NAME} size=Small
[Teardown] Custom Image Teardown


*** Keywords ***
Expand Down Expand Up @@ -144,7 +156,6 @@ Create Custom Image
# Create a unique notebook name for this test run
${IMG_NAME} = Catenate ${IMG_NAME} ${curr_date}
Set Global Variable ${IMG_NAME} ${IMG_NAME}

Import New Custom Image ${IMG_URL} ${IMG_NAME} ${IMG_DESCRIPTION}
... software=${IMG_SOFTWARE} packages=${IMG_PACKAGES}

Expand All @@ -164,3 +175,9 @@ Reset Image Name
[Documentation] Helper to reset the global variable img name to default value
${IMG_NAME} = Set Variable custom-test-image
Set Global Variable ${IMG_NAME} ${IMG_NAME}

Get Standard Data Science Local Registry URL
[Documentation] Fetches the local URL for the SDS image
${registry} = Run oc get imagestream s2i-generic-data-science-notebook -n redhat-ods-applications -o json | jq '.status.dockerImageRepository' | sed 's/"//g' # robocop: disable
${tag} = Run oc get imagestream s2i-generic-data-science-notebook -n redhat-ods-applications -o json | jq '.status.tags[-1].tag' | sed 's/"//g' # robocop: disable
RETURN ${registry}:${tag}

0 comments on commit 71b3e4b

Please sign in to comment.