From 18b9856dc56dbba91c7c3602c63d706f4c2771bc Mon Sep 17 00:00:00 2001 From: Yang Jiao Date: Wed, 27 Apr 2022 06:25:11 +0000 Subject: [PATCH] Add imgpkg copy test case Add this test case to make sure imgpkg copy to Harbor works. Signed-off-by: Yang Jiao --- .../Harbor-Pages/Project-Repository.robot | 5 ++- .../Project-Repository_Elements.robot | 1 + tests/resources/Imgpkg-Util.robot | 39 +++++++++++++++++++ tests/resources/Util.robot | 1 + tests/robot-cases/Group1-Nightly/Common.robot | 18 +++++---- .../Group1-Nightly/Replication.robot | 37 ++++++++++++++++++ 6 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 tests/resources/Imgpkg-Util.robot diff --git a/tests/resources/Harbor-Pages/Project-Repository.robot b/tests/resources/Harbor-Pages/Project-Repository.robot index 8a1da6992..152257ec0 100644 --- a/tests/resources/Harbor-Pages/Project-Repository.robot +++ b/tests/resources/Harbor-Pages/Project-Repository.robot @@ -43,4 +43,7 @@ Stop Scan Artifact Check Scan Artifact Job Status Is Stopped Wait Until Element Is Visible ${stopped_label} ${job_status}= Get Text ${stopped_label} - Should Be Equal As Strings '${job_status}' 'Scan stopped' \ No newline at end of file + Should Be Equal As Strings '${job_status}' 'Scan stopped' + +Refresh Repositories + Retry Element Click ${refresh_repositories_xpath} \ No newline at end of file diff --git a/tests/resources/Harbor-Pages/Project-Repository_Elements.robot b/tests/resources/Harbor-Pages/Project-Repository_Elements.robot index d21773ea1..6cb344058 100644 --- a/tests/resources/Harbor-Pages/Project-Repository_Elements.robot +++ b/tests/resources/Harbor-Pages/Project-Repository_Elements.robot @@ -25,3 +25,4 @@ ${push_image_command_btn} //hbr-push-image-button//button ${scan_artifact_btn} //button[@id='scan-btn'] ${stop_scan_artifact_btn} //button[@id='stop-scan'] ${stopped_label} //span[@class='label stopped'] +${refresh_repositories_xpath} //hbr-repository-gridview//span[contains(@class,'refresh-btn')] \ No newline at end of file diff --git a/tests/resources/Imgpkg-Util.robot b/tests/resources/Imgpkg-Util.robot new file mode 100644 index 000000000..1fafa1bdf --- /dev/null +++ b/tests/resources/Imgpkg-Util.robot @@ -0,0 +1,39 @@ +# Copyright Project Harbor Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation This resource provides helper functions for docker operations +Library OperatingSystem +Library Process + +*** Keywords *** +Imgpkg Push + [Arguments] ${server} ${project} ${repository} ${tag} ${directory} + Wait Unitl Command Success imgpkg push -b ${server}/${project}/${repository}:${tag} -f ${directory} + +Imgpkg Pull + [Arguments] ${server} ${project} ${repository} ${tag} ${directory} + Wait Unitl Command Success imgpkg pull -b ${server}/${project}/${repository}:${tag} -o ${directory} + +Imgpkg Copy From Registry To Registry + [Arguments] ${source_registry} ${target_repo} + Wait Unitl Command Success imgpkg copy -b ${source_registry} --to-repo=${target_repo} + +Imgpkg Copy From Registry To Local Tarball + [Arguments] ${source_registry} ${file_path} + Wait Unitl Command Success imgpkg copy -b ${source_registry} --to-tar=${file_path} + +Imgpkg Copy From Local Tarball To Registry + [Arguments] ${file_path} ${target_repo} + Wait Unitl Command Success imgpkg copy --tar ${file_path} --to-repo=${target_repo} diff --git a/tests/resources/Util.robot b/tests/resources/Util.robot index 2cd0898e4..4e93f0c62 100644 --- a/tests/resources/Util.robot +++ b/tests/resources/Util.robot @@ -75,6 +75,7 @@ Resource SeleniumUtil.robot Resource Nightly-Util.robot Resource APITest-Util.robot Resource Cosign_Util.robot +Resource Imgpkg-Util.robot Resource TestCaseBody.robot *** Keywords *** diff --git a/tests/robot-cases/Group1-Nightly/Common.robot b/tests/robot-cases/Group1-Nightly/Common.robot index d8c59abbc..b67472b6f 100644 --- a/tests/robot-cases/Group1-Nightly/Common.robot +++ b/tests/robot-cases/Group1-Nightly/Common.robot @@ -880,17 +880,19 @@ Test Case - WASM Push And Pull To Harbor Test Case - Carvel Imgpkg Push And Pull To Harbor [Tags] imgpkg_push_and_pull Init Chrome Driver - ${user}= Set Variable user004 - ${pwd}= Set Variable Test1@34 - ${out_path}= Set Variable /tmp/my-bundle + ${user}= Set Variable user004 + ${pwd}= Set Variable Test1@34 + ${out_path}= Set Variable /tmp/my-bundle + ${repository}= Set Variable my-bundle + ${tag}= Set Variable v1.0.0 Sign In Harbor ${HARBOR_URL} ${user} ${pwd} - ${d}= Get Current Date result_format=%m%s + ${d}= Get Current Date result_format=%m%s Create An New Project And Go Into Project project${d} Prepare Image Package Test Files ${EXECDIR}/config - Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip} - Wait Unitl Command Success imgpkg push -b ${ip}/project${d}/my-bundle:v1.0.0 -f config/ - Wait Unitl Command Success imgpkg pull -b ${ip}/project${d}/my-bundle:v1.0.0 -o ${out_path} - Wait Unitl Command Success docker logout ${ip} + Docker Login ${ip} ${user} ${pwd} + Imgpkg Push ${ip} project${d} ${repository} ${tag} ${EXECDIR}/config + Imgpkg Pull ${ip} project${d} ${repository} ${tag} ${out_path} + Docker Logout ${ip} Retry File Should Exist ${out_path}/.imgpkg/bundle.yml Retry File Should Exist ${out_path}/.imgpkg/images.yml diff --git a/tests/robot-cases/Group1-Nightly/Replication.robot b/tests/robot-cases/Group1-Nightly/Replication.robot index 12c8565e1..d4e16395f 100644 --- a/tests/robot-cases/Group1-Nightly/Replication.robot +++ b/tests/robot-cases/Group1-Nightly/Replication.robot @@ -848,4 +848,41 @@ Test Case - Enable Replication Of Cosign And Notary Deployment Security Policy Retry Double Keywords When Error Go Into Repo project_push_dest${d}/${image1} Should Be Signed By Cosign ${tag1} Back Project Home project_push_dest${d} Retry Double Keywords When Error Go Into Repo project_push_dest${d}/${image2} Should Be Signed By Cosign ${tag2} + Close Browser + +Test Case - Carvel Imgpkg Copy To Harbor + [Tags] imgpkg_copy + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + ${out_file_path}= Set Variable /tmp/my-bundle.tar + ${repository}= Set Variable my-bundle + ${tag}= Set Variable v1.0.0 + + Sign In Harbor https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project And Go Into Project project${d} + Logout Harbor + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project And Go Into Project project_dest${d} + Docker Login ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Docker Login ${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Prepare Image Package Test Files ${EXECDIR}/config + Imgpkg Push ${ip} project${d} ${repository} ${tag} ${EXECDIR}/config + Imgpkg Copy From Registry To Registry ${ip}/project${d}/${repository}:${tag} ${ip1}/project_dest${d}/${repository} + Refresh Repositories + Repo Exist project_dest${d} ${repository} + Go Into Repo project_dest${d}/${repository} + Artifact Exist ${tag} + Back Project Home project_dest${d} + Delete Repo project_dest${d} ${repository} + Repo Not Exist project_dest${d} ${repository} + Imgpkg Copy From Registry To Local Tarball ${ip}/project${d}/${repository}:${tag} ${out_file_path} + Retry File Should Exist ${out_file_path} + Imgpkg Copy From Local Tarball To Registry ${out_file_path} ${ip1}/project_dest${d}/${repository} + Refresh Repositories + Repo Exist project_dest${d} ${repository} + Retry Element Click ${repo_search_icon} + Go Into Repo project_dest${d}/${repository} + Artifact Exist ${tag} + Docker Logout ${ip} + Docker Logout ${ip1} Close Browser \ No newline at end of file