mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-31 03:51:23 +01:00
add retry keyword for docker pull and push image command. (#6857)
Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
parent
e12fd13c56
commit
e5efbfe490
@ -20,17 +20,13 @@ Library Process
|
||||
*** Keywords ***
|
||||
Run Docker Info
|
||||
[Arguments] ${docker-params}
|
||||
${rc}= Run And Return Rc docker ${docker-params} info
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker ${docker-params} info
|
||||
|
||||
Pull image
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image}
|
||||
Log To Console \nRunning docker pull ${image}...
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${ip}/${project}/${image}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
${output}= Wait Unitl Command Success docker pull ${ip}/${project}/${image}
|
||||
Should Contain ${output} Digest:
|
||||
Should Contain ${output} Status:
|
||||
Should Not Contain ${output} No such image:
|
||||
@ -38,62 +34,41 @@ Pull image
|
||||
Push image
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image}
|
||||
Log To Console \nRunning docker push ${image}...
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${image}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker tag ${image} ${ip}/${project}/${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker push ${ip}/${project}/${image}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker logout ${ip}
|
||||
Wait Unitl Command Success docker pull ${image}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image}
|
||||
Wait Unitl Command Success docker push ${ip}/${project}/${image}
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Push Image With Tag
|
||||
#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
|
||||
Log To Console \nRunning docker push ${image}...
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${image}:${tag1}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker tag ${image}:${tag1} ${ip}/${project}/${image}:${tag}
|
||||
${rc} ${output}= Run And Return Rc And Output docker push ${ip}/${project}/${image}:${tag}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker logout ${ip}
|
||||
Wait Unitl Command Success docker pull ${image}:${tag1}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker tag ${image}:${tag1} ${ip}/${project}/${image}:${tag}
|
||||
Wait Unitl Command Success docker push ${ip}/${project}/${image}:${tag}
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Cannot Pull image
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${ip}/${project}/${image}
|
||||
Log ${output}
|
||||
Should Not Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker pull ${ip}/${project}/${image} positive=${false}
|
||||
|
||||
Cannot Pull Unsigned Image
|
||||
[Arguments] ${ip} ${user} ${pass} ${proj} ${imagewithtag}
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pass} ${ip}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${ip}/${proj}/${imagewithtag}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pass} ${ip}
|
||||
${output}= Wait Unitl Command Success docker pull ${ip}/${proj}/${imagewithtag} positive=${false}
|
||||
Should Contain ${output} The image is not signed in Notary
|
||||
Should Not Be Equal As Integers ${rc} 0
|
||||
|
||||
Cannot Push image
|
||||
[Arguments] ${ip} ${user} ${pwd} ${project} ${image}
|
||||
Log To Console \nRunning docker push ${image}...
|
||||
${rc}= Run And Return Rc docker pull ${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Log ${output}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker tag ${image} ${ip}/${project}/${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker push ${ip}/${project}/${image}
|
||||
Log ${output}
|
||||
Should Not Be Equal As Integers ${rc} 0
|
||||
${rc}= Run And Return Rc docker logout ${ip}
|
||||
Wait Unitl Command Success docker pull ${image}
|
||||
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
|
||||
Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image}
|
||||
Wait Unitl Command Success docker push ${ip}/${project}/${image} positive=${false}
|
||||
Wait Unitl Command Success docker logout ${ip}
|
||||
|
||||
Wait Until Container Stops
|
||||
[Arguments] ${container}
|
||||
@ -106,13 +81,11 @@ Wait Until Container Stops
|
||||
|
||||
Hit Nginx Endpoint
|
||||
[Arguments] ${vch-ip} ${port}
|
||||
${rc} ${output}= Run And Return Rc And Output wget ${vch-ip}:${port}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success wget ${vch-ip}:${port}
|
||||
|
||||
Get Container IP
|
||||
[Arguments] ${docker-params} ${id} ${network}=default ${dockercmd}=docker
|
||||
${rc} ${ip}= Run And Return Rc And Output ${dockercmd} ${docker-params} network inspect ${network} | jq '.[0].Containers."${id}".IPv4Address' | cut -d \\" -f 2 | cut -d \\/ -f 1
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${ip}= Wait Unitl Command Success ${dockercmd} ${docker-params} network inspect ${network} | jq '.[0].Containers."${id}".IPv4Address' | cut -d \\" -f 2 | cut -d \\/ -f 1
|
||||
[Return] ${ip}
|
||||
|
||||
# The local dind version is embedded in Dockerfile
|
||||
@ -133,42 +106,34 @@ Start Docker Daemon Locally
|
||||
|
||||
Prepare Docker Cert
|
||||
[Arguments] ${ip}
|
||||
${rc} ${out}= Run And Return Rc And Output mkdir -p /etc/docker/certs.d/${ip}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
${rc} ${out}= Run And Return Rc And Output cp harbor_ca.crt /etc/docker/certs.d/${ip}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
|
||||
Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip}
|
||||
|
||||
Kill Local Docker Daemon
|
||||
[Arguments] ${handle} ${dockerd-pid}
|
||||
Terminate Process ${handle}
|
||||
Process Should Be Stopped ${handle}
|
||||
${rc}= Run And Return Rc kill -9 ${dockerd-pid}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success kill -9 ${dockerd-pid}
|
||||
|
||||
Docker Login Fail
|
||||
[Arguments] ${ip} ${user} ${pwd}
|
||||
Log To Console \nRunning docker login ${ip} ...
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
|
||||
Should Not Be Equal As Integers ${rc} 0
|
||||
${output}= Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip} positive=${false}
|
||||
Should Contain ${output} unauthorized: authentication required
|
||||
Should Not Contain ${output} 500 Internal Server Error
|
||||
|
||||
Docker Login
|
||||
[Arguments] ${server} ${username} ${password}
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u ${username} -p ${password} ${server}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker login -u ${username} -p ${password} ${server}
|
||||
|
||||
Docker Pull
|
||||
[Arguments] ${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker pull ${image}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker pull ${image}
|
||||
|
||||
Docker Tag
|
||||
[Arguments] ${src_image} ${dst_image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker tag ${src_image} ${dst_image}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker tag ${src_image} ${dst_image}
|
||||
|
||||
Docker Push
|
||||
[Arguments] ${image}
|
||||
${rc} ${output}= Run And Return Rc And Output docker push ${image}
|
||||
Should Be Equal As Integers ${rc} 0
|
||||
Wait Unitl Command Success docker push ${image}
|
@ -134,7 +134,7 @@ User Should Not Be A Member Of Project
|
||||
Project Should Not Display ${project}
|
||||
Logout Harbor
|
||||
Cannot Pull image ${ip} ${user} ${pwd} ${project} ${ip}/${project}/hello-world
|
||||
Cannot Push image ${ip} ${user} ${pwd} ${project} ${ip}/${project}/hello-world
|
||||
Cannot Push image ${ip} ${user} ${pwd} ${project} hello-world
|
||||
|
||||
Manage Project Member
|
||||
[Arguments] ${admin} ${pwd} ${project} ${user} ${op} ${has_image}=${true}
|
||||
|
@ -31,3 +31,4 @@ ${create_project_CANCEL_button_xpath} xpath=//button[contains(.,'CANCEL')]
|
||||
${project_statistics_private_repository_icon} xpath=//project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
|
||||
${repo_delete_btn} xpath=//button[contains(.,'Delete')]
|
||||
${repo_delete_confirm_btn} xpath=//clr-modal//button[2]
|
||||
${repo_retag_confirm_dlg} css=${modal-dialog}
|
||||
|
@ -109,6 +109,19 @@ Wait Unitl Vul Data Ready
|
||||
\ Sleep ${interval}
|
||||
Run Keyword If ${i+1}==${n} Fail The vul data is not ready
|
||||
|
||||
Wait Unitl Command Success
|
||||
[Arguments] ${cmd} ${times}=8 ${positive}=${true}
|
||||
:FOR ${n} IN RANGE 1 ${times}
|
||||
\ Log Trying ${cmd}: ${n} ... console=True
|
||||
\ ${rc} ${output}= Run And Return Rc And Output ${cmd}
|
||||
\ Run Keyword If ${positive} == ${true} Exit For Loop If '${rc}'=='0'
|
||||
\ ... ELSE Exit For Loop If '${rc}'!='0'
|
||||
\ Sleep 2
|
||||
Log ${output}
|
||||
Run Keyword If ${positive} == ${true} Should Be Equal As Strings '${rc}' '0'
|
||||
... ELSE Should Not Be Equal As Strings '${rc}' '0'
|
||||
[Return] ${output}
|
||||
|
||||
Retry Keyword When Error
|
||||
[Arguments] ${keyword} ${element}=${None} ${times}=6
|
||||
:For ${n} IN RANGE 1 ${times}
|
||||
|
@ -672,8 +672,7 @@ Test Case - Retag A Image Tag
|
||||
Sleep 1
|
||||
Go Into Repo project${random_num1}/redis
|
||||
Retag Image ${image_tag} project${random_num2} ${target_image_name} ${target_tag_value}
|
||||
|
||||
Wait Until Element Is Not Visible css=${modal-dialog}
|
||||
Retry Keyword When Error Wait Until Element Is Not Visible element=${repo_retag_confirm_dlg}
|
||||
Navigate To Projects
|
||||
Go Into Project project${random_num2}
|
||||
Sleep 1
|
||||
|
Loading…
Reference in New Issue
Block a user