Skip to content

Commit

Permalink
[Fix] the tests for custom image import
Browse files Browse the repository at this point in the history
This fixes multiple tests in the custom image import and fixes some
common keywords from the ODHDashboard.robot file.
  • Loading branch information
jstourac committed Oct 11, 2024
1 parent 6729d5e commit b245342
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 33 deletions.
68 changes: 44 additions & 24 deletions ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot
Original file line number Diff line number Diff line change
Expand Up @@ -627,20 +627,30 @@ Remove Package From Custom Image
Click Button xpath://td[.="${package_name}"]/..//${CUSTOM_IMAGE_REMOVE_BTN}

Delete Custom Image
# Need to check if image is REALLY deleted
[Documentation] Deletes a custom image through the dashboard UI.
... Needs an additional check on removed ImageStream
[Arguments] ${image_name}
Click Button xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[last()]//button
${custom_image_kebab_btn}= Set Variable //td[.="${image_name}"]/../td[last()]//button
Click Button xpath:${custom_image_kebab_btn}
${image_name_id}= Replace String ${image_name} ${SPACE} -
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[last()]//button/..//button[@id="custom-${image_name_id}-delete-button"] # robocop: disable
Click Element xpath:${custom_image_kebab_btn}/..//button[@id="custom-${image_name_id}-delete-button"] # robocop: disable
Handle Deletion Confirmation Modal ${image_name} notebook image
# Wait for the image to disappear from the list
Wait Until Page Does Not Contain Element xpath:${custom_image_kebab_btn} timeout=10s
# Assure that the actual ImageStream is also removed
${rc} ${out}= Run And Return Rc And Output
... oc wait --for=delete --timeout=10s imagestream -n ${APPLICATIONS_NAMESPACE} custom-${image_name_id}
IF ${rc} != ${0}
Fail msg=The ImageStream 'custom-${image_name_id}' wasn't deleted from cluster in timeout.
END


Open Edit Menu For Custom Image
[Documentation] Opens the edit view for a specific custom image
[Arguments] ${image_name}
Click Button xpath://td[.="${image_name}"]/../td[last()]//button
Click Element xpath://td[.="${image_name}"]/../td[last()]//button/..//button[@id="${image_name}-edit-button"]
${custom_image_kebab_btn}= Set Variable //td[.="${image_name}"]/../td[last()]//button
Click Button xpath:${custom_image_kebab_btn}
${image_name_id}= Replace String ${image_name} ${SPACE} -
Click Element xpath:${custom_image_kebab_btn}/..//button[@id="custom-${image_name_id}-edit-button"]
Wait Until Page Contains Delete Notebook Image

Expand Custom Image Details
Expand All @@ -665,10 +675,11 @@ Verify Custom Image Description
[Documentation] Verifies that the description shown in the dashboard UI
... matches the given one
[Arguments] ${image_name} ${expected_description}
${custom_image_name_record}= Set Variable xpath://td[@data-label="Name"]/div/div/div[.="${image_name}"]
${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
... ${custom_image_name_record}/../../../../td[@data-label="Description" and .="${expected_description}"]
IF ${exists}==False
${desc}= Get Text xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="Description"]
${desc}= Get Text ${custom_image_name_record}/../../../../td[@data-label="Description"]
Log Description for ${image_name} does not match ${expected_description} - Actual description is ${desc}
FAIL
END
Expand All @@ -678,42 +689,51 @@ Verify Custom Image Is Listed
[Documentation] Verifies that the custom image is displayed in the dashboard
... UI with the correct name
[Arguments] ${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
END
RETURN ${exists}
${custom_image_name_record}= Set Variable xpath://td[@data-label="Name"]/div/div/div[.="${image_name}"]
Wait Until Page Contains Element ${custom_image_name_record} timeout=10s

Verify Custom Image Has Error Icon
[Documentation] Verifies that the custom image is displayed with the error icon
[Arguments] ${image_name}
${custom_image_name_record}= Set Variable xpath://td[@data-label="Name"]/div/div/div[.="${image_name}"]
Wait Until Page Contains Element ${custom_image_name_record}/../..//span[@aria-label="error icon"] timeout=10s

Verify Custom Image Provider
[Documentation] Verifies that the user listed for an image in the dahsboard
... UI matches the given one
[Arguments] ${image_name} ${expected_user}
${custom_image_name_record}= Set Variable xpath://td[@data-label="Name"]/div/div/div[.="${image_name}"]
${exists}= Run Keyword And Return Status Page Should Contain Element
... xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="Provider" and .="${expected_user}"] # robocop: disable
... ${custom_image_name_record}/../../../../td[@data-label="Provider" and .="${expected_user}"]
IF ${exists}==False
${user}= Get Text xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../../td[@data-label="Provider"] # robocop: disable
${user}= Get Text ${custom_image_name_record}/../../../../td[@data-label="Provider"]
Log User for ${image_name} does not match ${expected_user} - Actual user is ${user}
FAIL
END
RETURN ${exists}

Is Custom Image Enabled
[Documentation] Checkes whether a custom image is enabled - if yes, returns true, false otherwise
... Note: if the image isn't listed at all this will return false always.
[Arguments] ${image_name}
# This is how disabled state looks like
RETURN Run Keyword And Return Status Page Should Contain Element
... //td[@data-label="Name"]/div/div/div[.="${image_name}"]/../../../..//input[@checked and not(@disabled)]

Enable Custom Image
[Documentation] Enables a custom image (i.e. displayed in JH) [WIP]
[Documentation] Enables a custom image (i.e. displayed in JH)
[Arguments] ${image_name}
${is_enabled}= # Need to find a check
${is_enabled}= Is Custom Image Enabled ${image_name}
IF ${is_enabled}==False
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${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]
[Documentation] Disables a custom image (i.e. not displayed in JH)
[Arguments] ${image_name}
${is_enabled}= # Need to find a check
${is_enabled}= Is Custom Image Enabled ${image_name}
IF ${is_enabled}==True
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name} "]/../../../..//input
Click Element xpath://td[@data-label="Name"]/div/div/div[.="${image_name}"]/../../../..//input
END

Close Notification Drawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Test Tags JupyterHub
*** Variables ***
${YAML} = tests/Resources/Files/custom_image.yaml
${IMG_NAME} = custom-test-image
${IMG_URL} = quay.io/opendatahub-contrib/workbench-images:jupyter-datascience-c9s-py311_2023c_latest
${IMG_URL} = quay.io/opendatahub/workbench-images:jupyter-minimal-ubi9-python-3.11-2024b-20241004
${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 Down Expand Up @@ -62,7 +62,7 @@ Verify Custom Image Can Be Added

Test Duplicate Image
[Documentation] Test adding two images with the same name (should fail)
... ProductBug - https://issues.redhat.com/browse/RHOAIENG-1192
... There was a bug related https://issues.redhat.com/browse/RHOAIENG-1192
[Tags] Tier1 ExcludeOnDisconnected
... ODS-1368
Sleep 1
Expand All @@ -71,10 +71,9 @@ Test Duplicate Image
Import New Custom Image ${IMG_URL} ${IMG_NAME} ${IMG_DESCRIPTION}
... software=${IMG_SOFTWARE}
... packages=${IMG_PACKAGES}
# Workaround for https://issues.redhat.com/browse/RHOAIENG-1192
# To be removed ASAP
Wait Until Page Contains Unable to add notebook image: HTTP request failed
Log Unable to add second image with error message "Unable to add notebook image: HTTP request failed" due to RHOAIENG-1192 level=WARN # robocop: disable
# Assure that the expected error message is shown in the modal window
${image_name_id}= Replace String ${IMG_NAME} ${SPACE} -
Wait Until Page Contains Unable to add notebook image: imagestreams.image.openshift.io "custom-${image_name_id}" already exists
# Since the image cannot be created, we need to cancel the modal window now
Click Button ${GENERIC_CANCEL_BTN_XP}
[Teardown] Duplicate Image Teardown
Expand All @@ -94,9 +93,11 @@ Test Bad Image URL

Test Image From Local registry
[Documentation] Try creating a custom image using a local registry URL (i.e. OOTB image)
... Issue reported for this test in the past - https://github.com/opendatahub-io/odh-dashboard/issues/2185
[Tags] Tier1
... ODS-2470
... ExcludeOnDisconnected # Since we don't have internal image registry enabled there usually
... InternalImageRegistry # Requires internal image registry enabled
... ProductBug # https://issues.redhat.com/browse/RHOAIENG-1193
${CLEANUP}= Set Variable False
Open Notebook Images Page
${local_url} = Get Standard Data Science Local Registry URL
Expand Down Expand Up @@ -198,6 +199,6 @@ Reset Image 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
${registry} = Run oc get imagestream s2i-generic-data-science-notebook -n ${APPLICATIONS_NAMESPACE} -o json | jq '.status.dockerImageRepository' | sed 's/"//g' # robocop: disable
${tag} = Run oc get imagestream s2i-generic-data-science-notebook -n ${APPLICATIONS_NAMESPACE} -o json | jq '.status.tags[-1].tag' | sed 's/"//g' # robocop: disable
RETURN ${registry}:${tag}

0 comments on commit b245342

Please sign in to comment.