Add retries to test cases

Retry to solve the ecs environment s3aws Path not found issue

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2022-04-11 07:15:12 +00:00
parent f178e2520e
commit 6dfdda7778
5 changed files with 21 additions and 14 deletions

View File

@ -22,11 +22,26 @@ def oras_push(harbor_server, user, password, project, repo, tag):
fo = open(file_config, "w")
fo.write( "{\"doc\":\"readme.md\"}" )
fo.close()
exception = None
for _ in range(5):
exception = oras_push_cmd(harbor_server, project, repo, tag)
if exception == None:
break
if exception != None:
raise exception
return md5_artifact.split(' ')[0], md5_readme.split(' ')[0]
def oras_push_cmd(harbor_server, project, repo, tag):
try:
ret = base.run_command( [oras_cmd, "push", harbor_server + "/" + project + "/" + repo+":"+ tag,
"--manifest-config", "config.json:application/vnd.acme.rocket.config.v1+json", \
file_artifact+":application/vnd.acme.rocket.layer.v1+txt", \
file_readme +":application/vnd.acme.rocket.docs.layer.v1+json"] )
return md5_artifact.split(' ')[0], md5_readme.split(' ')[0]
return None
except Exception as e:
print("Run command error:", str(e))
return e
def oras_login(harbor_server, user, password):
ret = base.run_command([oras_cmd, "login", "-u", user, "-p", password, harbor_server])

View File

@ -20,10 +20,7 @@ Library Process
*** Keywords ***
CNAB Push Bundle
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0
Wait Unitl Command Success ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2}
Prepare Cnab Push Test Data
[Arguments] ${ip} ${user} ${pwd} ${project} ${index1_image1} ${index1_image2} ${index2_image1} ${index2_image2} ${image_tag}=latest

View File

@ -38,9 +38,7 @@ Helm Repo Push
Helm Chart Push
[Arguments] ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
Log ${output}
Should Be Equal As Integers ${rc} 0
Wait Unitl Command Success ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion}
Helm3.7 Registry Login
[Arguments] ${ip} ${user} ${password}

View File

@ -174,10 +174,7 @@ Body Of Admin Push Signed Image
${src_tag}= Set Variable latest
${src_image}= Set Variable ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${src_tag}
Docker Pull ${src_image}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${src_image} ${user} ${pwd}
Log ${output}
Should Be Equal As Integers ${rc} 0
Wait Unitl Command Success ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${src_image} ${user} ${pwd}
${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/projects/${project}/repositories/${image}/artifacts/${tag}?with_signature=true"

View File

@ -747,7 +747,7 @@ Test Case - Push Helm Chart and Display
Sign In Harbor ${HARBOR_URL} user010 Test1@34
Create An New Project And Go Into Project test${d}
Helm Chart Push ${ip} user010 Test1@34 ${chart_file} ${archive} test${d} ${repo_name} ${verion}
Retry Action Keyword Helm Chart Push ${ip} user010 Test1@34 ${chart_file} ${archive} test${d} ${repo_name} ${verion}
Go Into Project test${d}
Wait Until Page Contains test${d}/${repo_name}