From 6b61b028ebed8a2445890e7fa917e563821a23b5 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Wed, 25 Oct 2023 12:20:41 +0200 Subject: [PATCH 1/5] fix custom image tests Signed-off-by: Luca Giorgi --- .../Page/ODH/ODHDashboard/ODHDashboard.robot | 42 ++++++++++++------- .../Tests/500__jupyterhub/custom-image.robot | 27 ++++++------ 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot b/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot index 067a609a3..bf452a55d 100644 --- a/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot +++ b/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot @@ -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 @@ -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 @@ -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 @@ -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"] @@ -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 @@ -662,7 +665,8 @@ 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! + ${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 @@ -673,9 +677,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 @@ -686,7 +691,7 @@ 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 @@ -694,11 +699,16 @@ Disable Custom Image [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} diff --git a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot index 266b2f941..367e364e3 100644 --- a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot +++ b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot @@ -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 @@ -38,7 +38,6 @@ Verify Custom Image Can Be Added ... Then loads the spawner and tries using the custom img [Tags] Sanity Tier1 ... ODS-1208 ODS-1365 - ... ProductBug Create Custom Image Get ImageStream Metadata And Check Name Verify Custom Image Is Listed ${IMG_NAME} @@ -61,23 +60,25 @@ Test Duplicate Image [Documentation] Test adding two images with the same name (should fail) [Tags] Sanity Tier1 ... 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} @@ -92,18 +93,20 @@ 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 - Get ImageStream Metadata And Check Name - Launch JupyterHub Spawner From Dashboard + RHODS Notification Drawer Should Contain + ... Unable to add notebook image ${IMG_NAME} + #### Image does not get imported anymore at all #### + #Get ImageStream Metadata And Check Name + #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 + #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 *** Keywords *** From f5c48b55117db3e56cb5ce5e9f8fad90583f935d Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Mon, 30 Oct 2023 17:55:26 +0100 Subject: [PATCH 2/5] add local registry test Signed-off-by: Luca Giorgi --- .../Tests/500__jupyterhub/custom-image.robot | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot index 367e364e3..48e49f138 100644 --- a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot +++ b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot @@ -36,7 +36,7 @@ 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 Create Custom Image Get ImageStream Metadata And Check Name @@ -58,7 +58,7 @@ 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 Sleep 1 Create Custom Image @@ -108,6 +108,21 @@ Test Bad Image Import #Set Global Variable ${IMG_URL} ${IMG_URL} #[Teardown] Custom Image Teardown cleanup=False +Test Image From Local registry + [Documentation] Try creating a custom image using a local registry URL (i.e. OOTB image) + [Tags] Sanity Tier1 + 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 + Spawn Notebook With Arguments image=${IMAGESTREAM_NAME} size=Small + [Teardown] Custom Image Teardown + *** Keywords *** @@ -147,7 +162,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} @@ -167,3 +181,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} \ No newline at end of file From 86984be8cafd16776996e1b684835e83c790bd32 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Tue, 31 Oct 2023 10:27:11 +0100 Subject: [PATCH 3/5] add small sleep Signed-off-by: Luca Giorgi --- ods_ci/tests/Tests/500__jupyterhub/custom-image.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot index 48e49f138..d078e8ee9 100644 --- a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot +++ b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot @@ -39,6 +39,7 @@ Verify Custom Image Can Be Added [Tags] Sanity Tier1 ExcludeOnDisconnected ... ODS-1208 ODS-1365 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} From c34435804c44e4f783a3029d61246b2540d8de33 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Tue, 31 Oct 2023 10:51:27 +0100 Subject: [PATCH 4/5] add sleep to wait for page load Signed-off-by: Luca Giorgi --- ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot b/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot index bf452a55d..b65fae92e 100644 --- a/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot +++ b/ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.robot @@ -666,6 +666,7 @@ Verify Custom Image Is Listed ... 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 From f4beafb5cdc12e095fd93d60ea2bfc45746731f6 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Tue, 31 Oct 2023 12:07:26 +0100 Subject: [PATCH 5/5] remove comments, add polarion Signed-off-by: Luca Giorgi --- ods_ci/tests/Tests/500__jupyterhub/custom-image.robot | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot index d078e8ee9..150a4d5c7 100644 --- a/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot +++ b/ods_ci/tests/Tests/500__jupyterhub/custom-image.robot @@ -100,18 +100,11 @@ Test Bad Image Import Create Custom Image RHODS Notification Drawer Should Contain ... Unable to add notebook image ${IMG_NAME} - #### Image does not get imported anymore at all #### - #Get ImageStream Metadata And Check Name - #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 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}