mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Merge pull request #11812 from danfengliu/fix-issue-of-gc-untag-case
Fix issue of GC untag images case
This commit is contained in:
commit
a8cfb40cc2
@ -304,13 +304,6 @@ Click GC Now
|
||||
Retry Element Click xpath=${gc_now_xpath}
|
||||
Sleep 2
|
||||
|
||||
Click GC Now With Param Delete Untagged Artifacts
|
||||
Sleep 1
|
||||
Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
|
||||
Sleep 1
|
||||
Retry Element Click xpath=${gc_now_xpath}
|
||||
Sleep 5
|
||||
|
||||
View GC Details
|
||||
Retry Element Click xpath=${gc_log_details_xpath}
|
||||
Sleep 2
|
||||
|
@ -20,13 +20,28 @@ Resource ../../resources/Util.robot
|
||||
|
||||
*** Keywords ***
|
||||
GC Now
|
||||
[Arguments] ${harbor_url} ${login_user} ${login_pwd}
|
||||
[Arguments] ${harbor_url} ${login_user} ${login_pwd} ${untag}=${false}
|
||||
Switch To Garbage Collection
|
||||
Capture Page Screenshot
|
||||
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
|
||||
Capture Page Screenshot
|
||||
Click GC Now
|
||||
Logout Harbor
|
||||
Sleep 2
|
||||
Sign In Harbor ${harbor_url} ${login_user} ${login_pwd}
|
||||
Switch To Garbage Collection
|
||||
Sleep 1
|
||||
Switch To GC History
|
||||
Retry Keyword N Times When Error 60 Retry Wait Until Page Contains Finished
|
||||
#Switch To GC History
|
||||
#Retry Keyword N Times When Error 60 Retry Wait Until Page Contains Finished
|
||||
|
||||
Retry GC Should Be Successful
|
||||
[Arguments] ${history_id} ${expected_msg}
|
||||
Retry Keyword When Error GC Should Be Successful ${history_id} ${expected_msg}
|
||||
|
||||
GC Should Be Successful
|
||||
[Arguments] ${history_id} ${expected_msg}
|
||||
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc/${history_id}/log"
|
||||
Log To Console ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Run Keyword If '${expected_msg}' != '${null}' Should Contain ${output} ${expected_msg}
|
||||
Should Contain ${output} success to run gc in job.
|
@ -21,11 +21,12 @@ Resource ../../resources/Util.robot
|
||||
*** Keywords ***
|
||||
Go Into Project
|
||||
[Arguments] ${project} ${has_image}=${true}
|
||||
Sleep 2
|
||||
Retry Element Click xpath=//harbor-app/harbor-shell/clr-main-container/navigator/clr-header/div[1]/a/span
|
||||
Sleep 2
|
||||
Retry Text Input ${search_input} ${project}
|
||||
:For ${n} IN RANGE 1 5
|
||||
\ Sleep 2
|
||||
\ Retry Wait Element ${search_input}
|
||||
\ Retry Clear Element Text ${search_input}
|
||||
\ Input Text ${search_input} ${project}
|
||||
\ ${out} Run Keyword If ${has_image}==${false} Retry Double Keywords When Error Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a Wait Until Element Is Visible And Enabled xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any repositories!\")] DoAssert=${false}
|
||||
\ ... ELSE Retry Double Keywords When Error Retry Element Click xpath=//*[@id='project-results']//clr-dg-cell[contains(.,'${project}')]/a Wait Until Element Is Visible And Enabled xpath=//project-detail//hbr-repository-gridview//clr-dg-cell[contains(.,'${project}/')] DoAssert=${false}
|
||||
\ Log To Console ${out}
|
||||
|
@ -228,13 +228,13 @@ Command Should be Failed
|
||||
|
||||
Retry Keyword When Error
|
||||
[Arguments] ${keyword} @{elements}
|
||||
:For ${n} IN RANGE 1 3
|
||||
:For ${n} IN RANGE 1 10
|
||||
\ Log To Console Trying ${keyword} elements @{elements} ${n} times ...
|
||||
\ ${out} Run Keyword And Ignore Error ${keyword} @{elements}
|
||||
\ Log To Console Return value is ${out} and ${out[0]}
|
||||
\ Run Keyword If '${keyword}'=='Make Swagger Client' Exit For Loop If '${out[0]}'=='PASS' and '${out[1]}'=='0'
|
||||
\ ... ELSE Exit For Loop If '${out[0]}'=='PASS'
|
||||
\ Sleep 2
|
||||
\ Sleep 10
|
||||
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
|
||||
Should Be Equal As Strings '${out[0]}' 'PASS'
|
||||
[Return] ${out[1]}
|
||||
@ -265,8 +265,8 @@ Retry Keyword When Return Value Mismatch
|
||||
Should Be Equal As Strings ${status} 'PASS'
|
||||
|
||||
Retry Double Keywords When Error
|
||||
[Arguments] ${keyword1} ${element1} ${keyword2} ${element2} ${DoAssert}=${true}
|
||||
:For ${n} IN RANGE 1 3
|
||||
[Arguments] ${keyword1} ${element1} ${keyword2} ${element2} ${DoAssert}=${true} ${times}=3
|
||||
:For ${n} IN RANGE 1 ${times}
|
||||
\ Log To Console Trying ${keyword1} and ${keyword2} ${n} times ...
|
||||
\ ${out1} Run Keyword And Ignore Error ${keyword1} ${element1}
|
||||
\ Capture Page Screenshot
|
||||
|
@ -444,26 +444,6 @@ Test Case - Create An New Project With Quotas Set
|
||||
Should Be Equal As Strings ${storage_quota_ret} 0Byte of ${storage_quota}${storage_quota_unit}
|
||||
Close Browser
|
||||
|
||||
# Make sure image logstash was pushed to harbor for the 1st time, so GC will delete it.
|
||||
Test Case - Project Quotas Control Under GC
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
${storage_quota}= Set Variable 200
|
||||
${storage_quota_unit}= Set Variable MB
|
||||
${image_a}= Set Variable logstash
|
||||
${image_a_size}= Set Variable 321.03MB
|
||||
${image_a_ver}= Set Variable 6.8.3
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Capture Page Screenshot
|
||||
Create An New Project project${d} storage_quota=${storage_quota} storage_quota_unit=${storage_quota_unit}
|
||||
Capture Page Screenshot
|
||||
Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=will exceed the configured upper limit of 200.0 MiB
|
||||
Capture Page Screenshot
|
||||
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
@{param} Create List project${d}
|
||||
Retry Keyword When Return Value Mismatch Get Project Storage Quota Text From Project Quotas List 0Byte of ${storage_quota}${storage_quota_unit} 60 @{param}
|
||||
Close Browser
|
||||
|
||||
Test Case - Project Storage Quotas Dispaly And Control
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
@ -558,37 +538,6 @@ Test Case - Tag CRUD
|
||||
Should Not Contain Tag latest
|
||||
Close Browser
|
||||
|
||||
Test Case - GC Untagged Images
|
||||
Init Chrome Driver
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Create An New Project project${d}
|
||||
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world latest
|
||||
# make hello-world untagged
|
||||
Go Into Project project${d}
|
||||
Go Into Repo hello-world
|
||||
Go Into Artifact latest
|
||||
Should Contain Tag latest
|
||||
Delete A Tag latest
|
||||
Should Not Contain Tag latest
|
||||
# run gc without param delete untagged artifacts checked, should not delete hello-world:latest
|
||||
Switch To Garbage Collection
|
||||
Click GC Now
|
||||
Go Into Project project${d}
|
||||
Switch To Project Repo
|
||||
Go Into Repo hello-world
|
||||
Should Contain Artifact
|
||||
# run gc with param delete untagged artifacts checked, should delete hello-world
|
||||
Switch To Garbage Collection
|
||||
Click GC Now With Param Delete Untagged Artifacts
|
||||
Go Into Project project${d}
|
||||
Switch To Project Repo
|
||||
Go Into Repo hello-world
|
||||
Should Not Contain Any Artifact
|
||||
Close Browser
|
||||
|
||||
|
||||
|
||||
Test Case - Tag Retention
|
||||
Init Chrome Driver
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
@ -627,7 +576,6 @@ Test Case - Tag Immutability
|
||||
Delete Success busybox
|
||||
Close Browser
|
||||
|
||||
|
||||
Test Case - Robot Account
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
@ -756,22 +704,4 @@ Test Case - Read Only Mode
|
||||
Sleep 5
|
||||
Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest
|
||||
Close Browser
|
||||
Test Case - Admin Add New Users
|
||||
[Tags] non-uaa
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
# can add a new user when self-reg is enbled
|
||||
Switch To Configure
|
||||
Self Reg Should Be Enabled
|
||||
Switch to User Tag
|
||||
Add A New User username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
|
||||
# can add a new user when self-reg is disabled
|
||||
Switch To Configure
|
||||
Self Reg Should Be Enabled
|
||||
Sleep 1
|
||||
Disable Self Reg
|
||||
Self Reg Should Be Disabled
|
||||
Switch to User Tag
|
||||
Add A New User username=tester2${d} email=tester2${d}@vmware.com realname=harbortest2 newPassword=Test1@34 comment=harbortest2
|
||||
Close Browser
|
||||
|
||||
|
@ -34,12 +34,58 @@ Test Case - Garbage Collection
|
||||
Sleep 2
|
||||
Go Into Project project${d}
|
||||
Delete Repo project${d}
|
||||
Sleep 2
|
||||
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc/1/log"
|
||||
Log To Console ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
#TODO: Need to find a reliable way to clear external storage, then this statistc will be accurate.
|
||||
#Should Contain ${output} 0 blobs marked, 3 blobs and 0 manifests eligible for deletion
|
||||
Should Contain ${output} success to run gc in job.
|
||||
Retry GC Should Be Successful 1 0 blobs marked, 3 blobs and 0 manifests eligible for deletion
|
||||
Close Browser
|
||||
|
||||
Test Case - GC Untagged Images
|
||||
Init Chrome Driver
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Create An New Project project${d}
|
||||
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world latest
|
||||
# make hello-world untagged
|
||||
Go Into Project project${d}
|
||||
Go Into Repo hello-world
|
||||
Go Into Artifact latest
|
||||
Should Contain Tag latest
|
||||
Delete A Tag latest
|
||||
Should Not Contain Tag latest
|
||||
# run gc without param delete untagged artifacts checked, should not delete hello-world:latest
|
||||
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Retry GC Should Be Successful 2 ${null}
|
||||
Go Into Project project${d}
|
||||
Switch To Project Repo
|
||||
Go Into Repo hello-world
|
||||
Should Contain Artifact
|
||||
# run gc with param delete untagged artifacts checked, should delete hello-world
|
||||
Switch To Garbage Collection
|
||||
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} untag=${true}
|
||||
Retry GC Should Be Successful 3 ${null}
|
||||
Go Into Project project${d}
|
||||
Switch To Project Repo
|
||||
Go Into Repo hello-world
|
||||
Should Not Contain Any Artifact
|
||||
Close Browser
|
||||
|
||||
# Make sure image logstash was pushed to harbor for the 1st time, so GC will delete it.
|
||||
Test Case - Project Quotas Control Under GC
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
${storage_quota}= Set Variable 200
|
||||
${storage_quota_unit}= Set Variable MB
|
||||
${image_a}= Set Variable logstash
|
||||
${image_a_size}= Set Variable 321.03MB
|
||||
${image_a_ver}= Set Variable 6.8.3
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Capture Page Screenshot
|
||||
Create An New Project project${d} storage_quota=${storage_quota} storage_quota_unit=${storage_quota_unit}
|
||||
Capture Page Screenshot
|
||||
Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=will exceed the configured upper limit of 200.0 MiB
|
||||
Capture Page Screenshot
|
||||
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
Retry GC Should Be Successful 4 ${null}
|
||||
@{param} Create List project${d}
|
||||
Retry Keyword When Return Value Mismatch Get Project Storage Quota Text From Project Quotas List 0Byte of ${storage_quota}${storage_quota_unit} 60 @{param}
|
||||
Close Browser
|
@ -86,3 +86,22 @@ Test Case - Edit Self-Registration
|
||||
# Restore setting
|
||||
Enable Self Reg
|
||||
Close Browser
|
||||
|
||||
Test Case - Admin Add New Users
|
||||
Init Chrome Driver
|
||||
${d}= Get Current Date result_format=%m%s
|
||||
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
|
||||
# can add a new user when self-reg is enbled
|
||||
Switch To Configure
|
||||
Self Reg Should Be Enabled
|
||||
Switch to User Tag
|
||||
Add A New User username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
|
||||
# can add a new user when self-reg is disabled
|
||||
Switch To Configure
|
||||
Self Reg Should Be Enabled
|
||||
Sleep 1
|
||||
Disable Self Reg
|
||||
Self Reg Should Be Disabled
|
||||
Switch to User Tag
|
||||
Add A New User username=tester2${d} email=tester2${d}@vmware.com realname=harbortest2 newPassword=Test1@34 comment=harbortest2
|
||||
Close Browser
|
Loading…
Reference in New Issue
Block a user