From a4a82d763a8a4633a7d82d39e851f07b064474c8 Mon Sep 17 00:00:00 2001 From: YangJiao Date: Fri, 3 Sep 2021 16:56:24 +0800 Subject: [PATCH] Add TestCase to download helmchart from UI Signed-off-by: YangJiao --- tests/resources/Harbor-Pages/Project-Helmcharts.robot | 10 ++++++++++ .../Harbor-Pages/Project-Helmcharts_Elements.robot | 1 + tests/resources/SeleniumUtil.robot | 6 ++++++ tests/resources/TestCaseBody.robot | 2 +- tests/resources/Util.robot | 8 ++++++++ tests/robot-cases/Group1-Nightly/Chartmuseum.robot | 2 +- tests/test-engine-image/Dockerfile.common | 4 ++-- tests/test-engine-image/Dockerfile.ui_test | 4 ++-- 8 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/resources/Harbor-Pages/Project-Helmcharts.robot b/tests/resources/Harbor-Pages/Project-Helmcharts.robot index e08dc0d30..a3d468dc5 100644 --- a/tests/resources/Harbor-Pages/Project-Helmcharts.robot +++ b/tests/resources/Harbor-Pages/Project-Helmcharts.robot @@ -37,6 +37,16 @@ Go Into Chart Detail Retry Element Click xpath=//hbr-helm-chart-version//a[contains(., '${version_name}')] Retry Wait Until Page Contains Element ${chart_detail} +Download Chart File + [Arguments] ${chart_name} ${chart_filename} + Switch To Project Charts + ${out} Run Keyword And Ignore Error OperatingSystem.File Should Not Exist ${download_directory}/${chart_filename} + Run Keyword If '${out[0]}'=='FAIL' Run rm -rf ${download_directory}/${chart_filename} + Retry File Should Not Exist ${download_directory}/${chart_filename} + Retry Element Click //clr-dg-row[contains(.,'${chart_name}')]//label + Retry Double Keywords When Error Retry Element Click ${download_chart_button} Retry File Should Exist ${download_directory}/${chart_filename} + Retry Element Click //clr-dg-row[contains(.,'${chart_name}')]//label + Multi-delete Chart Files [Arguments] @{obj} Switch To Project Charts diff --git a/tests/resources/Harbor-Pages/Project-Helmcharts_Elements.robot b/tests/resources/Harbor-Pages/Project-Helmcharts_Elements.robot index fc3625558..ba7738685 100644 --- a/tests/resources/Harbor-Pages/Project-Helmcharts_Elements.robot +++ b/tests/resources/Harbor-Pages/Project-Helmcharts_Elements.robot @@ -5,6 +5,7 @@ Documentation This resource provides any keywords related to the Harbor private ${project_chart_tabpage} xpath=//project-detail//a[contains(.,'Charts')] ${project_chart_list} xpath=//hbr-helm-chart ${upload_chart_button} //*[@id='helm-chart-upload'] +${download_chart_button} //clr-dg-action-bar/button[contains(.,'Download')] ${chart_file_browse} //*[@id='chart'] ${chart_prov_browse} //*[@id='prov'] ${upload_action_button} //*[@id='upload-chart'] diff --git a/tests/resources/SeleniumUtil.robot b/tests/resources/SeleniumUtil.robot index 06f965a1c..ca45d84ee 100644 --- a/tests/resources/SeleniumUtil.robot +++ b/tests/resources/SeleniumUtil.robot @@ -16,6 +16,9 @@ Documentation This resource provides helper functions for docker operations Resource Util.robot +*** Variables *** +${download_directory} /drone/download + *** Keywords *** Start Selenium Standalone Server Locally OperatingSystem.File Should Exist /go/selenium-server-standalone-3.4.0.jar @@ -25,11 +28,14 @@ Start Selenium Standalone Server Locally [Return] ${handle} Init Chrome Driver + Create Directory ${download_directory} Run pkill chromedriver Run pkill chrome ${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys ${capabilities}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.CHROME sys + ${prefs} Create Dictionary download.default_directory=${download_directory} Set To Dictionary ${capabilities} acceptInsecureCerts ${True} + Call Method ${chrome options} add_experimental_option prefs ${prefs} Call Method ${chrome options} add_argument --headless Call Method ${chrome options} add_argument --disable-gpu Call Method ${chrome options} add_argument --start-maximized diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index 8e746d764..a573e50b2 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -151,7 +151,7 @@ Body Of List Helm Charts Retry Double Keywords When Error Retry Element Click xpath=${detail_value} Retry Wait Until Page Contains Element ${value_content} Go Into Project project${d} has_image=${false} - Switch To Project Charts + Retry Keyword N Times When Error 4 Download Chart File ${prometheus_chart_name} ${prometheus_chart_filename} Multi-delete Chart Files ${prometheus_chart_name} ${harbor_chart_name} Close Browser diff --git a/tests/resources/Util.robot b/tests/resources/Util.robot index 153df7d62..ed01df5ee 100644 --- a/tests/resources/Util.robot +++ b/tests/resources/Util.robot @@ -273,6 +273,14 @@ Retry Double Keywords When Error Return From Keyword If ${DoAssert} == ${false} '${out2[0]}' Should Be Equal As Strings '${out2[0]}' 'PASS' +Retry File Should Exist + [Arguments] ${path} + Retry Keyword N Times When Error 4 OperatingSystem.File Should Exist ${path} + +Retry File Should Not Exist + [Arguments] ${path} + Retry Keyword N Times When Error 4 OperatingSystem.File Should Not Exist ${path} + Run Curl And Return Json [Arguments] ${curl_cmd} ${json_data_file}= Set Variable ${CURDIR}${/}cur_user_info.json diff --git a/tests/robot-cases/Group1-Nightly/Chartmuseum.robot b/tests/robot-cases/Group1-Nightly/Chartmuseum.robot index edd469144..a5fbc0405 100644 --- a/tests/robot-cases/Group1-Nightly/Chartmuseum.robot +++ b/tests/robot-cases/Group1-Nightly/Chartmuseum.robot @@ -23,7 +23,7 @@ ${SSH_USER} root ${HARBOR_ADMIN} admin *** Test Cases *** -Test Case - List Helm Charts And Delete Chart Files +Test Case - List Helm Charts And Download And Delete Chart Files Body Of List Helm Charts Test Case - Helm CLI Push diff --git a/tests/test-engine-image/Dockerfile.common b/tests/test-engine-image/Dockerfile.common index 6a8039120..c431ee260 100644 --- a/tests/test-engine-image/Dockerfile.common +++ b/tests/test-engine-image/Dockerfile.common @@ -60,8 +60,8 @@ RUN pwd && mkdir /tool/binary && \ pwd #ubuntu -RUN wget https://github.com/sylabs/singularity/releases/download/v3.3.0/singularity-3.3.0.tar.gz && \ - tar -xzf singularity-3.3.0.tar.gz && \ +RUN wget https://github.com/sylabs/singularity/releases/download/v3.7.4/singularity-3.7.4.tar.gz && \ + tar -xzf singularity-3.7.4.tar.gz && \ cd singularity && \ ./mconfig && \ make -C builddir && \ diff --git a/tests/test-engine-image/Dockerfile.ui_test b/tests/test-engine-image/Dockerfile.ui_test index 6de1f16c4..69dd3a9f1 100644 --- a/tests/test-engine-image/Dockerfile.ui_test +++ b/tests/test-engine-image/Dockerfile.ui_test @@ -33,8 +33,8 @@ RUN pip3 install --upgrade pip pyasn1 google-apitools==0.5.31 gsutil \ requests dbbot robotframework-seleniumlibrary==4.3.0 robotframework-pabot \ robotframework-JSONLibrary hurry.filesize --upgrade && \ apt-get clean all - -RUN wget -N http://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip && \ +# Because the old version of chromedriver can’t download files, upgrade it to version 93.0.4577.15, which can download files normally. +RUN wget -N http://chromedriver.storage.googleapis.com/93.0.4577.15/chromedriver_linux64.zip && \ unzip chromedriver_linux64.zip && \ chmod +x chromedriver && \ mv -f chromedriver /usr/local/share/chromedriver && \