Repull image when error

Docker pull command was enclosed to one keyword, in this keyword,
there're retry and log record.

Signed-off-by: Danfeng Liu (c) <danfengl@vmware.com>
This commit is contained in:
Danfeng Liu (c) 2019-12-31 11:31:52 +08:00
parent bbe40a551e
commit 1cdf7253cd
5 changed files with 17 additions and 14 deletions

View File

@ -28,7 +28,9 @@ Pull image
${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${user} -p ${pwd} ${ip}
${output}= Wait Unitl Command Success docker pull ${ip}/${project}/${image_with_tag}
${output}= Docker Pull ${ip}/${project}/${image_with_tag}
Log ${output}
Log To Console ${output}
Should Contain ${output} Digest:
Should Contain ${output} Status:
Should Not Contain ${output} No such image:
@ -38,7 +40,7 @@ Push image
${image_with_sha256}= Set Variable If '${sha256}'=='${null}' ${image} ${image}@sha256:${sha256}
${image_with_tag}= Set Variable If '${sha256}'=='${null}' ${image} ${image}:${sha256}
Log To Console \nRunning docker push ${image}...
Wait Unitl Command Success docker pull ${image_with_sha256}
Docker Pull ${image_with_sha256}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${image_with_sha256} ${ip}/${project}/${image_with_tag}
@ -50,7 +52,7 @@ 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}...
Wait Unitl Command Success docker pull ${image}:${tag1}
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}
@ -75,7 +77,7 @@ Cannot Pull Unsigned Image
Cannot Push image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${err_msg}=${null}
Log To Console \nRunning docker push ${image}...
Wait Unitl Command Success docker pull ${image}
Docker Pull ${image}
Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image}
${output}= Command Should be Failed docker push ${ip}/${project}/${image}
@ -140,7 +142,10 @@ Docker Login
Docker Pull
[Arguments] ${image}
Wait Unitl Command Success docker pull ${image}
${output}= Retry Keyword When Error Wait Unitl Command Success docker pull ${image}
Log ${output}
Log To Console Docker Pull: \n ${output}
[Return] ${output}
Docker Tag
[Arguments] ${src_image} ${dst_image}

View File

@ -80,9 +80,7 @@ Switch To LDAP
Config Harbor cfg auth=ldap_auth http_proxy=https
Prepare
Up Harbor
${rc}= Run And Return Rc docker pull osixia/openldap:1.1.7
Log ${rc}
Should Be Equal As Integers ${rc} 0
Docker Pull osixia/openldap:1.1.7
${rc} ${output}= Run And Return Rc And Output cd tests && ./ldapprepare.sh
Log ${rc}
Log ${output}

View File

@ -101,8 +101,7 @@ Body Of Admin Push Signed Image
[Arguments] ${image}=tomcat ${with_remove}=${false}
Enable Notary Client
${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest
Log ${output}
Docker Pull hello-world:latest
Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library hello-world:latest
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} library ${image} latest ${notaryServerEndpoint}

View File

@ -233,6 +233,7 @@ Retry Keyword When Error
\ Sleep 2
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
[Return] ${out[1]}
Retry Keyword When Return Value Mismatch
[Arguments] ${keyword} ${expected_value} ${count} @{elements}

View File

@ -26,13 +26,13 @@ ${HARBOR_URL} https://${ip}
Test Case - Registry Basic Verfication
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=true
Push image ${ip} tester${d} Test1@34 project${d} busybox:latest
Pull image ${ip} tester${d} Test1@34 project${d} busybox:latest
Pull image ${ip} tester${d} Test1@34 project${d} busybox:latest
Go Into Project project${d}
Delete Repo project${d}
Close Browser
Test Case - Clair Basic Verfication
@ -52,7 +52,7 @@ Test Case - Notary Basic Verfication
${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest
Log ${output}
Push image ${ip} %{HARBOR_ADMIN} %{HARBOR_PASSWORD} library hello-world:latest
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${notaryServerEndpoint}
Log ${output}