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} ${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} 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} ... 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} Digest:
Should Contain ${output} Status: Should Contain ${output} Status:
Should Not Contain ${output} No such image: 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_sha256}= Set Variable If '${sha256}'=='${null}' ${image} ${image}@sha256:${sha256}
${image_with_tag}= Set Variable If '${sha256}'=='${null}' ${image} ${image}:${sha256} ${image_with_tag}= Set Variable If '${sha256}'=='${null}' ${image} ${image}:${sha256}
Log To Console \nRunning docker push ${image}... 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} 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} ... 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} 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 #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 [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
Log To Console \nRunning docker push ${image}... 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 login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${image}:${tag1} ${ip}/${project}/${image}:${tag} 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 push ${ip}/${project}/${image}:${tag}
@ -75,7 +77,7 @@ Cannot Pull Unsigned Image
Cannot Push image Cannot Push image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${err_msg}=${null} [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${err_msg}=${null}
Log To Console \nRunning docker push ${image}... 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 login -u ${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image} Wait Unitl Command Success docker tag ${image} ${ip}/${project}/${image}
${output}= Command Should be Failed docker push ${ip}/${project}/${image} ${output}= Command Should be Failed docker push ${ip}/${project}/${image}
@ -140,7 +142,10 @@ Docker Login
Docker Pull Docker Pull
[Arguments] ${image} [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 Docker Tag
[Arguments] ${src_image} ${dst_image} [Arguments] ${src_image} ${dst_image}

View File

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

View File

@ -101,8 +101,7 @@ Body Of Admin Push Signed Image
[Arguments] ${image}=tomcat ${with_remove}=${false} [Arguments] ${image}=tomcat ${with_remove}=${false}
Enable Notary Client Enable Notary Client
${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest Docker Pull hello-world:latest
Log ${output}
Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library 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} ${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 \ Sleep 2
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS' Should Be Equal As Strings '${out[0]}' 'PASS'
[Return] ${out[1]}
Retry Keyword When Return Value Mismatch Retry Keyword When Return Value Mismatch
[Arguments] ${keyword} ${expected_value} ${count} @{elements} [Arguments] ${keyword} ${expected_value} ${count} @{elements}